Class: Unit::CheckDeposit::CreateCheckDepositRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/check_deposit/create_check_deposit_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id, amount, description, tags = nil, idempotency_key = nil) ⇒ CreateCheckDepositRequest

Returns a new instance of CreateCheckDepositRequest.

Parameters:

  • account_id (String)
  • amount (Integer)
  • description (String)
  • tags (Hash) (defaults to: nil)
    • optional

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



15
16
17
18
19
20
21
# File 'lib/unit/models/check_deposit/create_check_deposit_request.rb', line 15

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

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/check_deposit/create_check_deposit_request.rb', line 8

def 
  @account_id
end

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/unit/models/check_deposit/create_check_deposit_request.rb', line 8

def amount
  @amount
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/unit/models/check_deposit/create_check_deposit_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_deposit/create_check_deposit_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/check_deposit/create_check_deposit_request.rb', line 8

def tags
  @tags
end

Instance Method Details

#to_json_apiObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/unit/models/check_deposit/create_check_deposit_request.rb', line 23

def to_json_api
  payload = {
    "data": {
      "type": "checkDeposit",
      "attributes": {
        amount: amount,
        description: description,
        tags: tags,
        idempotencyKey: idempotency_key
      },
      "relationships": {
        "account": Unit::Types::Relationship.new("account", ).to_hash
      }
    }
  }
  payload[:data][:attributes].compact!
  payload.to_json
end