Class: Delivery::Client
- Inherits:
-
Object
- Object
- Delivery::Client
- Includes:
- HTTParty
- Defined in:
- lib/delivery/client.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
Instance Method Summary collapse
- #info(id) ⇒ Object
-
#initialize(client_id, options = {}) ⇒ Client
constructor
A new instance of Client.
- #search(address) ⇒ Object
Constructor Details
#initialize(client_id, options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/delivery/client.rb', line 11 def initialize(client_id, ={}) @client_id = client_id [:base_uri] ||= 'https://api.delivery.com' @base_uri = [:base_uri] end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
9 10 11 |
# File 'lib/delivery/client.rb', line 9 def base_uri @base_uri end |
#client_id ⇒ Object
Returns the value of attribute client_id.
9 10 11 |
# File 'lib/delivery/client.rb', line 9 def client_id @client_id end |
Instance Method Details
#info(id) ⇒ Object
24 25 26 27 28 |
# File 'lib/delivery/client.rb', line 24 def info id = {query: {client_id: client_id}} response = self.class.get("#{base_uri}/merchant/#{id}", ) Hashie::Mash.new(JSON.parse(response.body)) end |
#search(address) ⇒ Object
18 19 20 21 22 |
# File 'lib/delivery/client.rb', line 18 def search address = {query: {client_id: client_id, address: address}} response = self.class.get("#{base_uri}/merchant/search/delivery", ) Hashie::Mash.new(JSON.parse(response.body)) end |