Class: BuckyBox::API
Defined Under Namespace
Classes: CachedResponse
Constant Summary collapse
- ResponseError =
generic error
Class.new(Exception)
- NotFoundError =
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: "images"}, 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
- #flush_cache! ⇒ Object
-
#initialize(headers) ⇒ API
constructor
A new instance of API.
- #webstore ⇒ Object
Constructor Details
#initialize(headers) ⇒ API
Returns a new instance of API.
31 32 33 |
# File 'lib/buckybox/api.rb', line 31 def initialize(headers) self.class.headers(headers) end |
Instance Method Details
#authenticate_customer(params = {}, options = {}) ⇒ Object
63 64 65 |
# File 'lib/buckybox/api.rb', line 63 def authenticate_customer(params = {}, = {}) query :post, "/customers/sign_in", params, end |
#box(id, params = {embed: "extras,images,box_items"}, options = {}) ⇒ Object
39 40 41 |
# File 'lib/buckybox/api.rb', line 39 def box(id, params = {embed: "extras,images,box_items"}, = {}) query :get, "/boxes/#{id}", params, , price: CrazyMoney end |
#boxes(params = {embed: "images"}, options = {}) ⇒ Object
35 36 37 |
# File 'lib/buckybox/api.rb', line 35 def boxes(params = {embed: "images"}, = {}) query :get, "/boxes", params, , price: CrazyMoney end |
#create_or_update_customer(json_customer) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/buckybox/api.rb', line 67 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
77 78 79 |
# File 'lib/buckybox/api.rb', line 77 def create_order(json_order) query :post, "/orders", json_order end |
#customer(id, params = {}, options = {}) ⇒ Object
59 60 61 |
# File 'lib/buckybox/api.rb', line 59 def customer(id, params = {}, = {}) query :get, "/customers/#{id}", params, , account_balance: CrazyMoney end |
#customers(params = {}, options = {}) ⇒ Object
55 56 57 |
# File 'lib/buckybox/api.rb', line 55 def customers(params = {}, = {}) query :get, "/customers", params, , account_balance: CrazyMoney end |
#delivery_service(id, params = {}, options = {}) ⇒ Object
47 48 49 |
# File 'lib/buckybox/api.rb', line 47 def delivery_service(id, params = {}, = {}) query :get, "/delivery_services/#{id}", params, , fee: CrazyMoney end |
#delivery_services(params = {}, options = {}) ⇒ Object
43 44 45 |
# File 'lib/buckybox/api.rb', line 43 def delivery_services(params = {}, = {}) query :get, "/delivery_services", params, , fee: CrazyMoney end |
#flush_cache! ⇒ Object
81 82 83 |
# File 'lib/buckybox/api.rb', line 81 def flush_cache! @cache = nil end |
#webstore ⇒ Object
51 52 53 |
# File 'lib/buckybox/api.rb', line 51 def webstore query :get, "/webstore" end |