Class: FdxV660Api::StatementEntity

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

Overview

An account statement

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(account_id: SKIP, statement_id: SKIP, statement_date: SKIP, description: SKIP, links: SKIP, status: SKIP, additional_properties: nil) ⇒ StatementEntity

Returns a new instance of StatementEntity.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 65

def initialize(account_id: SKIP, statement_id: SKIP, statement_date: SKIP,
               description: SKIP, links: SKIP, status: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_id =  unless  == SKIP
  @statement_id = statement_id unless statement_id == SKIP
  @statement_date = statement_date unless statement_date == SKIP
  @description = description unless description == SKIP
  @links = links unless links == SKIP
  @status = status unless status == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idString

Corresponds to accountId in Account entity

Returns:

  • (String)


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

def 
  @account_id
end

#descriptionString

Description of statement

Returns:

  • (String)


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

def description
  @description
end

The links to retrieve this account statement, or to invoke other APIs

Returns:



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

def links
  @links
end

#statement_dateDate

Date of the statement

Returns:

  • (Date)


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

def statement_date
  @statement_date
end

#statement_idString

Long-term persistent identity of the statement

Returns:

  • (String)


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

def statement_id
  @statement_id
end

#statusDocumentStatus2

Availability status of statement

Returns:



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

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
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
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountId') ? hash['accountId'] : SKIP
  statement_id = hash.key?('statementId') ? hash['statementId'] : SKIP
  statement_date = hash.key?('statementDate') ? hash['statementDate'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (HateoasLink.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')
  status = hash.key?('status') ? hash['status'] : SKIP

  # 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.
  StatementEntity.new(account_id: ,
                      statement_id: statement_id,
                      statement_date: statement_date,
                      description: description,
                      links: links,
                      status: status,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_id'] = 'accountId'
  @_hash['statement_id'] = 'statementId'
  @_hash['statement_date'] = 'statementDate'
  @_hash['description'] = 'description'
  @_hash['links'] = 'links'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 49

def self.optionals
  %w[
    account_id
    statement_id
    statement_date
    description
    links
    status
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



127
128
129
130
131
132
133
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 127

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id.inspect}, statement_id: #{@statement_id.inspect},"\
  " statement_date: #{@statement_date.inspect}, description: #{@description.inspect}, links:"\
  " #{@links.inspect}, status: #{@status.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



119
120
121
122
123
124
# File 'lib/fdx_v660_api/models/statement_entity.rb', line 119

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id}, statement_id: #{@statement_id}, statement_date:"\
  " #{@statement_date}, description: #{@description}, links: #{@links}, status: #{@status},"\
  " additional_properties: #{@additional_properties}>"
end