Class: WalmartApIs::Feed

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/feed.rb

Overview

Feed Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(feed_id:, feed_type:, created_at:, processing_status:, marketplace_id: SKIP, processing_started_at: SKIP, processing_completed_at: SKIP, result_feed_document_id: SKIP, feed_processing_summary: SKIP, additional_properties: nil) ⇒ Feed

Returns a new instance of Feed.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/walmart_ap_is/models/feed.rb', line 81

def initialize(feed_id:, feed_type:, created_at:, processing_status:,
               marketplace_id: SKIP, processing_started_at: SKIP,
               processing_completed_at: SKIP, result_feed_document_id: SKIP,
               feed_processing_summary: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @feed_id = feed_id
  @feed_type = feed_type
  @marketplace_id = marketplace_id unless marketplace_id == SKIP
  @created_at = created_at
  @processing_started_at = processing_started_at unless processing_started_at == SKIP
  @processing_completed_at = processing_completed_at unless processing_completed_at == SKIP
  @processing_status = processing_status
  @result_feed_document_id = result_feed_document_id unless result_feed_document_id == SKIP
  @feed_processing_summary = feed_processing_summary unless feed_processing_summary == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atDateTime

Timestamp when the feed was received by the server

Returns:

  • (DateTime)


27
28
29
# File 'lib/walmart_ap_is/models/feed.rb', line 27

def created_at
  @created_at
end

#feed_idString

Unique identifier for this feed

Returns:

  • (String)


15
16
17
# File 'lib/walmart_ap_is/models/feed.rb', line 15

def feed_id
  @feed_id
end

#feed_processing_summaryFeedProcessingSummary

Record-level processing counts; present only when processingStatus is DONE



48
49
50
# File 'lib/walmart_ap_is/models/feed.rb', line 48

def feed_processing_summary
  @feed_processing_summary
end

#feed_typeString

The type of feed submitted (e.g. LISTINGS_FEED, INVENTORY_FEED)

Returns:

  • (String)


19
20
21
# File 'lib/walmart_ap_is/models/feed.rb', line 19

def feed_type
  @feed_type
end

#marketplace_idString

Marketplace the feed was submitted to (e.g. WALMART_US)

Returns:

  • (String)


23
24
25
# File 'lib/walmart_ap_is/models/feed.rb', line 23

def marketplace_id
  @marketplace_id
end

#processing_completed_atDateTime

Timestamp when feed processing finished; absent until complete

Returns:

  • (DateTime)


35
36
37
# File 'lib/walmart_ap_is/models/feed.rb', line 35

def processing_completed_at
  @processing_completed_at
end

#processing_started_atDateTime

Timestamp when feed processing began; absent until processing starts

Returns:

  • (DateTime)


31
32
33
# File 'lib/walmart_ap_is/models/feed.rb', line 31

def processing_started_at
  @processing_started_at
end

#processing_statusProcessingStatus1

Current processing status of the feed

Returns:



39
40
41
# File 'lib/walmart_ap_is/models/feed.rb', line 39

def processing_status
  @processing_status
end

#result_feed_document_idString

ID of the result document; present only when processingStatus is DONE. Use with GET /feeds/v4/feeds/feedId/document.

Returns:

  • (String)


44
45
46
# File 'lib/walmart_ap_is/models/feed.rb', line 44

def result_feed_document_id
  @result_feed_document_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/walmart_ap_is/models/feed.rb', line 101

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  feed_id = hash.key?('feedId') ? hash['feedId'] : nil
  feed_type = hash.key?('feedType') ? hash['feedType'] : nil
  created_at = if hash.key?('createdAt')
                 (DateTimeHelper.from_rfc3339(hash['createdAt']) if hash['createdAt'])
               end
  processing_status =
    hash.key?('processingStatus') ? hash['processingStatus'] : nil
  marketplace_id = hash.key?('marketplaceId') ? hash['marketplaceId'] : SKIP
  processing_started_at = if hash.key?('processingStartedAt')
                            (DateTimeHelper.from_rfc3339(hash['processingStartedAt']) if hash['processingStartedAt'])
                          else
                            SKIP
                          end
  processing_completed_at = if hash.key?('processingCompletedAt')
                              (DateTimeHelper.from_rfc3339(hash['processingCompletedAt']) if hash['processingCompletedAt'])
                            else
                              SKIP
                            end
  result_feed_document_id =
    hash.key?('resultFeedDocumentId') ? hash['resultFeedDocumentId'] : SKIP
  feed_processing_summary = FeedProcessingSummary.from_hash(hash['feedProcessingSummary']) if
    hash['feedProcessingSummary']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Feed.new(feed_id: feed_id,
           feed_type: feed_type,
           created_at: created_at,
           processing_status: processing_status,
           marketplace_id: marketplace_id,
           processing_started_at: processing_started_at,
           processing_completed_at: processing_completed_at,
           result_feed_document_id: result_feed_document_id,
           feed_processing_summary: feed_processing_summary,
           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/walmart_ap_is/models/feed.rb', line 51

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['feed_id'] = 'feedId'
  @_hash['feed_type'] = 'feedType'
  @_hash['marketplace_id'] = 'marketplaceId'
  @_hash['created_at'] = 'createdAt'
  @_hash['processing_started_at'] = 'processingStartedAt'
  @_hash['processing_completed_at'] = 'processingCompletedAt'
  @_hash['processing_status'] = 'processingStatus'
  @_hash['result_feed_document_id'] = 'resultFeedDocumentId'
  @_hash['feed_processing_summary'] = 'feedProcessingSummary'
  @_hash
end

.nullablesObject

An array for nullable fields



77
78
79
# File 'lib/walmart_ap_is/models/feed.rb', line 77

def self.nullables
  []
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
73
74
# File 'lib/walmart_ap_is/models/feed.rb', line 66

def self.optionals
  %w[
    marketplace_id
    processing_started_at
    processing_completed_at
    result_feed_document_id
    feed_processing_summary
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



172
173
174
175
176
177
178
179
180
# File 'lib/walmart_ap_is/models/feed.rb', line 172

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} feed_id: #{@feed_id.inspect}, feed_type: #{@feed_type.inspect},"\
  " marketplace_id: #{@marketplace_id.inspect}, created_at: #{@created_at.inspect},"\
  " processing_started_at: #{@processing_started_at.inspect}, processing_completed_at:"\
  " #{@processing_completed_at.inspect}, processing_status: #{@processing_status.inspect},"\
  " result_feed_document_id: #{@result_feed_document_id.inspect}, feed_processing_summary:"\
  " #{@feed_processing_summary.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



148
149
150
# File 'lib/walmart_ap_is/models/feed.rb', line 148

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_processing_completed_atObject



156
157
158
# File 'lib/walmart_ap_is/models/feed.rb', line 156

def to_custom_processing_completed_at
  DateTimeHelper.to_rfc3339(processing_completed_at)
end

#to_custom_processing_started_atObject



152
153
154
# File 'lib/walmart_ap_is/models/feed.rb', line 152

def to_custom_processing_started_at
  DateTimeHelper.to_rfc3339(processing_started_at)
end

#to_sObject

Provides a human-readable string representation of the object.



161
162
163
164
165
166
167
168
169
# File 'lib/walmart_ap_is/models/feed.rb', line 161

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} feed_id: #{@feed_id}, feed_type: #{@feed_type}, marketplace_id:"\
  " #{@marketplace_id}, created_at: #{@created_at}, processing_started_at:"\
  " #{@processing_started_at}, processing_completed_at: #{@processing_completed_at},"\
  " processing_status: #{@processing_status}, result_feed_document_id:"\
  " #{@result_feed_document_id}, feed_processing_summary: #{@feed_processing_summary},"\
  " additional_properties: #{@additional_properties}>"
end