Class: FdxV660Api::RewardBalanceEntity

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fdx_v660_api/models/reward_balance_entity.rb

Overview

Reward program balance

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(name: SKIP, type: SKIP, balance: SKIP, accrued_ytd: SKIP, redeemed_ytd: SKIP, qualifying: false, fi_attributes: SKIP, additional_properties: nil) ⇒ RewardBalanceEntity

Returns a new instance of RewardBalanceEntity.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 71

def initialize(name: SKIP, type: SKIP, balance: SKIP, accrued_ytd: SKIP,
               redeemed_ytd: SKIP, qualifying: false, fi_attributes: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name unless name == SKIP
  @type = type unless type == SKIP
  @balance = balance unless balance == SKIP
  @accrued_ytd = accrued_ytd unless accrued_ytd == SKIP
  @redeemed_ytd = redeemed_ytd unless redeemed_ytd == SKIP
  @qualifying = qualifying unless qualifying == SKIP
  @fi_attributes = fi_attributes unless fi_attributes == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#accrued_ytdFloat

Total units accrued in the current program year at time of download

Returns:

  • (Float)


26
27
28
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 26

def accrued_ytd
  @accrued_ytd
end

#balanceFloat

Total units available for redemption at time of download

Returns:

  • (Float)


22
23
24
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 22

def balance
  @balance
end

#fi_attributesArray[FiAttributeEntity]

Array of FI-specific attributes

Returns:



38
39
40
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 38

def fi_attributes
  @fi_attributes
end

#nameString

Name used to denominate the balance

Returns:

  • (String)


14
15
16
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 14

def name
  @name
end

#qualifyingTrueClass | FalseClass

Balance used for qualifying purposes

Returns:

  • (TrueClass | FalseClass)


34
35
36
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 34

def qualifying
  @qualifying
end

#redeemed_ytdFloat

Total units redeemed in the current program year at time of download

Returns:

  • (Float)


30
31
32
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 30

def redeemed_ytd
  @redeemed_ytd
end

#typeRewardType1

The type of the reward balance - CASHBACK, MILES, POINTS

Returns:



18
19
20
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 18

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
119
120
121
122
123
124
125
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  balance = hash.key?('balance') ? hash['balance'] : SKIP
  accrued_ytd = hash.key?('accruedYtd') ? hash['accruedYtd'] : SKIP
  redeemed_ytd = hash.key?('redeemedYtd') ? hash['redeemedYtd'] : SKIP
  qualifying = hash['qualifying'] ||= false
  # Parameter is an array, so we need to iterate through it
  fi_attributes = nil
  unless hash['fiAttributes'].nil?
    fi_attributes = []
    hash['fiAttributes'].each do |structure|
      fi_attributes << (FiAttributeEntity.from_hash(structure) if structure)
    end
  end

  fi_attributes = SKIP unless hash.key?('fiAttributes')

  # 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.
  RewardBalanceEntity.new(name: name,
                          type: type,
                          balance: balance,
                          accrued_ytd: accrued_ytd,
                          redeemed_ytd: redeemed_ytd,
                          qualifying: qualifying,
                          fi_attributes: fi_attributes,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['type'] = 'type'
  @_hash['balance'] = 'balance'
  @_hash['accrued_ytd'] = 'accruedYtd'
  @_hash['redeemed_ytd'] = 'redeemedYtd'
  @_hash['qualifying'] = 'qualifying'
  @_hash['fi_attributes'] = 'fiAttributes'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 54

def self.optionals
  %w[
    name
    type
    balance
    accrued_ytd
    redeemed_ytd
    qualifying
    fi_attributes
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



129
130
131
132
133
134
135
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 129

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



146
147
148
149
150
151
152
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 146

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, type: #{@type.inspect}, balance:"\
  " #{@balance.inspect}, accrued_ytd: #{@accrued_ytd.inspect}, redeemed_ytd:"\
  " #{@redeemed_ytd.inspect}, qualifying: #{@qualifying.inspect}, fi_attributes:"\
  " #{@fi_attributes.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



138
139
140
141
142
143
# File 'lib/fdx_v660_api/models/reward_balance_entity.rb', line 138

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, type: #{@type}, balance: #{@balance}, accrued_ytd:"\
  " #{@accrued_ytd}, redeemed_ytd: #{@redeemed_ytd}, qualifying: #{@qualifying},"\
  " fi_attributes: #{@fi_attributes}, additional_properties: #{@additional_properties}>"
end