Class: Flexibee::Product
- Inherits:
-
Object
- Object
- Flexibee::Product
- Defined in:
- lib/flexibee/product.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#ean ⇒ Object
Returns the value of attribute ean.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#note ⇒ Object
Returns the value of attribute note.
-
#price_base ⇒ Object
Returns the value of attribute price_base.
-
#price_no_vat ⇒ Object
Returns the value of attribute price_no_vat.
-
#price_vat ⇒ Object
Returns the value of attribute price_vat.
-
#stock ⇒ Object
Returns the value of attribute stock.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#vat ⇒ Object
Returns the value of attribute vat.
Instance Method Summary collapse
-
#category ⇒ Object
TODO test.
-
#find_relationship ⇒ Object
TODO test.
-
#initialize(response, client) ⇒ Product
constructor
Product basic response.
Constructor Details
#initialize(response, client) ⇒ Product
Product basic response
{ “id” => “4797”, “lastUpdate” => “2015-09-30T15:42:45.190+02:00”, “kod” => “B0002”, “nazev” => “Dámský zvýhodněný balíček”, “cenaZakl” => “1361.157024”, “cenaZaklBezDph” => “1361.157024”, “cenaZaklVcDph” => “1646.999999”,
"sumDostupMj" => "0.0",
"poznam" => "NENÍ FOTO",
"popis" => "",
"eanKod" => "",
"szbDph" => "21.0"
}
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/flexibee/product.rb', line 24 def initialize(response, client) @id = response['id'].to_i @updated_at = response['lastUpdate'] @code = response['kod'] @name = response['nazev'] @price_base = response['cenaZakl'].to_f @price_no_vat = response['cenaZaklBezDph'].to_f @price_vat = response['cenaZaklVcDph'].to_f @stock = response['sumDostupMj'].to_f @note = response['poznam'] @description = response['popis'] @ean = response['eanKod'] @vat = response['szbDph'].to_f @client = client end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def code @code end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def description @description end |
#ean ⇒ Object
Returns the value of attribute ean.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def ean @ean end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def name @name end |
#note ⇒ Object
Returns the value of attribute note.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def note @note end |
#price_base ⇒ Object
Returns the value of attribute price_base.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def price_base @price_base end |
#price_no_vat ⇒ Object
Returns the value of attribute price_no_vat.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def price_no_vat @price_no_vat end |
#price_vat ⇒ Object
Returns the value of attribute price_vat.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def price_vat @price_vat end |
#stock ⇒ Object
Returns the value of attribute stock.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def stock @stock end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def updated_at @updated_at end |
#vat ⇒ Object
Returns the value of attribute vat.
3 4 5 |
# File 'lib/flexibee/product.rb', line 3 def vat @vat end |
Instance Method Details
#category ⇒ Object
TODO test
41 42 43 44 |
# File 'lib/flexibee/product.rb', line 41 def category uzel_id = find_relationship ? find_relationship['uzel'] : find_relationship uzel_id ? @client.tree.find_by_id(uzel_id.to_i).first : nil end |
#find_relationship ⇒ Object
TODO test
47 48 49 |
# File 'lib/flexibee/product.rb', line 47 def find_relationship @client.get("/strom-cenik", { detail: 'full' }, "idZaznamu='#{id}'")['winstrom']['strom-cenik'][0] end |