Class: Brightpearl::Product

Inherits:
Resource show all
Extended by:
APIOperations::Get, APIOperations::Options, APIOperations::Post, APIOperations::Put
Defined in:
lib/brightpearl/resources/product.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Get

get

Methods included from APIOperations::Post

post

Methods included from APIOperations::Put

put

Methods included from APIOperations::Options

options

Methods inherited from Resource

send_request, to_query

Constructor Details

#initialize(ara) ⇒ Product

DSL ARA => API Record Array



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/brightpearl/resources/product.rb', line 35

def initialize(ara)
  @id = ara[0];
  @product_name = ara[1]; @sku = ara[2]; @barcode = ara[3];  
  @ean = ara[4]; @upc = ara[5]; @isbn = ara[6]; @mpn = ara[7];
  @stock_tracked = ara[8]; @sales_channel_name = ara[9];
  @created_on = ara[10]; @updated_on = ara[11];
  @bright_pearl_category_code = ara[12]; @product_group_id = ara[13];
  @brand_id = ara[14]; 
  @product_type_id = ara[15];
  @product_status = ara[16];
  @primary_supplier_id = ara[17];
end

Instance Attribute Details

#barcodeObject

Returns the value of attribute barcode.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def barcode
  @barcode
end

#brand_idObject

Returns the value of attribute brand_id.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def brand_id
  @brand_id
end

#bright_pearl_category_codeObject

Returns the value of attribute bright_pearl_category_code.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def bright_pearl_category_code
  @bright_pearl_category_code
end

#created_onObject

Returns the value of attribute created_on.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def created_on
  @created_on
end

#eanObject

Returns the value of attribute ean.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def ean
  @ean
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def id
  @id
end

#isbnObject

Returns the value of attribute isbn.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def isbn
  @isbn
end

#mpnObject

Returns the value of attribute mpn.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def mpn
  @mpn
end

#primary_supplier_idObject

Returns the value of attribute primary_supplier_id.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def primary_supplier_id
  @primary_supplier_id
end

#product_group_idObject

Returns the value of attribute product_group_id.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def product_group_id
  @product_group_id
end

#product_nameObject

Returns the value of attribute product_name.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def product_name
  @product_name
end

#product_statusObject

Returns the value of attribute product_status.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def product_status
  @product_status
end

#product_type_idObject

Returns the value of attribute product_type_id.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def product_type_id
  @product_type_id
end

#sales_channel_nameObject

Returns the value of attribute sales_channel_name.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def sales_channel_name
  @sales_channel_name
end

#skuObject

Returns the value of attribute sku.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def sku
  @sku
end

#stock_trackedObject

Returns the value of attribute stock_tracked.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def stock_tracked
  @stock_tracked
end

#upcObject

Returns the value of attribute upc.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def upc
  @upc
end

#updated_onObject

Returns the value of attribute updated_on.



8
9
10
# File 'lib/brightpearl/resources/product.rb', line 8

def updated_on
  @updated_on
end

Class Method Details

.resource_pathObject



15
16
17
# File 'lib/brightpearl/resources/product.rb', line 15

def resource_path
  "product-service/product"
end

.search(query_params = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/brightpearl/resources/product.rb', line 25

def search(query_params = {})
  response = send_request(path: "product-service/product-search?#{to_query(query_params)}", method: :get)
  return response.merge({ # modify final payload to set search results as objects
    records: response[:payload]["response"]["results"].map { |item| Product.new(item) },
   })
end