Class: Unit::RecurringPayment::CreateRecurringDebitAchPaymentRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id, counterparty_id, amount, description, schedule, addenda = nil, idempotency_key = nil, tags = nil, verify_counterparty_balance = nil, same_day = nil) ⇒ CreateRecurringDebitAchPaymentRequest

Returns a new instance of CreateRecurringDebitAchPaymentRequest.

Parameters:

  • account_id (String)
  • counterparty_id (String)
  • amount (Integer)
  • description (String)
  • schedule (CreateSchedule)
  • 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



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 21

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

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 8

def 
  @account_id
end

#addendaObject (readonly)

Returns the value of attribute addenda.



8
9
10
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 8

def addenda
  @addenda
end

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_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/recurring_payment/create_recurring_debit_ach_payment_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/recurring_payment/create_recurring_debit_ach_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/recurring_payment/create_recurring_debit_ach_payment_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/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 8

def same_day
  @same_day
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



8
9
10
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 8

def schedule
  @schedule
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_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/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 8

def verify_counterparty_balance
  @verify_counterparty_balance
end

Instance Method Details

#to_json_apiObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb', line 35

def to_json_api
  payload = {
    "data": {
      "type": "recurringDebitAchPayment",
      "attributes": {
        "amount": amount,
        "description": description,
        "addenda": addenda,
        "schedule": schedule&.represent,
        "idempotencyKey": idempotency_key,
        "tags": tags,
        "verifyCounterpartyBalance": verify_counterparty_balance,
        "sameDay": same_day
      },
      "relationships": {
        account: Unit::Types::Relationship.new("depositAccount", ).to_hash,
        counterparty: Unit::Types::Relationship.new("counterparty", counterparty_id).to_hash
      }
    }
  }
  payload[:data][:attributes].compact!
  payload.to_json
end