Class: WebPay::CardRequest

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 = {}) ⇒ CardRequest

Returns a new instance of CardRequest.



65
66
67
68
# File 'lib/webpay/data_types.rb', line 65

def initialize(hash = {})
  hash = normalize_hash(hash)
  @attributes = hash
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



48
49
50
# File 'lib/webpay/data_types.rb', line 48

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/webpay/data_types.rb', line 55

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

.fieldsObject



50
51
52
# File 'lib/webpay/data_types.rb', line 50

def self.fields
  ['number', 'exp_month', 'exp_year', 'cvc', 'name']
end

Instance Method Details

#cvcObject



112
113
114
# File 'lib/webpay/data_types.rb', line 112

def cvc
  attributes['cvc']
end

#cvc=(value) ⇒ Object



116
117
118
# File 'lib/webpay/data_types.rb', line 116

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

#exp_monthObject



96
97
98
# File 'lib/webpay/data_types.rb', line 96

def exp_month
  attributes['exp_month']
end

#exp_month=(value) ⇒ Object



100
101
102
# File 'lib/webpay/data_types.rb', line 100

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

#exp_yearObject



104
105
106
# File 'lib/webpay/data_types.rb', line 104

def exp_year
  attributes['exp_year']
end

#exp_year=(value) ⇒ Object



108
109
110
# File 'lib/webpay/data_types.rb', line 108

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

#nameObject



120
121
122
# File 'lib/webpay/data_types.rb', line 120

def name
  attributes['name']
end

#name=(value) ⇒ Object



124
125
126
# File 'lib/webpay/data_types.rb', line 124

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

#numberObject

attributes accessors



88
89
90
# File 'lib/webpay/data_types.rb', line 88

def number
  attributes['number']
end

#number=(value) ⇒ Object



92
93
94
# File 'lib/webpay/data_types.rb', line 92

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

#query_paramsObject



81
82
83
84
# File 'lib/webpay/data_types.rb', line 81

def query_params
  result = {}
  return result
end

#request_bodyObject



71
72
73
74
75
76
77
78
79
# File 'lib/webpay/data_types.rb', line 71

def request_body
  result = {}
  copy_if_exists(@attributes, result, 'number', 'request_body');
  copy_if_exists(@attributes, result, 'exp_month', 'request_body');
  copy_if_exists(@attributes, result, 'exp_year', 'request_body');
  copy_if_exists(@attributes, result, 'cvc', 'request_body');
  copy_if_exists(@attributes, result, 'name', 'request_body');
  result
end