Class: CyberSourceMergedSpec::BuyerInformation38

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

Overview

BuyerInformation38 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(mobile_phone:, merchant_customer_id: SKIP, personal_identification: SKIP, work_phone: SKIP, additional_properties: nil) ⇒ BuyerInformation38

Returns a new instance of BuyerInformation38.



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 74

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

  @merchant_customer_id = merchant_customer_id unless merchant_customer_id == SKIP
  @personal_identification = personal_identification unless personal_identification == SKIP
  @mobile_phone = mobile_phone
  @work_phone = work_phone unless work_phone == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#merchant_customer_idString

Your identifier for the customer. When a subscription or customer profile is being created, the maximum length for this field for most processors is 30. Otherwise, the maximum length is 100.

Comercio Latino

For recurring payments in Mexico, the value is the customer’s contract number. Note Before you request the authorization, you must inform the issuer of the customer contract numbers that will be used for recurring transactions.

Worldpay VAP

For a follow-on credit with Worldpay VAP, CyberSource checks the following locations, in the order given, for a customer account ID value and uses the first value it finds:

  1. customer_account_id value in the follow-on credit request
  2. Customer account ID value that was used for the capture that is being credited
  3. Customer account ID value that was used for the original authorization If a customer account ID value cannot be found in any of these locations, then no value is used.

Returns:

  • (String)


33
34
35
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 33

def merchant_customer_id
  @merchant_customer_id
end

#mobile_phoneInteger

Cardholder’s mobile phone number. Important Required for Visa Secure transactions in Brazil. Do not use this request field for any other types of transactions.

Returns:

  • (Integer)


44
45
46
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 44

def mobile_phone
  @mobile_phone
end

#personal_identificationArray[PersonalIdentification]

This array contains detailed information about the buyer's form of persoanl identification.

Returns:



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

def personal_identification
  @personal_identification
end

#work_phoneInteger

Cardholder's work phone number.

Returns:

  • (Integer)


48
49
50
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 48

def work_phone
  @work_phone
end

Class Method Details

.from_element(root) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 122

def self.from_element(root)
  mobile_phone = XmlUtilities.from_element(root, 'mobilePhone', Integer)
  merchant_customer_id = XmlUtilities.from_element(root,
                                                   'merchantCustomerId',
                                                   String)
  personal_identification = XmlUtilities.from_element_to_array(
    root, 'PersonalIdentification', PersonalIdentification
  )
  work_phone = XmlUtilities.from_element(root, 'workPhone', Integer)

  new(mobile_phone: mobile_phone,
      merchant_customer_id: merchant_customer_id,
      personal_identification: personal_identification,
      work_phone: work_phone,
      additional_properties: additional_properties)
end

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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mobile_phone = hash.key?('mobilePhone') ? hash['mobilePhone'] : nil
  merchant_customer_id =
    hash.key?('merchantCustomerId') ? hash['merchantCustomerId'] : 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 << (PersonalIdentification.from_hash(structure) if structure)
    end
  end

  personal_identification = SKIP unless hash.key?('personalIdentification')
  work_phone = hash.key?('workPhone') ? hash['workPhone'] : 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.
  BuyerInformation38.new(mobile_phone: mobile_phone,
                         merchant_customer_id: merchant_customer_id,
                         personal_identification: personal_identification,
                         work_phone: work_phone,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



51
52
53
54
55
56
57
58
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 51

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['merchant_customer_id'] = 'merchantCustomerId'
  @_hash['personal_identification'] = 'personalIdentification'
  @_hash['mobile_phone'] = 'mobilePhone'
  @_hash['work_phone'] = 'workPhone'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 61

def self.optionals
  %w[
    merchant_customer_id
    personal_identification
    work_phone
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



163
164
165
166
167
168
169
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 163

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

#to_sObject

Provides a human-readable string representation of the object.



155
156
157
158
159
160
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 155

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

#to_xml_element(doc, root_name) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/cyber_source_merged_spec/models/buyer_information38.rb', line 139

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

  XmlUtilities.add_as_subelement(doc, root, 'mobilePhone', mobile_phone)
  XmlUtilities.add_as_subelement(doc, root, 'merchantCustomerId',
                                 merchant_customer_id)
  XmlUtilities.add_array_as_subelement(doc, root, 'PersonalIdentification',
                                       personal_identification)
  XmlUtilities.add_as_subelement(doc, root, 'workPhone', work_phone)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end