Class: MastercardMerchantCheckout::PaymentData
- Inherits:
-
Object
- Object
- MastercardMerchantCheckout::PaymentData
- Includes:
- ROXML
- Defined in:
- lib/mastercard_merchant_checkout/models/payment_data.rb
Overview
This class contains various methods to get paymentData response parameters returned by PaymentDataApi.
Instance Attribute Summary collapse
-
#authentication_options ⇒ AuthenticationOptions
The authentication information.
-
#card ⇒ Card
The payment card details.
-
#pairing_id ⇒ String
The new pairingId.
-
#personal_info ⇒ PersonalInfo
The recipient’s personal information.
-
#shipping_address ⇒ Address
The shipping address details.
-
#tokenization ⇒ Tokenization
The tokenized card information.
-
#wallet_id ⇒ String
The unique identifier for a wallet that helps identify the origin wallet for the transaction.
-
#wallet_name ⇒ String
The wallet name.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Check equality by comparing each attribute.
- #_deserialize(type, value) ⇒ Object
-
#_to_hash(value) ⇒ Object
Method to output non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
build the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Object
Calculate hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ PaymentData
constructor
A new instance of PaymentData.
-
#to_body ⇒ Object
to_body is an alias to to_body (backward compatibility)).
-
#to_hash(include_root = false) ⇒ Object
return the object in the form of hash.
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ PaymentData
Returns a new instance of PaymentData.
65 66 67 68 69 70 71 72 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 99 100 101 102 103 104 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 65 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} if attributes.has_key?(:card) self.card = attributes[:card] end if attributes.has_key?(:shipping_address) self.shipping_address = attributes[:shipping_address] end if attributes.has_key?(:personal_info) self.personal_info = attributes[:personal_info] end if attributes.has_key?(:tokenization) self.tokenization = attributes[:tokenization] end if attributes.has_key?(:wallet_id) self.wallet_id = attributes[:wallet_id] end if attributes.has_key?(:wallet_name) self.wallet_name = attributes[:wallet_name] end if attributes.has_key?(:authentication_options) self. = attributes[:authentication_options] end if attributes.has_key?(:pairing_id) self.pairing_id = attributes[:pairing_id] end end |
Instance Attribute Details
#authentication_options ⇒ AuthenticationOptions
Returns the authentication information.
43 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 43 xml_accessor :authentication_options, :from =>"authenticationOptions",:as => AuthenticationOptions |
#card ⇒ Card
Returns the payment card details.
19 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 19 xml_accessor :card, :from =>"card",:as => Card |
#pairing_id ⇒ String
Returns the new pairingId.
47 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 47 xml_accessor :pairing_id, :from =>"pairingId" |
#personal_info ⇒ PersonalInfo
Returns the recipient’s personal information.
27 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 27 xml_accessor :personal_info, :from =>"personalInfo",:as => PersonalInfo |
#shipping_address ⇒ Address
Returns the shipping address details.
23 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 23 xml_accessor :shipping_address, :from =>"shippingAddress",:as => Address |
#tokenization ⇒ Tokenization
Returns the tokenized card information.
31 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 31 xml_accessor :tokenization, :from =>"tokenization",:as => Tokenization |
#wallet_id ⇒ String
Returns the unique identifier for a wallet that helps identify the origin wallet for the transaction.
35 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 35 xml_accessor :wallet_id, :from =>"walletId" |
#wallet_name ⇒ String
Returns the wallet name.
39 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 39 xml_accessor :wallet_name, :from =>"walletName" |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 51 def self.attribute_map { :card => :card , :shipping_address => :shippingAddress , :personal_info => :personalInfo , :tokenization => :tokenization , :wallet_id => :walletId , :wallet_name => :walletName , :authentication_options => :authenticationOptions , :pairing_id => :pairingId } end |
Instance Method Details
#==(o) ⇒ Object
Check equality by comparing each attribute.
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 110 def ==(o) return true if self.equal?(o) self.class == o.class && card == o.card && shipping_address == o.shipping_address && personal_info == o.personal_info && tokenization == o.tokenization && wallet_id == o.wallet_id && wallet_name == o.wallet_name && == o. && pairing_id == o.pairing_id end |
#_deserialize(type, value) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 153 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model _model = MastercardMerchantCheckout.const_get(type).new _model.build_from_hash(value) end end |
#_to_hash(value) ⇒ Object
Method to output non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 212 def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
build the object from hash
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 134 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.datatype_map.each_pair do |key, type| if type =~ /^Array<(.*)>/i if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) else #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) else # data not found in attributes(hash), not an issue as the data can be optional end end self end |
#eql?(o) ⇒ Boolean
124 125 126 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 124 def eql?(o) self == o end |
#hash ⇒ Object
Calculate hash code according to all attributes.
129 130 131 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 129 def hash [card, shipping_address, personal_info, tokenization, wallet_id, wallet_name, , pairing_id].hash end |
#to_body ⇒ Object
to_body is an alias to to_body (backward compatibility))
193 194 195 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 193 def to_body to_hash end |
#to_hash(include_root = false) ⇒ Object
return the object in the form of hash
198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 198 def to_hash(include_root = false) attributes_hash = {} hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end attributes_hash = include_root ? { "PaymentData" => hash } : hash return attributes_hash end |
#to_s ⇒ Object
188 189 190 |
# File 'lib/mastercard_merchant_checkout/models/payment_data.rb', line 188 def to_s to_hash.to_s end |