Class: WebPay::ChargeRequestCreate

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

Returns a new instance of ChargeRequestCreate.



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

def initialize(hash = {})
  hash = normalize_hash(hash)
  hash['card'] = hash['card'].is_a?(Hash) ? WebPay::CardRequest.new(hash['card']) : hash['card']
  @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
  ['amount', 'currency', 'customer', 'shop', 'card', 'description', 'capture', 'expire_days', 'uuid']
end

Instance Method Details

#amountObject

attributes accessors



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

def amount
  attributes['amount']
end

#amount=(value) ⇒ Object



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

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

#captureObject



142
143
144
# File 'lib/webpay/data_types.rb', line 142

def capture
  attributes['capture']
end

#capture=(value) ⇒ Object



146
147
148
# File 'lib/webpay/data_types.rb', line 146

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

#cardObject



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

def card
  attributes['card']
end

#card=(value) ⇒ Object



129
130
131
132
# File 'lib/webpay/data_types.rb', line 129

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

#currencyObject



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

def currency
  attributes['currency']
end

#currency=(value) ⇒ Object



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

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

#customerObject



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

def customer
  attributes['customer']
end

#customer=(value) ⇒ Object



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

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

#descriptionObject



134
135
136
# File 'lib/webpay/data_types.rb', line 134

def description
  attributes['description']
end

#description=(value) ⇒ Object



138
139
140
# File 'lib/webpay/data_types.rb', line 138

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

#expire_daysObject



150
151
152
# File 'lib/webpay/data_types.rb', line 150

def expire_days
  attributes['expire_days']
end

#expire_days=(value) ⇒ Object



154
155
156
# File 'lib/webpay/data_types.rb', line 154

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

#query_paramsObject



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

def query_params
  result = {}
  return result
end

#request_bodyObject



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/webpay/data_types.rb', line 72

def request_body
  result = {}
  copy_if_exists(@attributes, result, 'amount', 'request_body');
  copy_if_exists(@attributes, result, 'currency', 'request_body');
  copy_if_exists(@attributes, result, 'customer', 'request_body');
  copy_if_exists(@attributes, result, 'shop', 'request_body');
  copy_if_exists(@attributes, result, 'card', 'request_body');
  copy_if_exists(@attributes, result, 'description', 'request_body');
  copy_if_exists(@attributes, result, 'capture', 'request_body');
  copy_if_exists(@attributes, result, 'expire_days', 'request_body');
  copy_if_exists(@attributes, result, 'uuid', 'request_body');
  result
end

#shopObject



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

def shop
  attributes['shop']
end

#shop=(value) ⇒ Object



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

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

#uuidObject



158
159
160
# File 'lib/webpay/data_types.rb', line 158

def uuid
  attributes['uuid']
end

#uuid=(value) ⇒ Object



162
163
164
# File 'lib/webpay/data_types.rb', line 162

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