Class: NewStoreApi::FulfillmentOption

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

Overview

Service-level fulfillment option (e.g. in-store handover). The source spec models this as a oneOf; this MVP supports only the service-level variant and omits the shipping (shipping_offer_token) one.

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(price = nil, service_level_identifier = nil, tax = nil) ⇒ FulfillmentOption

Returns a new instance of FulfillmentOption.



47
48
49
50
51
# File 'lib/new_store_api/models/fulfillment_option.rb', line 47

def initialize(price = nil, service_level_identifier = nil, tax = nil)
  @price = price
  @service_level_identifier = service_level_identifier
  @tax = tax
end

Instance Attribute Details

#priceInteger

The price of the fulfillment option before discounts, in the currency's minor unit. It might include taxes depending on the pricing method.

Returns:

  • (Integer)


17
18
19
# File 'lib/new_store_api/models/fulfillment_option.rb', line 17

def price
  @price
end

#service_level_identifierString

Service level identifier of the fulfillment option. Set it to IN_STORE_HANDOVER in case of an in-store purchase order.

Returns:

  • (String)


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

def service_level_identifier
  @service_level_identifier
end

#taxInteger

The tax applied to the fulfillment option, in the currency's minor unit.

Returns:

  • (Integer)


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

def tax
  @tax
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_store_api/models/fulfillment_option.rb', line 54

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  price = hash.key?('price') ? hash['price'] : nil
  service_level_identifier =
    hash.key?('service_level_identifier') ? hash['service_level_identifier'] : nil
  tax = hash.key?('tax') ? hash['tax'] : nil

  # Create object from extracted values.
  FulfillmentOption.new(price,
                        service_level_identifier,
                        tax)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
# File 'lib/new_store_api/models/fulfillment_option.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['price'] = 'price'
  @_hash['service_level_identifier'] = 'service_level_identifier'
  @_hash['tax'] = 'tax'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/new_store_api/models/fulfillment_option.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
# File 'lib/new_store_api/models/fulfillment_option.rb', line 38

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



77
78
79
80
81
# File 'lib/new_store_api/models/fulfillment_option.rb', line 77

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

#to_sObject

Provides a human-readable string representation of the object.



70
71
72
73
74
# File 'lib/new_store_api/models/fulfillment_option.rb', line 70

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