Class: BlingApi::Product
- Inherits:
-
Object
- Object
- BlingApi::Product
- Defined in:
- lib/bling_api/product.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#nome ⇒ Object
readonly
Returns the value of attribute nome.
-
#sku ⇒ Object
readonly
Returns the value of attribute sku.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, nome:, sku:) ⇒ Product
constructor
A new instance of Product.
Constructor Details
#initialize(id:, nome:, sku:) ⇒ Product
Returns a new instance of Product.
11 12 13 14 15 |
# File 'lib/bling_api/product.rb', line 11 def initialize(id:, nome:, sku:) @id = id @nome = nome @sku = sku end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/bling_api/product.rb', line 10 def id @id end |
#nome ⇒ Object (readonly)
Returns the value of attribute nome.
10 11 12 |
# File 'lib/bling_api/product.rb', line 10 def nome @nome end |
#sku ⇒ Object (readonly)
Returns the value of attribute sku.
10 11 12 |
# File 'lib/bling_api/product.rb', line 10 def sku @sku end |
Class Method Details
.build_hash(json_response) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/bling_api/product.rb', line 17 def self.build_hash json_response { id: json_response["id"], nome: json_response["nome"], sku: json_response["codigo"] } end |
.find_by_sku(sku) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/bling_api/product.rb', line 3 def self.find_by_sku sku response_json = Client.new(BlingApi.configuration.access_token).find_product_by_sku(sku) if response_json new(**build_hash(response_json)) end end |