Class: Peddler::Refunds::Batch
- Inherits:
-
Object
- Object
- Peddler::Refunds::Batch
- Defined in:
- lib/peddler/refunds.rb
Overview
This is a refund batch.
Instance Attribute Summary collapse
-
#batch ⇒ Object
Returns the value of attribute batch.
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #file_content ⇒ Object
-
#initialize(transport) ⇒ Batch
constructor
A new instance of Batch.
- #upload ⇒ Object
Constructor Details
#initialize(transport) ⇒ Batch
Returns a new instance of Batch.
7 8 9 10 |
# File 'lib/peddler/refunds.rb', line 7 def initialize(transport) @transport = transport @batch = [] end |
Instance Attribute Details
#batch ⇒ Object
Returns the value of attribute batch.
5 6 7 |
# File 'lib/peddler/refunds.rb', line 5 def batch @batch end |
Instance Method Details
#<<(item) ⇒ Object
17 18 19 |
# File 'lib/peddler/refunds.rb', line 17 def <<(item) @batch << item end |
#file_content ⇒ Object
12 13 14 15 |
# File 'lib/peddler/refunds.rb', line 12 def file_content out = "order-id\tpayments-transaction-id\trefund-amount\treason\tmessage\r\n" @file_content = @batch.inject(out){ |memo, item| memo << item.to_s } end |
#upload ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/peddler/refunds.rb', line 21 def upload raise PeddlerError.new("Batch already uploaded") if @completed @transport.legacize_request @transport.path << "catalog-upload/batch-refund" @transport.body = file_content res = @transport.execute_request @completed = true if res == "<Success>SUCCESS</Success>" end |