41 lines
1.0 KiB
Ruby
41 lines
1.0 KiB
Ruby
require 'httparty'
|
|
class Store
|
|
include HTTParty
|
|
|
|
format :json
|
|
base_uri STORE_CONFIG[:store_settings]["url"]
|
|
|
|
def initialize(site_id,site_token,api_key)
|
|
@options_for_get = {
|
|
headers: {
|
|
"Authorization" => api_key,
|
|
"X_SiteToken" => site_token,
|
|
"X_SiteId" => site_id,
|
|
"Content-Type" => "application/json"
|
|
}
|
|
}
|
|
|
|
@options_for_client = {
|
|
headers: {
|
|
"Authorization" => api_key,
|
|
"Content-Type" => "application/json"
|
|
}
|
|
}
|
|
end
|
|
|
|
def templates(options={})
|
|
options = @options_for_get
|
|
response = self.class.get('/templates', options)
|
|
puts response.request.last_uri.to_s
|
|
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
|
|
end |