Class: Unit::Card::CreateIndividualVirtualCardRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/card/create_individual_virtual_card_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_id, customer_id = nil, idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil) ⇒ CreateIndividualVirtualCardRequest

Returns a new instance of CreateIndividualVirtualCardRequest.

Parameters:

  • account_id (String)
  • customer_id (String) (defaults to: nil)
    • optional

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

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

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

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



16
17
18
19
20
21
22
23
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 16

def initialize(, customer_id = nil, idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
  @account_id = 
  @customer_id = customer_id
  @idempotency_key = idempotency_key
  @tags = tags
  @limits = limits
  @expiry_date = expiry_date
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 8

def 
  @account_id
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



8
9
10
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 8

def customer_id
  @customer_id
end

#expiry_dateObject (readonly)

Returns the value of attribute expiry_date.



8
9
10
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 8

def expiry_date
  @expiry_date
end

#idempotency_keyObject (readonly)

Returns the value of attribute idempotency_key.



8
9
10
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 8

def idempotency_key
  @idempotency_key
end

#limitsObject (readonly)

Returns the value of attribute limits.



8
9
10
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 8

def limits
  @limits
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 8

def tags
  @tags
end

Instance Method Details

#to_json_apiObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/unit/models/card/create_individual_virtual_card_request.rb', line 25

def to_json_api
  payload = {
    "data": {
      "type": "individualVirtualDebitCard",
      "attributes": {
        "idempotencyKey": idempotency_key,
        "tags": tags,
        "limits": limits,
        "expiryDate": expiry_date
      },
      "relationships": {
        "account": Unit::Types::Relationship.new("depositAccount", ).to_hash
      }
    }
  }
  customer = { "customer": Unit::Types::Relationship.new("customer", customer_id).to_hash } unless customer_id.nil?
  payload[:data][:relationships].merge!(customer) unless customer.nil?
  payload[:data][:attributes].compact!
  payload.to_json
end