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.



147
148
149
150
151
# File 'lib/webpay/data_types.rb', line 147

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.



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

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



137
138
139
140
141
142
143
144
145
# File 'lib/webpay/data_types.rb', line 137

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



132
133
134
# File 'lib/webpay/data_types.rb', line 132

def self.fields
  ['amount', 'currency', 'customer', 'shop', 'card', 'description', 'capture', 'expire_days', 'uuid']
end

Instance Method Details

#amountObject

attributes accessors



175
176
177
# File 'lib/webpay/data_types.rb', line 175

def amount
  attributes['amount']
end

#amount=(value) ⇒ Object



179
180
181
# File 'lib/webpay/data_types.rb', line 179

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

#captureObject



224
225
226
# File 'lib/webpay/data_types.rb', line 224

def capture
  attributes['capture']
end

#capture=(value) ⇒ Object



228
229
230
# File 'lib/webpay/data_types.rb', line 228

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

#cardObject



207
208
209
# File 'lib/webpay/data_types.rb', line 207

def card
  attributes['card']
end

#card=(value) ⇒ Object



211
212
213
214
# File 'lib/webpay/data_types.rb', line 211

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

#currencyObject



183
184
185
# File 'lib/webpay/data_types.rb', line 183

def currency
  attributes['currency']
end

#currency=(value) ⇒ Object



187
188
189
# File 'lib/webpay/data_types.rb', line 187

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

#customerObject



191
192
193
# File 'lib/webpay/data_types.rb', line 191

def customer
  attributes['customer']
end

#customer=(value) ⇒ Object



195
196
197
# File 'lib/webpay/data_types.rb', line 195

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

#descriptionObject



216
217
218
# File 'lib/webpay/data_types.rb', line 216

def description
  attributes['description']
end

#description=(value) ⇒ Object



220
221
222
# File 'lib/webpay/data_types.rb', line 220

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

#expire_daysObject



232
233
234
# File 'lib/webpay/data_types.rb', line 232

def expire_days
  attributes['expire_days']
end

#expire_days=(value) ⇒ Object



236
237
238
# File 'lib/webpay/data_types.rb', line 236

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

#query_paramsObject



168
169
170
171
# File 'lib/webpay/data_types.rb', line 168

def query_params
  result = {}
  return result
end

#request_bodyObject



154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/webpay/data_types.rb', line 154

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



199
200
201
# File 'lib/webpay/data_types.rb', line 199

def shop
  attributes['shop']
end

#shop=(value) ⇒ Object



203
204
205
# File 'lib/webpay/data_types.rb', line 203

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

#uuidObject



240
241
242
# File 'lib/webpay/data_types.rb', line 240

def uuid
  attributes['uuid']
end

#uuid=(value) ⇒ Object



244
245
246
# File 'lib/webpay/data_types.rb', line 244

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