Class: WalmartApIs::FeesEstimate

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/fees_estimate.rb

Overview

The estimated fees broken down by component. Mirrors SP-API FeesEstimate.

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(time_of_fees_estimation:, total_fees_estimate:, fee_detail_list: SKIP, additional_properties: nil) ⇒ FeesEstimate

Returns a new instance of FeesEstimate.



46
47
48
49
50
51
52
53
54
55
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 46

def initialize(time_of_fees_estimation:, total_fees_estimate:,
               fee_detail_list: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @time_of_fees_estimation = time_of_fees_estimation
  @total_fees_estimate = total_fees_estimate
  @fee_detail_list = fee_detail_list unless fee_detail_list == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#fee_detail_listArray[FeeDetail]

Currency amount.

Returns:



23
24
25
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 23

def fee_detail_list
  @fee_detail_list
end

#time_of_fees_estimationDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


15
16
17
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 15

def time_of_fees_estimation
  @time_of_fees_estimation
end

#total_fees_estimateMoneyType1

Currency amount.

Returns:



19
20
21
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 19

def total_fees_estimate
  @total_fees_estimate
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  time_of_fees_estimation = if hash.key?('TimeOfFeesEstimation')
                              (DateTimeHelper.from_rfc3339(hash['TimeOfFeesEstimation']) if hash['TimeOfFeesEstimation'])
                            end
  total_fees_estimate = MoneyType1.from_hash(hash['TotalFeesEstimate']) if
    hash['TotalFeesEstimate']
  # Parameter is an array, so we need to iterate through it
  fee_detail_list = nil
  unless hash['FeeDetailList'].nil?
    fee_detail_list = []
    hash['FeeDetailList'].each do |structure|
      fee_detail_list << (FeeDetail.from_hash(structure) if structure)
    end
  end

  fee_detail_list = SKIP unless hash.key?('FeeDetailList')

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  FeesEstimate.new(time_of_fees_estimation: time_of_fees_estimation,
                   total_fees_estimate: total_fees_estimate,
                   fee_detail_list: fee_detail_list,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['time_of_fees_estimation'] = 'TimeOfFeesEstimation'
  @_hash['total_fees_estimate'] = 'TotalFeesEstimate'
  @_hash['fee_detail_list'] = 'FeeDetailList'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 35

def self.optionals
  %w[
    fee_detail_list
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



105
106
107
108
109
110
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 105

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} time_of_fees_estimation: #{@time_of_fees_estimation.inspect},"\
  " total_fees_estimate: #{@total_fees_estimate.inspect}, fee_detail_list:"\
  " #{@fee_detail_list.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_time_of_fees_estimationObject



92
93
94
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 92

def to_custom_time_of_fees_estimation
  DateTimeHelper.to_rfc3339(time_of_fees_estimation)
end

#to_sObject

Provides a human-readable string representation of the object.



97
98
99
100
101
102
# File 'lib/walmart_ap_is/models/fees_estimate.rb', line 97

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} time_of_fees_estimation: #{@time_of_fees_estimation}, total_fees_estimate:"\
  " #{@total_fees_estimate}, fee_detail_list: #{@fee_detail_list}, additional_properties:"\
  " #{@additional_properties}>"
end