Class: DoocaCommerce
- Inherits:
-
Object
- Object
- DoocaCommerce
- Defined in:
- lib/dooca_commerce.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #create_attribute(body) ⇒ Object
- #create_attribute_value(body) ⇒ Object
- #create_brand(body) ⇒ Object
- #create_category(body) ⇒ Object
- #create_color(body) ⇒ Object
- #create_fulfillment(order_id:) ⇒ Object
- #create_image(product_id:, body:) ⇒ Object
- #create_product(body) ⇒ Object
- #create_variation(body) ⇒ Object
- #delete_image(product_id:, image_id:) ⇒ Object
- #fetch_attributes(query = {}) ⇒ Object
- #fetch_brands(query = {}) ⇒ Object
- #fetch_categories(query = {}) ⇒ Object
- #fetch_category(category_id:) ⇒ Object
- #fetch_colors(query = {}) ⇒ Object
- #fetch_order(order_id:) ⇒ Object
- #fetch_orders(query = {}) ⇒ Object
- #fetch_product(query = {}) ⇒ Object
- #fetch_products(query = {}) ⇒ Object
- #fetch_variation(query = {}) ⇒ Object
- #fetch_variations(query = {}) ⇒ Object
-
#initialize(token:) ⇒ DoocaCommerce
constructor
A new instance of DoocaCommerce.
- #mark_as_delivered(order_id:) ⇒ Object
- #update_attribute(attribute_id:, body:) ⇒ Object
- #update_attribute_value(attribute_value_id:, body:) ⇒ Object
- #update_brand(brand_id:, body:) ⇒ Object
- #update_category(category_id:, body:) ⇒ Object
- #update_color(color_id:, body:) ⇒ Object
- #update_invoice(order_id:, body:) ⇒ Object
- #update_product(product_id:, body:) ⇒ Object
- #update_tracking(order_id:, body:) ⇒ Object
- #update_variation(variation_id:, body:) ⇒ Object
Constructor Details
#initialize(token:) ⇒ DoocaCommerce
Returns a new instance of DoocaCommerce.
6 7 8 9 |
# File 'lib/dooca_commerce.rb', line 6 def initialize(token:) @token = token @handler = ResponseHandler end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
11 12 13 |
# File 'lib/dooca_commerce.rb', line 11 def handler @handler end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
11 12 13 |
# File 'lib/dooca_commerce.rb', line 11 def token @token end |
Instance Method Details
#create_attribute(body) ⇒ Object
139 140 141 142 143 |
# File 'lib/dooca_commerce.rb', line 139 def create_attribute(body) response = connection.post("/attributes", body.to_json) handler.new(response).parse! end |
#create_attribute_value(body) ⇒ Object
151 152 153 154 155 |
# File 'lib/dooca_commerce.rb', line 151 def create_attribute_value(body) response = connection.post("/attributes/values", body.to_json) handler.new(response).parse! end |
#create_brand(body) ⇒ Object
115 116 117 118 119 |
# File 'lib/dooca_commerce.rb', line 115 def create_brand(body) response = connection.post("/brands", body.to_json) handler.new(response).parse! end |
#create_category(body) ⇒ Object
103 104 105 106 107 |
# File 'lib/dooca_commerce.rb', line 103 def create_category(body) response = connection.post("/categories", body.to_json) handler.new(response).parse! end |
#create_color(body) ⇒ Object
127 128 129 130 131 |
# File 'lib/dooca_commerce.rb', line 127 def create_color(body) response = connection.post("/colors", body.to_json) handler.new(response).parse! end |
#create_fulfillment(order_id:) ⇒ Object
163 164 165 166 167 |
# File 'lib/dooca_commerce.rb', line 163 def create_fulfillment(order_id:) response = connection.post("/orders/#{order_id}/fulfillment") handler.new(response).parse! end |
#create_image(product_id:, body:) ⇒ Object
193 194 195 196 197 |
# File 'lib/dooca_commerce.rb', line 193 def create_image(product_id:, body:) response = connection.post("/products/#{product_id}/images", body.to_json) handler.new(response).parse! end |
#create_product(body) ⇒ Object
79 80 81 82 83 |
# File 'lib/dooca_commerce.rb', line 79 def create_product(body) response = connection.post("/products", body.to_json) handler.new(response).parse! end |
#create_variation(body) ⇒ Object
91 92 93 94 95 |
# File 'lib/dooca_commerce.rb', line 91 def create_variation(body) response = connection.post("/variations", body.to_json) handler.new(response).parse! end |
#delete_image(product_id:, image_id:) ⇒ Object
187 188 189 190 191 |
# File 'lib/dooca_commerce.rb', line 187 def delete_image(product_id:, image_id:) response = connection.delete("/products/#{product_id}/images/#{image_id}") handler.new(response).parse! end |
#fetch_attributes(query = {}) ⇒ Object
73 74 75 76 77 |
# File 'lib/dooca_commerce.rb', line 73 def fetch_attributes(query = {}) response = connection.get("/attributes", query) handler.new(response).parse! end |
#fetch_brands(query = {}) ⇒ Object
67 68 69 70 71 |
# File 'lib/dooca_commerce.rb', line 67 def fetch_brands(query = {}) response = connection.get("/brands", query) handler.new(response).parse! end |
#fetch_categories(query = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/dooca_commerce.rb', line 37 def fetch_categories(query = {}) response = connection.get("/categories", query) handler.new(response).parse! end |
#fetch_category(category_id:) ⇒ Object
43 44 45 46 47 |
# File 'lib/dooca_commerce.rb', line 43 def fetch_category(category_id:) response = connection.get("/categories/#{category_id}") handler.new(response).parse! end |
#fetch_colors(query = {}) ⇒ Object
61 62 63 64 65 |
# File 'lib/dooca_commerce.rb', line 61 def fetch_colors(query = {}) response = connection.get("/colors", query) handler.new(response).parse! end |
#fetch_order(order_id:) ⇒ Object
55 56 57 58 59 |
# File 'lib/dooca_commerce.rb', line 55 def fetch_order(order_id:) response = connection.get("/orders/#{order_id}") handler.new(response).parse! end |
#fetch_orders(query = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/dooca_commerce.rb', line 49 def fetch_orders(query = {}) response = connection.get("/orders", query) handler.new(response).parse! end |
#fetch_product(query = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/dooca_commerce.rb', line 19 def fetch_product(query = {}) response = connection.get("/products", query) handler.new(response, single_from_list: true).parse! end |
#fetch_products(query = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/dooca_commerce.rb', line 13 def fetch_products(query = {}) response = connection.get("/products", query) handler.new(response).parse! end |
#fetch_variation(query = {}) ⇒ Object
31 32 33 34 35 |
# File 'lib/dooca_commerce.rb', line 31 def fetch_variation(query = {}) response = connection.get("/variations", query) handler.new(response, single_from_list: true).parse! end |
#fetch_variations(query = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/dooca_commerce.rb', line 25 def fetch_variations(query = {}) response = connection.get("/variations", query) handler.new(response).parse! end |
#mark_as_delivered(order_id:) ⇒ Object
181 182 183 184 185 |
# File 'lib/dooca_commerce.rb', line 181 def mark_as_delivered(order_id:) response = connection.put("/orders/#{order_id}/fulfillment/delivered") handler.new(response).parse! end |
#update_attribute(attribute_id:, body:) ⇒ Object
145 146 147 148 149 |
# File 'lib/dooca_commerce.rb', line 145 def update_attribute(attribute_id:, body:) response = connection.put("/attributes/#{attribute_id}", body.to_json) handler.new(response).parse! end |
#update_attribute_value(attribute_value_id:, body:) ⇒ Object
157 158 159 160 161 |
# File 'lib/dooca_commerce.rb', line 157 def update_attribute_value(attribute_value_id:, body:) response = connection.put("/attributes/values/#{attribute_value_id}", body.to_json) handler.new(response).parse! end |
#update_brand(brand_id:, body:) ⇒ Object
121 122 123 124 125 |
# File 'lib/dooca_commerce.rb', line 121 def update_brand(brand_id:, body:) response = connection.put("/brands/#{brand_id}", body.to_json) handler.new(response).parse! end |
#update_category(category_id:, body:) ⇒ Object
109 110 111 112 113 |
# File 'lib/dooca_commerce.rb', line 109 def update_category(category_id:, body:) response = connection.put("/categories/#{category_id}", body.to_json) handler.new(response).parse! end |
#update_color(color_id:, body:) ⇒ Object
133 134 135 136 137 |
# File 'lib/dooca_commerce.rb', line 133 def update_color(color_id:, body:) response = connection.put("/colors/#{color_id}", body.to_json) handler.new(response).parse! end |
#update_invoice(order_id:, body:) ⇒ Object
169 170 171 172 173 |
# File 'lib/dooca_commerce.rb', line 169 def update_invoice(order_id:, body:) response = connection.put("/orders/#{order_id}/fulfillment/invoiced", body.to_json) handler.new(response).parse! end |
#update_product(product_id:, body:) ⇒ Object
85 86 87 88 89 |
# File 'lib/dooca_commerce.rb', line 85 def update_product(product_id:, body:) response = connection.put("/products/#{product_id}", body.to_json) handler.new(response).parse! end |
#update_tracking(order_id:, body:) ⇒ Object
175 176 177 178 179 |
# File 'lib/dooca_commerce.rb', line 175 def update_tracking(order_id:, body:) response = connection.put("/orders/#{order_id}/fulfillment/shipped", body.to_json) handler.new(response).parse! end |
#update_variation(variation_id:, body:) ⇒ Object
97 98 99 100 101 |
# File 'lib/dooca_commerce.rb', line 97 def update_variation(variation_id:, body:) response = connection.put("/variations/#{variation_id}", body.to_json) handler.new(response).parse! end |