Class: Shoppy::Client
- Inherits:
-
Object
- Object
- Shoppy::Client
- Defined in:
- lib/shoppy/client.rb
Class Method Summary collapse
- .auth(hostname, license) ⇒ Object
- .delete(path, params = nil) ⇒ Object
- .execute(method, path, params = nil) ⇒ Object
- .get(path, params = nil) ⇒ Object
- .post(path, params) ⇒ Object
- .put(path, params) ⇒ Object
Class Method Details
.auth(hostname, license) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/shoppy/client.rb', line 15 def self.auth(hostname, license) begin response = self.get('validate', {:domain => hostname, :license => license}) return response.parsed_response rescue => e return 'error' => e. end end |
.delete(path, params = nil) ⇒ Object
36 37 38 |
# File 'lib/shoppy/client.rb', line 36 def self.delete(path, params = nil) self.execute(:delete, path, params) end |
.execute(method, path, params = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/shoppy/client.rb', line 40 def self.execute(method, path, params = nil) begin request = HTTMultiParty.send(method, Shoppy.api_url(path), { query: params, timeout: 300 }) if request.respond_to?('parsed_response') return request.parsed_response else return request end rescue => e return 'error' => e. # error end end |
.get(path, params = nil) ⇒ Object
24 25 26 |
# File 'lib/shoppy/client.rb', line 24 def self.get(path, params = nil) self.execute(:get, path, params) end |
.post(path, params) ⇒ Object
28 29 30 |
# File 'lib/shoppy/client.rb', line 28 def self.post(path, params) self.execute(:post, path, params) end |
.put(path, params) ⇒ Object
32 33 34 |
# File 'lib/shoppy/client.rb', line 32 def self.put(path, params) self.execute(:put, path, params) end |