Class: NewStoreApi::FulfillmentAssignment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/fulfillment_assignment.rb

Overview

FulfillmentAssignment 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(currency = nil, line_items = nil, location_id = nil, price = nil, tax_code = SKIP) ⇒ FulfillmentAssignment

Returns a new instance of FulfillmentAssignment.



57
58
59
60
61
62
63
64
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 57

def initialize(currency = nil, line_items = nil, location_id = nil,
               price = nil, tax_code = SKIP)
  @currency = currency
  @line_items = line_items
  @location_id = location_id
  @price = price
  @tax_code = tax_code unless tax_code == SKIP
end

Instance Attribute Details

#currencyCurrencyEnum

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 14

def currency
  @currency
end

#line_itemsArray[LineItem]

Which products can be fulfilled from this location.

Returns:



18
19
20
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 18

def line_items
  @line_items
end

#location_idString

The Location ID that is going to fulfill the items

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 22

def location_id
  @location_id
end

#priceFloat

The Location ID that is going to fulfill the items

Returns:

  • (Float)


26
27
28
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 26

def price
  @price
end

#tax_codeString

The Location ID that is going to fulfill the items

Returns:

  • (String)


30
31
32
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 30

def tax_code
  @tax_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  currency = hash.key?('currency') ? hash['currency'] : nil
  # Parameter is an array, so we need to iterate through it
  line_items = nil
  unless hash['line_items'].nil?
    line_items = []
    hash['line_items'].each do |structure|
      line_items << (LineItem.from_hash(structure) if structure)
    end
  end

  line_items = nil unless hash.key?('line_items')
  location_id = hash.key?('location_id') ? hash['location_id'] : nil
  price = hash.key?('price') ? hash['price'] : nil
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP

  # Create object from extracted values.
  FulfillmentAssignment.new(currency,
                            line_items,
                            location_id,
                            price,
                            tax_code)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['currency'] = 'currency'
  @_hash['line_items'] = 'line_items'
  @_hash['location_id'] = 'location_id'
  @_hash['price'] = 'price'
  @_hash['tax_code'] = 'tax_code'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
54
55
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 51

def self.nullables
  %w[
    tax_code
  ]
end

.optionalsObject

An array for optional fields



44
45
46
47
48
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 44

def self.optionals
  %w[
    tax_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
107
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 102

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency.inspect}, line_items: #{@line_items.inspect},"\
  " location_id: #{@location_id.inspect}, price: #{@price.inspect}, tax_code:"\
  " #{@tax_code.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
# File 'lib/new_store_api/models/fulfillment_assignment.rb', line 95

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency}, line_items: #{@line_items}, location_id:"\
  " #{@location_id}, price: #{@price}, tax_code: #{@tax_code}>"
end