Class: WebPay::TokenRequestCreate

Inherits:
Entity
  • Object
show all
Defined in:
lib/webpay/data_types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#normalize_hash, #to_h, #to_s

Constructor Details

#initialize(hash = {}) ⇒ TokenRequestCreate

Returns a new instance of TokenRequestCreate.



1267
1268
1269
1270
1271
# File 'lib/webpay/data_types.rb', line 1267

def initialize(hash = {})
  hash = normalize_hash(hash)
  hash['card'] = WebPay::CardRequest.new(hash['card']) if hash['card'].is_a?(Hash)
  @attributes = hash
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



1249
1250
1251
# File 'lib/webpay/data_types.rb', line 1249

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
# File 'lib/webpay/data_types.rb', line 1256

def self.create(params)
  return params if params.is_a?(self)
  hash = case params
    when Hash; params
    when WebPay::CardRequest; {'card' => params}
    else
      raise WebPay::InvalidRequestError.new("#{self} does not accept the given value", params)
    end
  self.new(hash)
end

.fieldsObject



1251
1252
1253
# File 'lib/webpay/data_types.rb', line 1251

def self.fields
  ['card', 'customer', 'uuid']
end

Instance Method Details

#cardObject

attributes accessors



1289
1290
1291
# File 'lib/webpay/data_types.rb', line 1289

def card
  attributes['card']
end

#card=(value) ⇒ Object



1293
1294
1295
1296
# File 'lib/webpay/data_types.rb', line 1293

def card=(value)
  value = WebPay::CardRequest.new(value) if value.is_a?(Hash)
  attributes['card'] = value
end

#customerObject



1298
1299
1300
# File 'lib/webpay/data_types.rb', line 1298

def customer
  attributes['customer']
end

#customer=(value) ⇒ Object



1302
1303
1304
# File 'lib/webpay/data_types.rb', line 1302

def customer=(value)
  attributes['customer'] = value
end

#query_paramsObject



1282
1283
1284
1285
# File 'lib/webpay/data_types.rb', line 1282

def query_params
  result = {}
  return result
end

#request_bodyObject



1274
1275
1276
1277
1278
1279
1280
# File 'lib/webpay/data_types.rb', line 1274

def request_body
  result = {}
  copy_if_exists(@attributes, result, 'card', 'request_body');
  copy_if_exists(@attributes, result, 'customer', 'request_body');
  copy_if_exists(@attributes, result, 'uuid', 'request_body');
  result
end

#uuidObject



1306
1307
1308
# File 'lib/webpay/data_types.rb', line 1306

def uuid
  attributes['uuid']
end

#uuid=(value) ⇒ Object



1310
1311
1312
# File 'lib/webpay/data_types.rb', line 1310

def uuid=(value)
  attributes['uuid'] = value
end