class DoocaCommerce

Constants

URL

Attributes

handler[R]
token[R]

Public Class Methods

new(token:) click to toggle source
# File lib/dooca_commerce.rb, line 6
def initialize(token:)
  @token = token
  @handler = ResponseHandler
end

Public Instance Methods

create_attribute(body) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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:) click to toggle source
# 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_product(body) click to toggle source
# 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) click to toggle source
# File lib/dooca_commerce.rb, line 91
def create_variation(body)
  response = connection.post("/variations", body.to_json)

  handler.new(response).parse!
end
fetch_attributes(query = {}) click to toggle source
# File lib/dooca_commerce.rb, line 73
def fetch_attributes(query = {})
  response = connection.get("/attributes", query)

  handler.new(response).parse!
end
fetch_brands(query = {}) click to toggle source
# File lib/dooca_commerce.rb, line 67
def fetch_brands(query = {})
  response = connection.get("/brands", query)

  handler.new(response).parse!
end
fetch_categories(query = {}) click to toggle source
# 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:) click to toggle source
# 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 = {}) click to toggle source
# 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:) click to toggle source
# 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 = {}) click to toggle source
# File lib/dooca_commerce.rb, line 49
def fetch_orders(query = {})
  response = connection.get("/orders", query)

  handler.new(response).parse!
end
fetch_product(query = {}) click to toggle source
# 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 = {}) click to toggle source
# File lib/dooca_commerce.rb, line 13
def fetch_products(query = {})
  response = connection.get("/products", query)

  handler.new(response).parse!
end
fetch_variation(query = {}) click to toggle source
# 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 = {}) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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:) click to toggle source
# 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

Private Instance Methods

connection() click to toggle source
# File lib/dooca_commerce.rb, line 198
def connection
  @connection ||= Faraday.new(url: URL, headers: headers)
end
headers() click to toggle source
# File lib/dooca_commerce.rb, line 191
def headers
  {
    "Content-Type" => "application/json",
    "Authorization": "Bearer #{token}"
  }
end