Class: BuckyBox::API
Constant Summary collapse
- ResponseError =
Class.new(Exception)
Instance Method Summary collapse
- #authenticate_customer(params = {}, options = {}) ⇒ Object
- #box(id, params = {embed: "extras,images,box_items"}, options = {}) ⇒ Object
- #boxes(params = {embed: "extras,images,box_items"}, options = {}) ⇒ Object
- #create_or_update_customer(json_customer) ⇒ Object
- #create_order(json_order) ⇒ Object
- #customer(id, params = {}, options = {}) ⇒ Object
- #customers(params = {}, options = {}) ⇒ Object
- #delivery_service(id, params = {}, options = {}) ⇒ Object
- #delivery_services(params = {}, options = {}) ⇒ Object
-
#initialize(headers) ⇒ API
constructor
A new instance of API.
- #webstore ⇒ Object
Constructor Details
#initialize(headers) ⇒ API
Returns a new instance of API.
14 15 16 |
# File 'lib/buckybox/api.rb', line 14 def initialize(headers) self.class.headers(headers) end |
Instance Method Details
#authenticate_customer(params = {}, options = {}) ⇒ Object
46 47 48 |
# File 'lib/buckybox/api.rb', line 46 def authenticate_customer(params = {}, = {}) query :post, "/customers/sign_in", params, end |
#box(id, params = {embed: "extras,images,box_items"}, options = {}) ⇒ Object
22 23 24 |
# File 'lib/buckybox/api.rb', line 22 def box(id, params = {embed: "extras,images,box_items"}, = {}) query :get, "/boxes/#{id}", params, , price: CrazyMoney end |
#boxes(params = {embed: "extras,images,box_items"}, options = {}) ⇒ Object
18 19 20 |
# File 'lib/buckybox/api.rb', line 18 def boxes(params = {embed: "extras,images,box_items"}, = {}) query :get, "/boxes", params, , price: CrazyMoney end |
#create_or_update_customer(json_customer) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/buckybox/api.rb', line 50 def create_or_update_customer(json_customer) customer = JSON.parse(json_customer) if customer['id'] query :put, "/customers/#{customer['id']}", json_customer # TODO: replace by :patch else query :post, "/customers", json_customer end end |
#create_order(json_order) ⇒ Object
60 61 62 |
# File 'lib/buckybox/api.rb', line 60 def create_order(json_order) query :post, "/orders", json_order end |
#customer(id, params = {}, options = {}) ⇒ Object
42 43 44 |
# File 'lib/buckybox/api.rb', line 42 def customer(id, params = {}, = {}) query :get, "/customers/#{id}", params, , account_balance: CrazyMoney end |
#customers(params = {}, options = {}) ⇒ Object
38 39 40 |
# File 'lib/buckybox/api.rb', line 38 def customers(params = {}, = {}) query :get, "/customers", params, , account_balance: CrazyMoney end |
#delivery_service(id, params = {}, options = {}) ⇒ Object
30 31 32 |
# File 'lib/buckybox/api.rb', line 30 def delivery_service(id, params = {}, = {}) query :get, "/delivery_services/#{id}", params, , fee: CrazyMoney end |
#delivery_services(params = {}, options = {}) ⇒ Object
26 27 28 |
# File 'lib/buckybox/api.rb', line 26 def delivery_services(params = {}, = {}) query :get, "/delivery_services", params, , fee: CrazyMoney end |
#webstore ⇒ Object
34 35 36 |
# File 'lib/buckybox/api.rb', line 34 def webstore query :get, "/webstore" end |