Class: Bcash::Package
- Inherits:
-
Object
- Object
- Bcash::Package
- Defined in:
- lib/bcash/package.rb
Instance Attribute Summary collapse
-
#integration ⇒ Object
Returns the value of attribute integration.
-
#items ⇒ Object
Returns the value of attribute items.
-
#shipping_cost ⇒ Object
Returns the value of attribute shipping_cost.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(items, shipping_cost, integration) ⇒ Package
constructor
A new instance of Package.
Constructor Details
#initialize(items, shipping_cost, integration) ⇒ Package
Returns a new instance of Package.
7 8 9 10 11 |
# File 'lib/bcash/package.rb', line 7 def initialize(items, shipping_cost, integration) @items = items @shipping_cost = shipping_cost @integration = integration end |
Instance Attribute Details
#integration ⇒ Object
Returns the value of attribute integration.
5 6 7 |
# File 'lib/bcash/package.rb', line 5 def integration @integration end |
#items ⇒ Object
Returns the value of attribute items.
5 6 7 |
# File 'lib/bcash/package.rb', line 5 def items @items end |
#shipping_cost ⇒ Object
Returns the value of attribute shipping_cost.
5 6 7 |
# File 'lib/bcash/package.rb', line 5 def shipping_cost @shipping_cost end |
Class Method Details
.create(items, shipping_cost = 0, integration = Bcash::PAD) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bcash/package.rb', line 15 def create(items, shipping_cost = 0, integration = Bcash::PAD) items_humanize_bcash = {} items.each_with_index do |item, index| amount_to_post = index + 1 items_humanize_bcash[:"produto_codigo_#{amount_to_post}"] = item.id items_humanize_bcash[:"produto_descricao_#{amount_to_post}"] = item.description items_humanize_bcash[:"produto_qtde_#{amount_to_post}"] = item.amount items_humanize_bcash[:"produto_valor_#{amount_to_post}"] = item.price end items_humanize_bcash[:tipo_integracao] = integration items_humanize_bcash[:frete] = shipping_cost Package.new(items_humanize_bcash, items_humanize_bcash[:frete], items_humanize_bcash[:tipo_integracao]) end |