Class: Mpp::Methods::Tempo::Schemas::ChargeRequest

Inherits:
Data
  • Object
show all
Defined in:
lib/mpp/methods/tempo/schemas.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount:, currency:, recipient:, description: nil, external_id: nil, method_details: nil) ⇒ ChargeRequest

Returns a new instance of ChargeRequest.

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
# File 'lib/mpp/methods/tempo/schemas.rb', line 29

def initialize(amount:, currency:, recipient:, description: nil,
  external_id: nil, method_details: nil)
  raise ArgumentError, "currency must be a hex address" unless currency.match?(HEX_PATTERN)
  raise ArgumentError, "recipient must be a hex address" unless recipient.match?(HEX_PATTERN)

  method_details ||= MethodDetails.new
  super
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



27
28
29
# File 'lib/mpp/methods/tempo/schemas.rb', line 27

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



27
28
29
# File 'lib/mpp/methods/tempo/schemas.rb', line 27

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



27
28
29
# File 'lib/mpp/methods/tempo/schemas.rb', line 27

def description
  @description
end

#external_idObject (readonly)

Returns the value of attribute external_id

Returns:

  • (Object)

    the current value of external_id



27
28
29
# File 'lib/mpp/methods/tempo/schemas.rb', line 27

def external_id
  @external_id
end

#method_detailsObject (readonly)

Returns the value of attribute method_details

Returns:

  • (Object)

    the current value of method_details



27
28
29
# File 'lib/mpp/methods/tempo/schemas.rb', line 27

def method_details
  @method_details
end

#recipientObject (readonly)

Returns the value of attribute recipient

Returns:

  • (Object)

    the current value of recipient



27
28
29
# File 'lib/mpp/methods/tempo/schemas.rb', line 27

def recipient
  @recipient
end

Class Method Details

.from_hash(hash) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/mpp/methods/tempo/schemas.rb', line 38

def self.from_hash(hash)
  new(
    amount: hash["amount"],
    currency: hash["currency"],
    recipient: hash["recipient"],
    description: hash["description"],
    external_id: hash["externalId"],
    method_details: MethodDetails.from_hash(hash["methodDetails"])
  )
end