Class: BlingApi::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/bling_api/product.rb

Constant Summary collapse

ACCESS_TOKEN =
"0039bb7d2d3e3c6777983361204dc168ecbf1ef8"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, nome:, sku:) ⇒ Product

Returns a new instance of Product.



13
14
15
16
17
# File 'lib/bling_api/product.rb', line 13

def initialize(id:, nome:, sku:)
  @id = id
  @nome = nome
  @sku = sku
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/bling_api/product.rb', line 12

def id
  @id
end

#nomeObject (readonly)

Returns the value of attribute nome.



12
13
14
# File 'lib/bling_api/product.rb', line 12

def nome
  @nome
end

#skuObject (readonly)

Returns the value of attribute sku.



12
13
14
# File 'lib/bling_api/product.rb', line 12

def sku
  @sku
end

Class Method Details

.find_by_sku(sku) ⇒ Object



5
6
7
8
9
10
# File 'lib/bling_api/product.rb', line 5

def self.find_by_sku sku
  response_json = Client.new(ACCESS_TOKEN).find_product_by_sku(sku)
  if response_json
    new(**build_hash(response_json))
  end
end