Class: CyberSourceMergedSpec::BuyerInformation13

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

Overview

BuyerInformation13 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(company_tax_id: SKIP, currency: SKIP, date_of_birth: SKIP, personal_identification: SKIP, additional_properties: nil) ⇒ BuyerInformation13

Returns a new instance of BuyerInformation13.



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 69

def initialize(company_tax_id: SKIP, currency: SKIP, date_of_birth: SKIP,
               personal_identification: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @company_tax_id = company_tax_id unless company_tax_id == SKIP
  @currency = currency unless currency == SKIP
  @date_of_birth = date_of_birth unless date_of_birth == SKIP
  @personal_identification = personal_identification unless personal_identification == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#company_tax_idString

Company’s tax identifier. This is only used for eCheck service.

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 14

def company_tax_id
  @company_tax_id
end

#currencyString

Currency used for the order. Use the three-character I[ISO Standard Currency Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/cur rencies.pdf) For an authorization reversal (reversalInformation) or a capture (processingOptions.capture is set to true), you must use the same currency that you used in your payment authorization request.

DCC for First Data

Your local currency. For details, see the currency field description in [Dynamic Currency Conversion For First Data Using the SCMP API](http://apps.cybersource.com/library/documentation/dev_guides/DCC_Firs tData_SCMP/DCC_FirstData_SCMP_API.pdf).

For details about currency as used in partial authorizations, see

"Features for Debit Cards and Prepaid Cards" in the [Credit Card Services Using the SCMP API Guide](https://apps.cybersource.com/library/documentation/dev_guides/CC_Sv cs_SCMP_API/html/)

Returns:

  • (String)


34
35
36
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 34

def currency
  @currency
end

#date_of_birthDate

Date of birth of the customer. Format: YYYY-MM-DD

Returns:

  • (Date)


38
39
40
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 38

def date_of_birth
  @date_of_birth
end

#personal_identificationArray[PersonalIdentification9]

Date of birth of the customer. Format: YYYY-MM-DD

Returns:



42
43
44
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 42

def personal_identification
  @personal_identification
end

Class Method Details

.from_element(root) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 115

def self.from_element(root)
  company_tax_id = XmlUtilities.from_element(root, 'companyTaxID', String)
  currency = XmlUtilities.from_element(root, 'currency', String)
  date_of_birth = XmlUtilities.from_element(root, 'dateOfBirth', String)
  personal_identification = XmlUtilities.from_element_to_array(
    root, 'PersonalIdentification9', PersonalIdentification9
  )

  new(company_tax_id: company_tax_id,
      currency: currency,
      date_of_birth: date_of_birth,
      personal_identification: personal_identification,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  company_tax_id = hash.key?('companyTaxID') ? hash['companyTaxID'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  date_of_birth = hash.key?('dateOfBirth') ? hash['dateOfBirth'] : SKIP
  # Parameter is an array, so we need to iterate through it
  personal_identification = nil
  unless hash['personalIdentification'].nil?
    personal_identification = []
    hash['personalIdentification'].each do |structure|
      personal_identification << (PersonalIdentification9.from_hash(structure) if structure)
    end
  end

  personal_identification = SKIP unless hash.key?('personalIdentification')

  # 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.
  BuyerInformation13.new(company_tax_id: company_tax_id,
                         currency: currency,
                         date_of_birth: date_of_birth,
                         personal_identification: personal_identification,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['company_tax_id'] = 'companyTaxID'
  @_hash['currency'] = 'currency'
  @_hash['date_of_birth'] = 'dateOfBirth'
  @_hash['personal_identification'] = 'personalIdentification'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 55

def self.optionals
  %w[
    company_tax_id
    currency
    date_of_birth
    personal_identification
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



153
154
155
156
157
158
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 153

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} company_tax_id: #{@company_tax_id.inspect}, currency: #{@currency.inspect},"\
  " date_of_birth: #{@date_of_birth.inspect}, personal_identification:"\
  " #{@personal_identification.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



145
146
147
148
149
150
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 145

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} company_tax_id: #{@company_tax_id}, currency: #{@currency}, date_of_birth:"\
  " #{@date_of_birth}, personal_identification: #{@personal_identification},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/cyber_source_merged_spec/models/buyer_information13.rb', line 130

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

  XmlUtilities.add_as_subelement(doc, root, 'companyTaxID', company_tax_id)
  XmlUtilities.add_as_subelement(doc, root, 'currency', currency)
  XmlUtilities.add_as_subelement(doc, root, 'dateOfBirth', date_of_birth)
  XmlUtilities.add_array_as_subelement(doc, root, 'PersonalIdentification9',
                                       personal_identification)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end