Class: MuffinMan::RequestHelpers::OutboundFulfillment::FulfillmentPreviewRequest
- Inherits:
-
Base
- Object
- Base
- MuffinMan::RequestHelpers::OutboundFulfillment::FulfillmentPreviewRequest
- Defined in:
- lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb
Constant Summary collapse
- OPTIONAL_FULFILLMENT_PREVIEW_PARAMS =
%w[ marketplaceId shippingSpeedCategories includeCODFulfillmentPreview includeDeliveryWindows featureConstraints ].freeze
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#items ⇒ Object
Returns the value of attribute items.
-
#optional_params ⇒ Object
Returns the value of attribute optional_params.
Instance Method Summary collapse
-
#errors ⇒ Object
Show invalid properties with the reasons.
-
#initialize(address, items, optional_params = {}) ⇒ FulfillmentPreviewRequest
constructor
Initializes the object @param items in the form of list of items objects.
-
#to_camelize ⇒ Object
Format request object in sp-api request format.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid rubocop:disable Metrics/CyclomaticComplexity.
Methods inherited from Base
Constructor Details
#initialize(address, items, optional_params = {}) ⇒ FulfillmentPreviewRequest
Initializes the object @param items in the form of list of items objects
21 22 23 24 25 26 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 21 def initialize(address, items, optional_params = {}) super @address = address @items = items @optional_params = optional_params end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 7 def address @address end |
#items ⇒ Object
Returns the value of attribute items.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 7 def items @items end |
#optional_params ⇒ Object
Returns the value of attribute optional_params.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 7 def optional_params @optional_params end |
Instance Method Details
#errors ⇒ Object
Show invalid properties with the reasons.
42 43 44 45 46 47 48 49 50 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 42 def errors errors = [] errors.push('"address" cannot be nil.') if address.blank? errors.push('"items" cannot be nil.') if items.blank? errors.push("invalid value for \"address\",#{address.errors}") if address.present? && !address.valid? errors.push('invalid value for "items"') if items.present? && items.map(&:valid?).include?(false) errors end |
#to_camelize ⇒ Object
Format request object in sp-api request format
55 56 57 58 59 60 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 55 def to_camelize { "address" => address.to_camelize, "items" => items.map(&:to_camelize) }.merge!(optional_params.slice(*OPTIONAL_FULFILLMENT_PREVIEW_PARAMS)) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid rubocop:disable Metrics/CyclomaticComplexity
31 32 33 34 35 36 37 38 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/fulfillment_preview_request.rb', line 31 def valid? return false if address.blank? || !address.is_a?(MuffinMan::RequestHelpers::OutboundFulfillment::Address) return false if items.blank? || !items.is_a?(Array) return false if !address.valid? || items.map(&:valid?).include?(false) true end |