Class: WebPay::ChargeRequestWithAmount

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

Returns a new instance of ChargeRequestWithAmount.



501
502
503
504
# File 'lib/webpay/data_types.rb', line 501

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



482
483
484
# File 'lib/webpay/data_types.rb', line 482

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



489
490
491
492
493
494
495
496
497
498
499
# File 'lib/webpay/data_types.rb', line 489

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

.fieldsObject



484
485
486
# File 'lib/webpay/data_types.rb', line 484

def self.fields
  ['id', 'amount']
end

Instance Method Details

#amountObject



528
529
530
# File 'lib/webpay/data_types.rb', line 528

def amount
  attributes['amount']
end

#amount=(value) ⇒ Object



532
533
534
# File 'lib/webpay/data_types.rb', line 532

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

#idObject

attributes accessors



520
521
522
# File 'lib/webpay/data_types.rb', line 520

def id
  attributes['id']
end

#id=(value) ⇒ Object



524
525
526
# File 'lib/webpay/data_types.rb', line 524

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

#query_paramsObject



513
514
515
516
# File 'lib/webpay/data_types.rb', line 513

def query_params
  result = {}
  return result
end

#request_bodyObject



507
508
509
510
511
# File 'lib/webpay/data_types.rb', line 507

def request_body
  result = {}
  copy_if_exists(@attributes, result, 'amount', 'request_body');
  result
end