Class: Unit::CheckPayment::OriginateCheckPaymentRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/check_payment/originate_check_payment_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id, customer_id, customer_type, amount, counterparty, description, idempotency_key, memo, send_date, tags = nil) ⇒ OriginateCheckPaymentRequest

Returns a new instance of OriginateCheckPaymentRequest.

Parameters:

  • account_id (String)
  • customer_id (String)
  • customer_type (String)
  • amount (Integer)
  • counterparty (CheckPaymentCounterparty)
  • description (String)
  • idempotency_key (String)
  • memo (String)
    • optional

  • send_date (String)
    • optional

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



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 20

def initialize(, customer_id, customer_type, amount, counterparty, description, idempotency_key, memo, send_date, tags = nil)
  @account_id = 
  @customer_id = customer_id
  @customer_type = customer_type
  @amount = amount
  @counterparty = counterparty
  @description = description
  @idempotency_key = idempotency_key
  @memo = memo
  @send_date = send_date
  @tags = tags
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def 
  @account_id
end

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def amount
  @amount
end

#counterpartyObject (readonly)

Returns the value of attribute counterparty.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def counterparty
  @counterparty
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def customer_id
  @customer_id
end

#customer_typeObject (readonly)

Returns the value of attribute customer_type.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def customer_type
  @customer_type
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_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/check_payment/originate_check_payment_request.rb', line 8

def idempotency_key
  @idempotency_key
end

#memoObject (readonly)

Returns the value of attribute memo.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def memo
  @memo
end

#send_dateObject (readonly)

Returns the value of attribute send_date.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def send_date
  @send_date
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 8

def tags
  @tags
end

Instance Method Details

#to_json_apiObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/unit/models/check_payment/originate_check_payment_request.rb', line 33

def to_json_api
  payload = {
    "data": {
      "type": "checkPayment",
      "attributes": {
        "amount": amount,
        "counterparty": counterparty.represent,
        "description": description,
        "memo": memo,
        "sendDate": send_date,
        "idempotencyKey": idempotency_key,
        "tags": tags
      },
      "relationships": {
        "account": Unit::Types::Relationship.new("depositAccount", ).to_hash,
        "customer": Unit::Types::Relationship.new(customer_type, customer_id).to_hash
      }
    }
  }
  payload[:data][:attributes].compact!
  payload.to_json
end