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.



566
567
568
569
# File 'lib/webpay/data_types.rb', line 566

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



547
548
549
# File 'lib/webpay/data_types.rb', line 547

def attributes
  @attributes
end

Class Method Details

.create(params) ⇒ Object



554
555
556
557
558
559
560
561
562
563
564
# File 'lib/webpay/data_types.rb', line 554

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



549
550
551
# File 'lib/webpay/data_types.rb', line 549

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

Instance Method Details

#amountObject



593
594
595
# File 'lib/webpay/data_types.rb', line 593

def amount
  attributes['amount']
end

#amount=(value) ⇒ Object



597
598
599
# File 'lib/webpay/data_types.rb', line 597

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

#idObject

attributes accessors



585
586
587
# File 'lib/webpay/data_types.rb', line 585

def id
  attributes['id']
end

#id=(value) ⇒ Object



589
590
591
# File 'lib/webpay/data_types.rb', line 589

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

#query_paramsObject



578
579
580
581
# File 'lib/webpay/data_types.rb', line 578

def query_params
  result = {}
  return result
end

#request_bodyObject



572
573
574
575
576
# File 'lib/webpay/data_types.rb', line 572

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