Class: Peddler::Feeds::Feed
- Inherits:
-
Object
- Object
- Peddler::Feeds::Feed
- Defined in:
- lib/peddler/feeds.rb
Overview
This is the base class.
Direct Known Subclasses
OrderCancellation::Batch, OrderFulfillment::Batch, Reports::UnshippedOrdersReport
Constant Summary collapse
- MAPPED_PARAMS =
{ 'UploadStatus' => 'status', 'UploadType' => 'type', 'UploadId' => 'id', 'SubmittedDate' => 'submitted_at', 'StartedProcessingDate' => 'started_processing_at', 'CompletedProcessingDate' => 'completed_processing_at', 'CompletedProcesssingDate' => 'completed_processing_at', 'MessagesProcessed' => 'messages_processed', 'MessagesSuccessful' => 'messages_successful', 'MessagesWithErrors' => 'messages_with_errors', 'MessagesWithWarnings' => 'messages_with_warnings'}
Instance Attribute Summary collapse
-
#batch ⇒ Object
Returns the value of attribute batch.
-
#completed_processing_at ⇒ Object
Returns the value of attribute completed_processing_at.
-
#download ⇒ Object
Returns the value of attribute download.
-
#file_content ⇒ Object
Returns content of the upload file.
-
#id ⇒ Object
Returns the value of attribute id.
-
#messages_processed ⇒ Object
Returns the value of attribute messages_processed.
-
#messages_successful ⇒ Object
Returns the value of attribute messages_successful.
-
#messages_with_errors ⇒ Object
Returns the value of attribute messages_with_errors.
-
#messages_with_warnings ⇒ Object
Returns the value of attribute messages_with_warnings.
-
#started_processing_at ⇒ Object
Returns the value of attribute started_processing_at.
-
#status ⇒ Object
Returns the value of attribute status.
-
#submitted_at ⇒ Object
Returns the value of attribute submitted_at.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#<<(item) ⇒ Object
Adds an item to the batch.
-
#initialize(transport) ⇒ Feed
constructor
A new instance of Feed.
-
#status! ⇒ Object
Returns status and will also refresh if not already “done.”.
-
#upload ⇒ Object
Uploads batch.
Constructor Details
#initialize(transport) ⇒ Feed
Returns a new instance of Feed.
58 59 60 61 |
# File 'lib/peddler/feeds.rb', line 58 def initialize(transport) @transport = transport @batch = [] end |
Instance Attribute Details
#batch ⇒ Object
Returns the value of attribute batch.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def batch @batch end |
#completed_processing_at ⇒ Object
Returns the value of attribute completed_processing_at.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def completed_processing_at @completed_processing_at end |
#download ⇒ Object
Returns the value of attribute download.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def download @download end |
#file_content ⇒ Object
Returns content of the upload file.
64 65 66 67 68 69 |
# File 'lib/peddler/feeds.rb', line 64 def file_content return @file_content if @file_content out = @file_header @batch.each{ |item| out << item.to_s } @file_content = out end |
#id ⇒ Object
Returns the value of attribute id.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def id @id end |
#messages_processed ⇒ Object
Returns the value of attribute messages_processed.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def @messages_processed end |
#messages_successful ⇒ Object
Returns the value of attribute messages_successful.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def @messages_successful end |
#messages_with_errors ⇒ Object
Returns the value of attribute messages_with_errors.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def @messages_with_errors end |
#messages_with_warnings ⇒ Object
Returns the value of attribute messages_with_warnings.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def @messages_with_warnings end |
#started_processing_at ⇒ Object
Returns the value of attribute started_processing_at.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def started_processing_at @started_processing_at end |
#status ⇒ Object
Returns the value of attribute status.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def status @status end |
#submitted_at ⇒ Object
Returns the value of attribute submitted_at.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def submitted_at @submitted_at end |
#type ⇒ Object
Returns the value of attribute type.
43 44 45 |
# File 'lib/peddler/feeds.rb', line 43 def type @type end |
Instance Method Details
#<<(item) ⇒ Object
Adds an item to the batch.
92 93 94 |
# File 'lib/peddler/feeds.rb', line 92 def <<(item) @batch << item end |
#status! ⇒ Object
Returns status and will also refresh if not already “done.”
72 73 74 75 76 |
# File 'lib/peddler/feeds.rb', line 72 def status! return @status if @status.nil? || @status =~ /_DONE_/ refresh_status @status end |
#upload ⇒ Object
Uploads batch.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/peddler/feeds.rb', line 79 def upload raise PeddlerError.new('Batch already uploaded') unless @id.nil? @transport.modernize_request @transport.query_params.merge!({ 'Action' => 'upload', 'uploadType' => @type}) @transport.body = file_content res = @transport.execute_request process_response(res) @status end |