Class: MuffinMan::RequestHelpers::OutboundFulfillment::Item
- Defined in:
- lib/muffin_man/request_helpers/outbound_fulfillment/item.rb
Constant Summary collapse
- OPTIONAL_ITEM_PARAMS =
%w[ perUnitDeclaredValue giftMessage displayableComment fulfillmentNetworkSku perUnitDeclaredValue perUnitPrice perUnitTax ].freeze
Instance Attribute Summary collapse
-
#optional_params ⇒ Object
Returns the value of attribute optional_params.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#seller_fulfillment_order_item_id ⇒ Object
Returns the value of attribute seller_fulfillment_order_item_id.
-
#seller_sku ⇒ Object
Returns the value of attribute seller_sku.
Instance Method Summary collapse
-
#errors ⇒ Object
Show invalid properties with the reasons.
-
#initialize(attributes = {}) ⇒ Item
constructor
Initializes the object.
- #to_camelize ⇒ Object
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from Base
Constructor Details
#initialize(attributes = {}) ⇒ Item
Initializes the object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 21 def initialize(attributes = {}) super return unless attributes.is_a?(Hash) attributes = attributes.with_indifferent_access @seller_sku = attributes["seller_sku"] if attributes.key?("seller_sku") if attributes.key?("seller_fulfillment_order_item_id") @seller_fulfillment_order_item_id = attributes["seller_fulfillment_order_item_id"] end @quantity = attributes["quantity"] if attributes.key?("quantity") @optional_params = attributes.slice(*OPTIONAL_ITEM_PARAMS) end |
Instance Attribute Details
#optional_params ⇒ Object
Returns the value of attribute optional_params.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 7 def optional_params @optional_params end |
#quantity ⇒ Object
Returns the value of attribute quantity.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 7 def quantity @quantity end |
#seller_fulfillment_order_item_id ⇒ Object
Returns the value of attribute seller_fulfillment_order_item_id.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 7 def seller_fulfillment_order_item_id @seller_fulfillment_order_item_id end |
#seller_sku ⇒ Object
Returns the value of attribute seller_sku.
7 8 9 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 7 def seller_sku @seller_sku end |
Instance Method Details
#errors ⇒ Object
Show invalid properties with the reasons.
50 51 52 53 54 55 56 57 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 50 def errors errors = [] errors.push('"seller_sku" cannot be nil.') if seller_sku.blank? errors.push('"seller_fulfillment_order_item_id" cannot be nil.') if seller_fulfillment_order_item_id.blank? errors.push('"quantity" cannot be nil.') if quantity.blank? errors end |
#to_camelize ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 59 def to_camelize { "sellerSku" => seller_sku, "sellerFulfillmentOrderItemId" => seller_fulfillment_order_item_id, "quantity" => quantity }.merge!(optional_params.slice(*OPTIONAL_ITEM_PARAMS)) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
40 41 42 43 44 45 46 |
# File 'lib/muffin_man/request_helpers/outbound_fulfillment/item.rb', line 40 def valid? return false if seller_sku.blank? return false if seller_fulfillment_order_item_id.blank? return false if quantity.blank? true end |