Class: Bling::API::Product

Inherits:
Request
  • Object
show all
Defined in:
lib/bling/api/product.rb

Overview

This class is used to make requests to all available actions related to products in Bling api. Is strongly recommended to use the Bling::API module wrapper

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bling::API::Request

Instance Method Details

#create(params) ⇒ [Record]

Insert a product in Bling

Examples:

product = Bling::API::Product.new.create(
  {
  code: '92314',
  description: 'Awesome product',
  additional_description: 'In lovely colors',
  unit: 'Pc',
  price: 20.50,
  cost_price: 14.30,
  raw_weight: 2,
  weight: 1.8,
  tax_category: '1000.01.01',
  origin: 0,
  quantity: 10,
  gtin: 832222,
  gtin_package: 13414,
  width: 25,
  height: 15,
  depth: 10,
  min_quantity: 1,
  max_quantity: 200
  }
)


63
64
65
66
# File 'lib/bling/api/product.rb', line 63

def create(params)
  @params = params
  post_request(t_url(:product), parsed_xml)
end

#delete(product_id) ⇒ [Record]

Delete a product in Bling

Examples:

Bling::API::Product.new.delete(1)


113
114
115
# File 'lib/bling/api/product.rb', line 113

def delete(product_id)
  delete_request(t_url(:product, product_id))
end

#get(product_id) ⇒ [Record]

Get a specific object based on product_id

Examples:

product = Bling::API::Product.new.get


29
30
31
# File 'lib/bling/api/product.rb', line 29

def get(product_id)
  get_request(t_url(:product, product_id))
end

#list[Record]

Get a list of available products

Examples:

products = Bling::API::Product.new.list


16
17
18
# File 'lib/bling/api/product.rb', line 16

def list
  get_request(t_url(:products))
end

#update(product_id, params) ⇒ [Record]

Update a product in Bling

Examples:

product = Bling::API::Product.new.create(
  {
  code: '92314',
  description: 'Awesome product',
  additional_description: 'In lovely colors',
  unit: 'Pc',
  price: 20.50,
  cost_price: 14.30,
  raw_weight: 2,
  weight: 1.8,
  tax_category: '1000.01.01',
  origin: 0,
  quantity: 10,
  gtin: 832222,
  gtin_package: 13414,
  width: 25,
  height: 15,
  depth: 10,
  min_quantity: 1,
  max_quantity: 200
  }
)


99
100
101
102
# File 'lib/bling/api/product.rb', line 99

def update(product_id, params)
  @params = params
  post_request(t_url(:product, product_id), parsed_xml)
end