Class: MastercardMerchantCheckout::ExpressCheckoutRequest
- Inherits:
-
Object
- Object
- MastercardMerchantCheckout::ExpressCheckoutRequest
- Includes:
- ROXML
- Defined in:
- lib/mastercard_merchant_checkout/models/express_checkout_request.rb
Overview
This class contains various methods to set express checkout request parameters required for ExpressCheckoutApi.
Instance Attribute Summary collapse
-
#amount ⇒ Float
The transaction amount.
-
#card_id ⇒ String
The card identifier from PreCheckoutApi response.
-
#checkout_id ⇒ String
The merchant Checkout identifier.
-
#currency ⇒ String
The ISO-4217 code for currency of the transaction.
-
#digital_goods ⇒ BOOLEAN
The flag to indicate digital goods are being purchased so a shipping address is not required for the transaction.
-
#pairing_id ⇒ String
The unique pairing token identifier used to fetch card and address data from a wallet that is paired with a merchant during Express Checkout.
-
#pre_checkout_transaction_id ⇒ String
The precheckout identifier from PreCheckoutApi response.
-
#shipping_address_id ⇒ String
The shippingAddress identifier from PreCheckoutApi response.
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 = {}) ⇒ ExpressCheckoutRequest
constructor
A new instance of ExpressCheckoutRequest.
-
#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 = {}) ⇒ ExpressCheckoutRequest
Returns a new instance of ExpressCheckoutRequest.
60 61 62 63 64 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 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 60 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?(:checkout_id) self.checkout_id = attributes[:checkout_id] end if attributes.has_key?(:pairing_id) self.pairing_id = attributes[:pairing_id] end if attributes.has_key?(:pre_checkout_transaction_id) self.pre_checkout_transaction_id = attributes[:pre_checkout_transaction_id] end if attributes.has_key?(:amount) self.amount = attributes[:amount] end if attributes.has_key?(:currency) self.currency = attributes[:currency] end if attributes.has_key?(:card_id) self.card_id = attributes[:card_id] end if attributes.has_key?(:shipping_address_id) self.shipping_address_id = attributes[:shipping_address_id] end if attributes.has_key?(:digital_goods) self.digital_goods = attributes[:digital_goods] end end |
Instance Attribute Details
#amount ⇒ Float
Returns the transaction amount.
26 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 26 xml_accessor :amount, :from =>"amount" |
#card_id ⇒ String
Returns the card identifier from PreCheckoutApi response.
34 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 34 xml_accessor :card_id, :from =>"cardId" |
#checkout_id ⇒ String
Returns the merchant Checkout identifier.
14 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 14 xml_accessor :checkout_id, :from =>"checkoutId" |
#currency ⇒ String
Returns the ISO-4217 code for currency of the transaction.
30 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 30 xml_accessor :currency, :from =>"currency" |
#digital_goods ⇒ BOOLEAN
Returns the flag to indicate digital goods are being purchased so a shipping address is not required for the transaction.
42 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 42 xml_accessor :digital_goods, :from =>"digitalGoods" |
#pairing_id ⇒ String
Returns the unique pairing token identifier used to fetch card and address data from a wallet that is paired with a merchant during Express Checkout.
18 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 18 xml_accessor :pairing_id, :from =>"pairingId" |
#pre_checkout_transaction_id ⇒ String
Returns the precheckout identifier from PreCheckoutApi response.
22 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 22 xml_accessor :pre_checkout_transaction_id, :from =>"preCheckoutTransactionId" |
#shipping_address_id ⇒ String
Returns the shippingAddress identifier from PreCheckoutApi response.
38 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 38 xml_accessor :shipping_address_id, :from =>"shippingAddressId" |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 46 def self.attribute_map { :checkout_id => :checkoutId , :pairing_id => :pairingId , :pre_checkout_transaction_id => :preCheckoutTransactionId , :amount => :amount , :currency => :currency , :card_id => :cardId , :shipping_address_id => :shippingAddressId , :digital_goods => :digitalGoods } end |
Instance Method Details
#==(o) ⇒ Object
Check equality by comparing each attribute.
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 105 def ==(o) return true if self.equal?(o) self.class == o.class && checkout_id == o.checkout_id && pairing_id == o.pairing_id && pre_checkout_transaction_id == o.pre_checkout_transaction_id && amount == o.amount && currency == o.currency && card_id == o.card_id && shipping_address_id == o.shipping_address_id && digital_goods == o.digital_goods end |
#_deserialize(type, value) ⇒ Object
148 149 150 151 152 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 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 148 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
207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 207 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
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 129 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
119 120 121 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 119 def eql?(o) self == o end |
#hash ⇒ Object
Calculate hash code according to all attributes.
124 125 126 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 124 def hash [checkout_id, pairing_id, pre_checkout_transaction_id, amount, currency, card_id, shipping_address_id, digital_goods].hash end |
#to_body ⇒ Object
to_body is an alias to to_body (backward compatibility))
188 189 190 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 188 def to_body to_hash end |
#to_hash(include_root = false) ⇒ Object
return the object in the form of hash
193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 193 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 ? { "ExpressCheckoutRequest" => hash } : hash return attributes_hash end |
#to_s ⇒ Object
183 184 185 |
# File 'lib/mastercard_merchant_checkout/models/express_checkout_request.rb', line 183 def to_s to_hash.to_s end |