2014-02-14 06:38:28 +00:00
|
|
|
require 'httparty'
|
2014-02-11 10:14:45 +00:00
|
|
|
class Store
|
|
|
|
include HTTParty
|
|
|
|
|
2014-02-14 06:38:28 +00:00
|
|
|
format :json
|
|
|
|
base_uri STORE_CONFIG[:store_settings]["url"]
|
|
|
|
|
|
|
|
def initialize(site_id,site_token,api_key)
|
|
|
|
@options_for_get = {
|
|
|
|
headers: {
|
|
|
|
"Authorization" => api_key,
|
2014-02-14 08:57:05 +00:00
|
|
|
"X-SiteToken" => site_token,
|
|
|
|
"X-SiteId" => site_id,
|
|
|
|
"Content-Type" => "application/json",
|
|
|
|
'Accept' => 'application/json'
|
2014-02-14 06:38:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@options_for_client = {
|
|
|
|
headers: {
|
|
|
|
"Authorization" => api_key,
|
2014-02-14 08:57:05 +00:00
|
|
|
"Content-Type" => "application/json",
|
|
|
|
'Accept' => 'application/json'
|
2014-02-14 06:38:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def templates(options={})
|
|
|
|
options = @options_for_get
|
2014-02-14 08:57:05 +00:00
|
|
|
self.class.get('/templates', options)
|
2014-02-14 06:38:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def extensions(options={})
|
|
|
|
options = @options_for_get
|
|
|
|
self.class.get('/extensions', options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_client(site_id,site_token,site_name)
|
|
|
|
options = @options_for_client.merge({ :body => {:site_name => site_name, :site_id => site_id, :site_token => site_token}.to_json })
|
|
|
|
self.class.post('/clients', options )
|
|
|
|
end
|
2014-02-11 10:14:45 +00:00
|
|
|
end
|