require 'httparty' class Store include HTTParty format :json base_uri STORE_CONFIG[:store_settings]["api_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", 'Accept' => 'application/json' } } @options_for_client = { headers: { "Authorization" => api_key, "Content-Type" => "application/json", 'Accept' => 'application/json' } } end def templates(options={}) options = @options_for_get self.class.get('/templates', options) end def get_template(id) options = @options_for_get self.class.get("/templates/#{id}", options) end def extensions(options={}) options = @options_for_get self.class.get('/extensions', options) end def get_extension(id) options = @options_for_get self.class.get("/extensions/#{id}", 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