class EcwidApi::Api::ProductCombinations

Attributes

product[R]

Public Class Methods

new(product, client) click to toggle source
Calls superclass method EcwidApi::Api::Base::new
# File lib/ecwid_api/api/product_combinations.rb, line 9
def initialize(product, client)
  @product = product
  super(client)
end

Public Instance Methods

all() click to toggle source
# File lib/ecwid_api/api/product_combinations.rb, line 14
def all
  response = client.get("products/#{product.id}/combinations")

  if response.success?
    response.body.map do |data|
      ProductCombination.new(data, client: client, product: product)
    end
  end
end
create(params) click to toggle source
# File lib/ecwid_api/api/product_combinations.rb, line 38
def create(params)
  response = client.post("products/#{product.id}/combinations", params)
  find(response.body["id"])
end
delete_all!() click to toggle source
# File lib/ecwid_api/api/product_combinations.rb, line 43
def delete_all!
  client.delete("products/#{product.id}/combinations")
end
each(&block) click to toggle source
# File lib/ecwid_api/api/product_combinations.rb, line 24
def each(&block)
  all = self.all || []

  all.each(&block)
end
find(id) click to toggle source
# File lib/ecwid_api/api/product_combinations.rb, line 30
def find(id)
  response = client.get("products/#{product.id}/combinations/#{id}")

  if response.success?
    ProductCombination.new(response.body, product: product, client: client)
  end
end