Class: Unit::Payment::CreatePaymentLinkedRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id:, counterparty_id:, amount:, direction:, description:, addenda: nil, idempotency_key: nil, tags: nil, verify_counterparty_balance: nil, same_day: nil, sec_code: nil) ⇒ CreatePaymentLinkedRequest

Returns a new instance of CreatePaymentLinkedRequest.

Parameters:

  • account_id (String)
  • counterparty_id (String)
  • amount (Integer)
  • direction (String)
  • description (String)
  • addenda (String) (defaults to: nil)
    • optional

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

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

  • verify_counterparty_balance (Boolean) (defaults to: nil)
    • optional

  • same_day (Boolean) (defaults to: nil)
    • optional

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/unit/models/payment/create_payment_linked_request.rb', line 23

def initialize(account_id:, counterparty_id:, amount:, direction:, description:,
               addenda: nil, idempotency_key: nil, tags: nil, verify_counterparty_balance: nil,
               same_day: nil, sec_code: nil)
  @account_id = 
  @counterparty_id = counterparty_id
  @amount = amount
  @direction = direction
  @description = description
  @addenda = addenda
  @idempotency_key = idempotency_key
  @tags = tags
  @verify_counterparty_balance = verify_counterparty_balance
  @same_day = same_day
  @sec_code = sec_code
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



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

def 
  @account_id
end

#addendaObject (readonly)

Returns the value of attribute addenda.



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

def addenda
  @addenda
end

#amountObject (readonly)

Returns the value of attribute amount.



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

def amount
  @amount
end

#counterparty_idObject (readonly)

Returns the value of attribute counterparty_id.



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

def counterparty_id
  @counterparty_id
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#directionObject (readonly)

Returns the value of attribute direction.



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

def direction
  @direction
end

#idempotency_keyObject (readonly)

Returns the value of attribute idempotency_key.



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

def idempotency_key
  @idempotency_key
end

#same_dayObject (readonly)

Returns the value of attribute same_day.



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

def same_day
  @same_day
end

#sec_codeObject (readonly)

Returns the value of attribute sec_code.



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

def sec_code
  @sec_code
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

#verify_counterparty_balanceObject (readonly)

Returns the value of attribute verify_counterparty_balance.



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

def verify_counterparty_balance
  @verify_counterparty_balance
end

Instance Method Details

#change_attributesObject



68
69
70
71
72
# File 'lib/unit/models/payment/create_payment_linked_request.rb', line 68

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

#to_hashObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/unit/models/payment/create_payment_linked_request.rb', line 47

def to_hash
  {
    "type": "achPayment",
    "attributes": {
      amount: amount,
      direction: direction,
      description: description,
      addenda: addenda,
      idempotencyKey: idempotency_key,
      tags: tags,
      verifyCounterpartyBalance: verify_counterparty_balance,
      sameDay: same_day,
      secCode: sec_code
    },
    "relationships": {
      "account": Unit::Types::Relationship.new("account", ).to_hash,
      "counterparty": Unit::Types::Relationship.new("counterparty", counterparty_id).to_hash
    }
  }
end

#to_json_apiObject



39
40
41
42
43
44
45
# File 'lib/unit/models/payment/create_payment_linked_request.rb', line 39

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