Class: NewStoreApi::AddOnResource
- Defined in:
- lib/new_store_api/models/add_on_resource.rb
Overview
AddOnResource Model.
Instance Attribute Summary collapse
-
#extended_attributes ⇒ Array[ExtAttrResource]
Extended attributes.
-
#fulfillment ⇒ String
Fulfillment method, can be SHIPPING,IN_STORE_HANDOVER.
-
#id ⇒ String
Line ID.
-
#links ⇒ AddOnLinks
TODO: Write general description for this method.
-
#price ⇒ ItemPrice
Line ID.
-
#product_id ⇒ String
Item ID.
-
#quantity ⇒ Integer
Number of items in the line.
-
#source_id ⇒ String
Source identifier.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(links = nil, extended_attributes = nil, id = nil, price = nil, product_id = nil, quantity = nil, fulfillment = SKIP, source_id = SKIP) ⇒ AddOnResource
constructor
A new instance of AddOnResource.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(links = nil, extended_attributes = nil, id = nil, price = nil, product_id = nil, quantity = nil, fulfillment = SKIP, source_id = SKIP) ⇒ AddOnResource
Returns a new instance of AddOnResource.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 73 def initialize(links = nil, extended_attributes = nil, id = nil, price = nil, product_id = nil, quantity = nil, fulfillment = SKIP, source_id = SKIP) @links = links @extended_attributes = extended_attributes @fulfillment = fulfillment unless fulfillment == SKIP @id = id @price = price @product_id = product_id @quantity = quantity @source_id = source_id unless source_id == SKIP end |
Instance Attribute Details
#extended_attributes ⇒ Array[ExtAttrResource]
Extended attributes
18 19 20 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 18 def extended_attributes @extended_attributes end |
#fulfillment ⇒ String
Fulfillment method, can be SHIPPING,IN_STORE_HANDOVER
22 23 24 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 22 def fulfillment @fulfillment end |
#id ⇒ String
Line ID
26 27 28 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 26 def id @id end |
#links ⇒ AddOnLinks
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 14 def links @links end |
#price ⇒ ItemPrice
Line ID
30 31 32 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 30 def price @price end |
#product_id ⇒ String
Item ID
34 35 36 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 34 def product_id @product_id end |
#quantity ⇒ Integer
Number of items in the line
38 39 40 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 38 def quantity @quantity end |
#source_id ⇒ String
Source identifier
42 43 44 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 42 def source_id @source_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 87 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. links = AddOnLinks.from_hash(hash['_links']) if hash['_links'] # Parameter is an array, so we need to iterate through it extended_attributes = nil unless hash['extended_attributes'].nil? extended_attributes = [] hash['extended_attributes'].each do |structure| extended_attributes << (ExtAttrResource.from_hash(structure) if structure) end end extended_attributes = nil unless hash.key?('extended_attributes') id = hash.key?('id') ? hash['id'] : nil price = ItemPrice.from_hash(hash['price']) if hash['price'] product_id = hash.key?('product_id') ? hash['product_id'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil fulfillment = hash.key?('fulfillment') ? hash['fulfillment'] : SKIP source_id = hash.key?('source_id') ? hash['source_id'] : SKIP # Create object from extracted values. AddOnResource.new(links, extended_attributes, id, price, product_id, quantity, fulfillment, source_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['links'] = '_links' @_hash['extended_attributes'] = 'extended_attributes' @_hash['fulfillment'] = 'fulfillment' @_hash['id'] = 'id' @_hash['price'] = 'price' @_hash['product_id'] = 'product_id' @_hash['quantity'] = 'quantity' @_hash['source_id'] = 'source_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
67 68 69 70 71 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 67 def self.nullables %w[ extended_attributes ] end |
.optionals ⇒ Object
An array for optional fields
59 60 61 62 63 64 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 59 def self.optionals %w[ fulfillment source_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
129 130 131 132 133 134 135 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 129 def inspect class_name = self.class.name.split('::').last "<#{class_name} links: #{@links.inspect}, extended_attributes:"\ " #{@extended_attributes.inspect}, fulfillment: #{@fulfillment.inspect}, id: #{@id.inspect},"\ " price: #{@price.inspect}, product_id: #{@product_id.inspect}, quantity:"\ " #{@quantity.inspect}, source_id: #{@source_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
121 122 123 124 125 126 |
# File 'lib/new_store_api/models/add_on_resource.rb', line 121 def to_s class_name = self.class.name.split('::').last "<#{class_name} links: #{@links}, extended_attributes: #{@extended_attributes},"\ " fulfillment: #{@fulfillment}, id: #{@id}, price: #{@price}, product_id: #{@product_id},"\ " quantity: #{@quantity}, source_id: #{@source_id}>" end |