orbit-4-2/lib/store.rb

52 lines
1.4 KiB
Ruby
Raw Normal View History

require 'httparty'
2014-02-11 10:14:45 +00:00
class Store
include HTTParty
format :json
2014-02-14 12:06:32 +00:00
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
2014-02-14 12:06:32 +00:00
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
2014-02-14 12:06:32 +00:00
def get_extension(id)
options = @options_for_get
self.class.get("/extensions/#{id}", options)
end
def post_client(site_id,site_token,site_name,url,university,department,email,country)
options = @options_for_client.merge({ :body => {:site_name => site_name, :site_id => site_id,:url => url, :university => university, :department => department, :email => email, :country => country, :site_token => site_token}.to_json })
self.class.post('/clients', options )
end
2014-02-11 10:14:45 +00:00
end