Class: CyberSourceMergedSpec::InvoiceHistory

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/invoice_history.rb

Overview

InvoiceHistory 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(event: SKIP, date: SKIP, transaction_details: SKIP, additional_properties: nil) ⇒ InvoiceHistory

Returns a new instance of InvoiceHistory.



61
62
63
64
65
66
67
68
69
70
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 61

def initialize(event: SKIP, date: SKIP, transaction_details: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @event = event unless event == SKIP
  @date = date unless date == SKIP
  @transaction_details = transaction_details unless transaction_details == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#dateDateTime

The date and time when the invoice event was triggered in ISO 8601 format. Format: YYYY-MM-DDThh:mm:ssZ

Returns:

  • (DateTime)


32
33
34
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 32

def date
  @date
end

#eventString

The event triggered for the invoice. Possible values:

  • UNKNOWN
  • DRAFT
  • CREATE
  • UPDATE
  • SEND
  • RESEND
  • REMINDER
  • PAYMENT
  • CANCEL
  • PENDING
  • REJECTED

Returns:

  • (String)


27
28
29
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 27

def event
  @event
end

#transaction_detailsTransactionDetails

These details are only returned when the invoice event is payment.

Returns:



36
37
38
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 36

def transaction_details
  @transaction_details
end

Class Method Details

.from_element(root) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 104

def self.from_element(root)
  event = XmlUtilities.from_element(root, 'event', String)
  date = XmlUtilities.from_element(root, 'date', String,
                                   datetime_format: 'rfc3339')
  transaction_details = XmlUtilities.from_element(root,
                                                  'TransactionDetails',
                                                  TransactionDetails)

  new(event: event,
      date: date,
      transaction_details: transaction_details,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  event = hash.key?('event') ? hash['event'] : SKIP
  date = if hash.key?('date')
           (DateTimeHelper.from_rfc3339(hash['date']) if hash['date'])
         else
           SKIP
         end
  transaction_details = TransactionDetails.from_hash(hash['transactionDetails']) if
    hash['transactionDetails']

  # 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.
  InvoiceHistory.new(event: event,
                     date: date,
                     transaction_details: transaction_details,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['event'] = 'event'
  @_hash['date'] = 'date'
  @_hash['transaction_details'] = 'transactionDetails'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



48
49
50
51
52
53
54
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 48

def self.optionals
  %w[
    event
    date
    transaction_details
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



140
141
142
143
144
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 140

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

#to_custom_dateObject



100
101
102
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 100

def to_custom_date
  DateTimeHelper.to_rfc3339(date)
end

#to_sObject

Provides a human-readable string representation of the object.



133
134
135
136
137
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 133

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

#to_xml_element(doc, root_name) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/cyber_source_merged_spec/models/invoice_history.rb', line 118

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'event', event)
  XmlUtilities.add_as_subelement(doc, root, 'date', date,
                                 datetime_format: 'rfc3339')
  XmlUtilities.add_as_subelement(doc, root, 'TransactionDetails',
                                 transaction_details)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end