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.



1184
1185
1186
1187
1188
# File 'lib/webpay/data_types.rb', line 1184

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.



1166
1167
1168
# File 'lib/webpay/data_types.rb', line 1166

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
# File 'lib/webpay/data_types.rb', line 1173

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



1168
1169
1170
# File 'lib/webpay/data_types.rb', line 1168

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

Instance Method Details

#cardObject

attributes accessors



1206
1207
1208
# File 'lib/webpay/data_types.rb', line 1206

def card
  attributes['card']
end

#card=(value) ⇒ Object



1210
1211
1212
1213
# File 'lib/webpay/data_types.rb', line 1210

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

#customerObject



1215
1216
1217
# File 'lib/webpay/data_types.rb', line 1215

def customer
  attributes['customer']
end

#customer=(value) ⇒ Object



1219
1220
1221
# File 'lib/webpay/data_types.rb', line 1219

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

#query_paramsObject



1199
1200
1201
1202
# File 'lib/webpay/data_types.rb', line 1199

def query_params
  result = {}
  return result
end

#request_bodyObject



1191
1192
1193
1194
1195
1196
1197
# File 'lib/webpay/data_types.rb', line 1191

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



1223
1224
1225
# File 'lib/webpay/data_types.rb', line 1223

def uuid
  attributes['uuid']
end

#uuid=(value) ⇒ Object



1227
1228
1229
# File 'lib/webpay/data_types.rb', line 1227

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