Class: Unit::Payment::CreateBookPaymentRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/payment/create_book_payment_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil, idempotency_key: nil, tags: nil) ⇒ CreateBookPaymentRequest

Returns a new instance of CreateBookPaymentRequest.

Parameters:

  • amount (Integer)
  • description (String)
  • account_id (String)
  • counterparty_account_id (String)
  • transaction_summary_override (String) (defaults to: nil)
    • optional

  • idempotency_key (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional



17
18
19
20
21
22
23
24
25
26
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 17

def initialize(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil,
               idempotency_key: nil, tags: nil)
  @amount = amount
  @description = description
  @account_id = 
  @counterparty_account_id = 
  @transaction_summary_override = transaction_summary_override
  @idempotency_key = idempotency_key
  @tags = tags
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def 
  @account_id
end

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def amount
  @amount
end

#counterparty_account_idObject (readonly)

Returns the value of attribute counterparty_account_id.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def 
  @counterparty_account_id
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def description
  @description
end

#idempotency_keyObject (readonly)

Returns the value of attribute idempotency_key.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def idempotency_key
  @idempotency_key
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def tags
  @tags
end

#transaction_summary_overrideObject (readonly)

Returns the value of attribute transaction_summary_override.



8
9
10
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 8

def transaction_summary_override
  @transaction_summary_override
end

Instance Method Details

#change_attributesObject



51
52
53
54
55
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 51

def change_attributes
  payload = to_hash
  payload[:attributes].compact!
  payload
end

#to_hashObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 36

def to_hash
  {
    type: "bookPayment",
    attributes: {
      amount: amount,
      description: description,
      transactionSummaryOverride: transaction_summary_override,
      idempotencyKey: idempotency_key,
      tags: tags
    },
    relationships: { account: Unit::Types::Relationship.new("depositAccount", ).to_hash,
                     counterpartyAccount: Unit::Types::Relationship.new("depositAccount", ).to_hash }
  }
end

#to_json_apiObject



28
29
30
31
32
33
34
# File 'lib/unit/models/payment/create_book_payment_request.rb', line 28

def to_json_api
  payload = {
    data: to_hash
  }
  payload[:data][:attributes].compact!
  payload.to_json
end