unit_ruby_sdk 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +182 -20
  3. data/lib/unit/api_resources/account_resource.rb +24 -0
  4. data/lib/unit/api_resources/application_form_resource.rb +40 -0
  5. data/lib/unit/api_resources/authorization_request_resource.rb +49 -0
  6. data/lib/unit/api_resources/authorization_resource.rb +31 -0
  7. data/lib/unit/api_resources/card_resource.rb +8 -0
  8. data/lib/unit/api_resources/event_resource.rb +40 -0
  9. data/lib/unit/api_resources/fee_resource.rb +32 -0
  10. data/lib/unit/api_resources/institution_resource.rb +23 -0
  11. data/lib/unit/api_resources/payment_resource.rb +9 -0
  12. data/lib/unit/api_resources/received_payment_resource.rb +47 -0
  13. data/lib/unit/api_resources/recurring_payment_resource.rb +55 -0
  14. data/lib/unit/api_resources/repayment_resource.rb +41 -0
  15. data/lib/unit/api_resources/reward_resource.rb +41 -0
  16. data/lib/unit/api_resources/webhook_resource.rb +65 -0
  17. data/lib/unit/models/account/account.rb +25 -0
  18. data/lib/unit/models/account/deposit/create_deposit_account_request.rb +2 -1
  19. data/lib/unit/models/application/application.rb +98 -10
  20. data/lib/unit/models/application/create_business_application_request.rb +34 -13
  21. data/lib/unit/models/application/create_individual_application_request.rb +12 -8
  22. data/lib/unit/models/application/create_sole_proprietor_application_request.rb +113 -0
  23. data/lib/unit/models/application/create_trust_application_request.rb +67 -0
  24. data/lib/unit/models/application/patch_trust_application_request.rb +31 -0
  25. data/lib/unit/models/application_form/application_form.rb +43 -0
  26. data/lib/unit/models/application_form/create_application_form_request.rb +48 -0
  27. data/lib/unit/models/application_form/list_application_form_params.rb +30 -0
  28. data/lib/unit/models/authorization/authorization.rb +42 -0
  29. data/lib/unit/models/authorization/get_request.rb +22 -0
  30. data/lib/unit/models/authorization/list_request.rb +67 -0
  31. data/lib/unit/models/authorization_request/approve_request.rb +37 -0
  32. data/lib/unit/models/authorization_request/authorization_request.rb +55 -0
  33. data/lib/unit/models/authorization_request/decline_request.rb +31 -0
  34. data/lib/unit/models/authorization_request/list_authorization_params.rb +44 -0
  35. data/lib/unit/models/card/card.rb +102 -4
  36. data/lib/unit/models/card/create_business_credit_card_request.rb +29 -0
  37. data/lib/unit/models/card/create_business_debit_card_request.rb +10 -6
  38. data/lib/unit/models/card/create_business_virtual_credit_card_request.rb +25 -0
  39. data/lib/unit/models/card/create_business_virtual_debit_card_request.rb +10 -6
  40. data/lib/unit/models/card/create_individual_debit_card_request.rb +7 -3
  41. data/lib/unit/models/card/create_individual_virtual_card_request.rb +6 -3
  42. data/lib/unit/models/card/patch_business_card_request.rb +50 -0
  43. data/lib/unit/models/card/patch_business_credit_card_request.rb +22 -0
  44. data/lib/unit/models/card/patch_business_virtual_card_request.rb +43 -0
  45. data/lib/unit/models/card/patch_business_virtual_credit_card_request.rb +20 -0
  46. data/lib/unit/models/customer/list_customer_params.rb +4 -2
  47. data/lib/unit/models/event/event.rb +37 -0
  48. data/lib/unit/models/event/list_event_params.rb +37 -0
  49. data/lib/unit/models/fee/create_fee_request.rb +43 -0
  50. data/lib/unit/models/fee/fee.rb +34 -0
  51. data/lib/unit/models/fee/reverse_fee_request.rb +43 -0
  52. data/lib/unit/models/institution/institution.rb +14 -0
  53. data/lib/unit/models/payment/batch_release_request_builder.rb +21 -0
  54. data/lib/unit/models/payment/create_batch_release_request.rb +54 -0
  55. data/lib/unit/models/payment/payment.rb +21 -1
  56. data/lib/unit/models/received_payment/list_payment_params.rb +51 -0
  57. data/lib/unit/models/received_payment/patch_payment_request.rb +31 -0
  58. data/lib/unit/models/received_payment/received_payment.rb +54 -0
  59. data/lib/unit/models/recurring_payment/create_recurring_credit_ach_payment_request.rb +52 -0
  60. data/lib/unit/models/recurring_payment/create_recurring_credit_book_payment_request.rb +54 -0
  61. data/lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb +60 -0
  62. data/lib/unit/models/recurring_payment/list_recurring_payment_params.rb +60 -0
  63. data/lib/unit/models/recurring_payment/recurring_payment.rb +106 -0
  64. data/lib/unit/models/repayment/create_ach_repayment_request.rb +57 -0
  65. data/lib/unit/models/repayment/create_book_repayment_request.rb +53 -0
  66. data/lib/unit/models/repayment/list_repayment_params.rb +48 -0
  67. data/lib/unit/models/repayment/repayment.rb +67 -0
  68. data/lib/unit/models/reward/create_reward_request.rb +49 -0
  69. data/lib/unit/models/reward/get_request.rb +22 -0
  70. data/lib/unit/models/reward/list_reward_params.rb +65 -0
  71. data/lib/unit/models/reward/reward.rb +55 -0
  72. data/lib/unit/models/unit_response.rb +1 -1
  73. data/lib/unit/models/webhook/create_webhook_request.rb +49 -0
  74. data/lib/unit/models/webhook/list_webhook_params.rb +39 -0
  75. data/lib/unit/models/webhook/patch_webhook_request.rb +47 -0
  76. data/lib/unit/models/webhook/webhook.rb +80 -0
  77. data/lib/unit/types/application_form_prefill.rb +84 -0
  78. data/lib/unit/types/application_form_settings_override.rb +51 -0
  79. data/lib/unit/types/beneficial_owner.rb +15 -10
  80. data/lib/unit/types/beneficiary.rb +25 -0
  81. data/lib/unit/types/create_schedule.rb +38 -0
  82. data/lib/unit/types/evaluation_params.rb +4 -4
  83. data/lib/unit/types/grantor.rb +37 -0
  84. data/lib/unit/types/officer.rb +26 -13
  85. data/lib/unit/types/power_of_attorney_agent.rb +5 -12
  86. data/lib/unit/types/require_id_verification.rb +29 -0
  87. data/lib/unit/types/trust_contact.rb +34 -0
  88. data/lib/unit/types/trustee.rb +37 -0
  89. data/lib/unit/version.rb +1 -1
  90. data/lib/unit_ruby_sdk.rb +33 -0
  91. metadata +68 -2
@@ -10,6 +10,12 @@ module Unit
10
10
  autoload :CreateIndividualVirtualCardRequest, "unit/models/card/create_individual_virtual_card_request"
11
11
  autoload :ReplaceCardRequest, "unit/models/card/replace_card_request"
12
12
  autoload :ListCardParams, "unit/models/card/list_card_params"
13
+ autoload :CreateBusinessCreditCardRequest, "unit/models/card/create_business_credit_card_request"
14
+ autoload :CreateBusinessVirtualCreditCardRequest, "unit/models/card/create_business_virtual_credit_card_request"
15
+ autoload :PatchBusinessCardRequest, "unit/models/card/patch_business_card_request"
16
+ autoload :PatchBusinessCreditCardRequest, "unit/models/card/patch_business_credit_card_request"
17
+ autoload :PatchBusinessVirtualCardRequest, "unit/models/card/patch_business_virtual_card_request"
18
+ autoload :PatchBusinessVirtualCreditCardRequest, "unit/models/card/patch_business_virtual_credit_card_request"
13
19
 
14
20
  class << self
15
21
  # Create a new individual debit card by calling Unit's API
@@ -22,10 +28,11 @@ module Unit
22
28
  # @param tags [Hash] - optional
23
29
  # @param limits [Hash] - optional
24
30
  # @param print_only_business_name [String] - optional
31
+ # @param expiry_date [String] - optional
25
32
  def create_individual_debit_card(account_id:, customer_id: nil, shipping_address: nil, design: nil, additional_embossed_text: nil,
26
- idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil)
33
+ idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil, expiry_date: nil)
27
34
  request = CreateIndividualDebitCardRequest.new(account_id, customer_id, shipping_address, design, additional_embossed_text,
28
- idempotency_key, tags, limits, print_only_business_name)
35
+ idempotency_key, tags, limits, print_only_business_name, expiry_date)
29
36
  Unit::Resource::CardResource.create_card(request)
30
37
  end
31
38
 
@@ -43,13 +50,104 @@ module Unit
43
50
  # @param tags [Hash] - optional
44
51
  # @param limits [Hash] - optional
45
52
  # @param print_only_business_name [Boolean] - optional
53
+ # @param expiry_date [String] - optional
46
54
  def create_business_debit_card(account_id:, full_name:, date_of_birth:, address:, phone:, email:, shipping_address: nil,
47
- design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil)
55
+ design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil, expiry_date: nil)
48
56
  request = CreateBusinessDebitCardRequest.new(account_id, full_name, date_of_birth, address, shipping_address, phone, email, design, additional_embossed_text,
49
- idempotency_key, tags, limits, print_only_business_name)
57
+ idempotency_key, tags, limits, print_only_business_name, expiry_date)
50
58
  Unit::Resource::CardResource.create_card(request)
51
59
  end
52
60
 
61
+ # Create a new business credit card by calling Unit's API
62
+ # @see https://guides.unit.co/business-charge-cards/#what-is-a-charge-card
63
+ # @param account_id [String]
64
+ # @param full_name [FullName]
65
+ # @param date_of_birth [Date]
66
+ # @param address [Address]
67
+ # @param shipping_address [Address] - optional
68
+ # @param phone [Phone] - optional
69
+ # @param email [String] - optional
70
+ # @param design [String] - optional
71
+ # @param additional_embossed_text [String] - optional
72
+ # @param idempotency_key [String] - optional
73
+ # @param tags [Hash] - optional
74
+ # @param limits [Hash] - optional
75
+ # @param print_only_business_name [Boolean] - optional
76
+ # @param expiry_date [String] - optional
77
+ def create_business_credit_card(account_id:, full_name:, date_of_birth:, address:, shipping_address: nil, phone: nil, email: nil, design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil, expiry_date: nil)
78
+ request = CreateBusinessCreditCardRequest.new(account_id, full_name, date_of_birth, address, shipping_address, phone, email, design, additional_embossed_text, idempotency_key, tags, limits, print_only_business_name, expiry_date)
79
+ Unit::Resource::CardResource.create_card(request)
80
+ end
81
+
82
+ # Create a new business virtual credit card by calling Unit's API
83
+ # @see https://docs.unit.co/cards#create-business-virtual-debit-card
84
+ # @param account_id [String]
85
+ # @param type [String]
86
+ # @param idempotency_key [String] - optional
87
+ # @param tags [Hash] - optional
88
+ # @param limits [Hash] - optional
89
+ # @param expiry_date [String] - optional
90
+ def create_business_virtual_credit_card(account_id:, full_name:, date_of_birth:, address:, phone: nil, email: nil, idempotency_key: nil, tags: nil, limits: nil, expiry_date: nil)
91
+ request = CreateBusinessVirtualCreditCardRequest.new(account_id, full_name, date_of_birth, address, phone, email, idempotency_key, tags, limits, expiry_date)
92
+ Unit::Resource::CardResource.create_card(request)
93
+ end
94
+
95
+ # Update a business debit card by calling Unit's API
96
+ # @see https://docs.unit.co/cards/#update-business-debit-card
97
+ # @param card_id [String]
98
+ # @param shipping_address [Address] - optional
99
+ # @param address [Address] - optional
100
+ # @param phone [Phone] - optional
101
+ # @param email [String] - optional
102
+ # @param design [String] - optional
103
+ # @param tags [Hash] - optional
104
+ # @param limits [Hash] - optional
105
+ def update_business_debit_card(card_id:, shipping_address: nil, address: nil, phone: nil, email: nil, design: nil, tags: nil, limits: nil)
106
+ request = PatchBusinessCardRequest.new(card_id, shipping_address, address, phone, email, design, tags, limits)
107
+ Unit::Resource::CardResource.update(request)
108
+ end
109
+
110
+ # Update a business credit card by calling Unit's API
111
+ # @see https://guides.unit.co/business-charge-cards/
112
+ # @param card_id [String]
113
+ # @param shipping_address [Address] - optional
114
+ # @param address [Address] - optional
115
+ # @param phone [Phone] - optional
116
+ # @param email [String] - optional
117
+ # @param design [String] - optional
118
+ # @param tags [Hash] - optional
119
+ # @param limits [Hash] - optional
120
+ def update_business_credit_card(card_id:, shipping_address: nil, address: nil, phone: nil, email: nil, design: nil, tags: nil, limits: nil)
121
+ request = PatchBusinessCreditCardRequest.new(card_id, shipping_address, address, phone, email, design, tags, limits)
122
+ Unit::Resource::CardResource.update(request)
123
+ end
124
+
125
+ # Update a business virtual debit card by calling Unit's API
126
+ # @see https://docs.unit.co/cards/#update-business-virtual-debit-card
127
+ # @param card_id [String]
128
+ # @param address [Address] - optional
129
+ # @param phone [Phone] - optional
130
+ # @param email [String] - optional
131
+ # @param tags [Hash] - optional
132
+ # @param limits [Hash] - optional
133
+ def update_business_virtual_debit_card(card_id:, address: nil, phone: nil, email: nil, tags: nil, limits: nil)
134
+ request = PatchBusinessVirtualCardRequest.new(card_id, address, phone, email, tags, limits)
135
+ Unit::Resource::CardResource.update(request)
136
+ end
137
+
138
+ # Update a business virtual credit card by calling Unit's API
139
+ # @see https://guides.unit.co/business-charge-cards/
140
+ # @param card_id [String]
141
+ # @param address [Address] - optional
142
+ # @param phone [Phone] - optional
143
+ # @param email [String] - optional
144
+ # @param tags [Hash] - optional
145
+ # @param limits [Hash] - optional
146
+ def update_business_virtual_credit_card(card_id:, address: nil, phone: nil, email: nil, tags: nil, limits: nil)
147
+ request = PatchBusinessVirtualCreditCardRequest.new(card_id, address, phone, email, tags, limits)
148
+ Unit::Resource::CardResource.update(request)
149
+ end
150
+
53
151
  # Create a new individual virtual card by calling Unit's API
54
152
  # @see https://docs.unit.co/cards#create-individual-virtual-debit-card
55
153
  # @param account_id [String]
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to create business credit card request
4
+ # @see https://guides.unit.co/business-charge-cards/
5
+ module Unit
6
+ module Card
7
+ class CreateBusinessCreditCardRequest < CreateBusinessDebitCardRequest
8
+ # @param account_id [String]
9
+ # @param full_name [FullName]
10
+ # @param date_of_birth [Date]
11
+ # @param address [Address]
12
+ # @param shipping_address [Address] - optional
13
+ # @param phone [Phone] - optional
14
+ # @param email [String] - optional
15
+ # @param design [String] - optional
16
+ # @param additional_embossed_text [String] - optional
17
+ # @param idempotency_key [String] - optional
18
+ # @param tags [Hash] - optional
19
+ # @param limits [Hash] - optional
20
+ # @param print_only_business_name [Boolean] - optional
21
+ # @param expiry_date [String] - optional
22
+ def initialize(account_id, full_name, date_of_birth, address, shipping_address = nil, phone = nil, email = nil, design = nil,
23
+ additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil, expiry_date = nil)
24
+ super
25
+ @type = "businessCreditCard"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,7 +5,8 @@
5
5
  module Unit
6
6
  module Card
7
7
  class CreateBusinessDebitCardRequest
8
- attr_reader :account_id, :full_name, :date_of_birth, :address, :shipping_address, :phone, :email, :design, :additional_embossed_text, :idempotency_key, :tags, :limits, :print_only_business_name
8
+ attr_reader :account_id, :full_name, :date_of_birth, :address, :shipping_address, :phone, :email, :design, :additional_embossed_text,
9
+ :idempotency_key, :tags, :limits, :print_only_business_name, :expiry_date, :type
9
10
 
10
11
  # @param account_id [String]
11
12
  # @param full_name [FullName]
@@ -20,8 +21,9 @@ module Unit
20
21
  # @param tags [Hash] - optional
21
22
  # @param limits [Hash] - optional
22
23
  # @param print_only_business_name [Boolean] - optional
24
+ # @param expiry_date [String] - optional
23
25
  def initialize(account_id, full_name, date_of_birth, address, shipping_address = nil, phone = nil, email = nil, design = nil,
24
- additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil)
26
+ additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil, expiry_date = nil)
25
27
  @account_id = account_id
26
28
  @full_name = full_name
27
29
  @date_of_birth = date_of_birth
@@ -35,12 +37,14 @@ module Unit
35
37
  @tags = tags
36
38
  @limits = limits
37
39
  @print_only_business_name = print_only_business_name
40
+ @expiry_date = expiry_date
41
+ @type = "businessDebitCard"
38
42
  end
39
43
 
40
44
  def to_json_api
41
45
  payload = {
42
46
  "data": {
43
- "type": "businessDebitCard",
47
+ "type": type,
44
48
  "attributes": {
45
49
  "fullName": full_name&.represent,
46
50
  "dateOfBirth": date_of_birth,
@@ -53,14 +57,14 @@ module Unit
53
57
  "idempotencyKey": idempotency_key,
54
58
  "tags": tags,
55
59
  "limits": limits,
56
- "printOnlyBusinessName": print_only_business_name
57
- },
60
+ "printOnlyBusinessName": print_only_business_name,
61
+ "expiryDate": expiry_date
62
+ }.compact!,
58
63
  "relationships": {
59
64
  "account": Unit::Types::Relationship.new("account", account_id).to_hash
60
65
  }
61
66
  }
62
67
  }
63
- payload[:data][:attributes].compact!
64
68
  payload.to_json
65
69
  end
66
70
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to create business virtual credit card request
4
+ # @see https://guides.unit.co/business-charge-cards/
5
+ module Unit
6
+ module Card
7
+ # @param account_id [String]
8
+ # @param full_name [FullName]
9
+ # @param date_of_birth [Date]
10
+ # @param address [Address]
11
+ # @param phone [Phone] - optional
12
+ # @param email [String] - optional
13
+ # @param idempotency_key [String] - optional
14
+ # @param tags [Hash] - optional
15
+ # @param limits [Hash] - optional
16
+ # @param expiry_date [String] - optional
17
+ class CreateBusinessVirtualCreditCardRequest < CreateBusinessVirtualDebitCardRequest
18
+ def initialize(account_id, full_name, date_of_birth, address, phone = nil, email = nil,
19
+ idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
20
+ super
21
+ @type = "businessVirtualCreditCard"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -5,7 +5,8 @@
5
5
  module Unit
6
6
  module Card
7
7
  class CreateBusinessVirtualDebitCardRequest
8
- attr_reader :account_id, :full_name, :date_of_birth, :address, :phone, :email, :idempotency_key, :tags, :limits
8
+ attr_reader :account_id, :full_name, :date_of_birth, :address, :phone, :email,
9
+ :idempotency_key, :tags, :limits, :expiry_date, :type
9
10
 
10
11
  # @param account_id [String]
11
12
  # @param full_name [FullName]
@@ -16,8 +17,9 @@ module Unit
16
17
  # @param idempotency_key [String] - optional
17
18
  # @param tags [Hash] - optional
18
19
  # @param limits [Hash] - optional
20
+ # @param expiry_date [String] - optional
19
21
  def initialize(account_id, full_name, date_of_birth, address, phone, email,
20
- idempotency_key, tags, limits)
22
+ idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
21
23
  @account_id = account_id
22
24
  @full_name = full_name
23
25
  @date_of_birth = date_of_birth
@@ -27,12 +29,14 @@ module Unit
27
29
  @idempotency_key = idempotency_key
28
30
  @tags = tags
29
31
  @limits = limits
32
+ @expiry_date = expiry_date
33
+ @type = "businessVirtualDebitCard"
30
34
  end
31
35
 
32
36
  def to_json_api
33
37
  payload = {
34
38
  "data": {
35
- "type": "businessVirtualDebitCard",
39
+ "type": type,
36
40
  "attributes": {
37
41
  "fullName": full_name&.represent,
38
42
  "dateOfBirth": date_of_birth,
@@ -41,14 +45,14 @@ module Unit
41
45
  "email": email,
42
46
  "idempotencyKey": idempotency_key,
43
47
  "tags": tags,
44
- "limits": limits
45
- },
48
+ "limits": limits,
49
+ "expiryDate": expiry_date
50
+ }.compact!,
46
51
  "relationships": {
47
52
  "account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
48
53
  }
49
54
  }
50
55
  }
51
- payload[:data][:attributes].compact!
52
56
  payload.to_json
53
57
  end
54
58
  end
@@ -5,7 +5,8 @@
5
5
  module Unit
6
6
  module Card
7
7
  class CreateIndividualDebitCardRequest
8
- attr_reader :account_id, :customer_id, :shipping_address, :design, :additional_embossed_text, :idempotency_key, :tags, :limits, :print_only_business_name
8
+ attr_reader :account_id, :customer_id, :shipping_address, :design, :additional_embossed_text, :idempotency_key,
9
+ :tags, :limits, :print_only_business_name, :expiry_date
9
10
 
10
11
  # @param account_id [String]
11
12
  # @param customer_id [String] - optional
@@ -16,8 +17,9 @@ module Unit
16
17
  # @param tags [Hash] - optional
17
18
  # @param limits [Hash] - optional
18
19
  # @param print_only_business_name [Boolean] - optional
20
+ # @param expiry_date [String] - optional
19
21
  def initialize(account_id, customer_id = nil, shipping_address = nil, design = nil, additional_embossed_text = nil,
20
- idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil)
22
+ idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil, expiry_date = nil)
21
23
  @account_id = account_id
22
24
  @customer_id = customer_id
23
25
  @shipping_address = shipping_address
@@ -27,6 +29,7 @@ module Unit
27
29
  @tags = tags
28
30
  @limits = limits
29
31
  @print_only_business_name = print_only_business_name
32
+ @expiry_date = expiry_date
30
33
  end
31
34
 
32
35
  def to_json_api
@@ -40,7 +43,8 @@ module Unit
40
43
  "idempotencyKey": idempotency_key,
41
44
  "tags": tags,
42
45
  "limits": limits,
43
- "printOnlyBusinessName": print_only_business_name
46
+ "printOnlyBusinessName": print_only_business_name,
47
+ "expiryDate": expiry_date
44
48
  },
45
49
  "relationships": {
46
50
  "account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
@@ -5,19 +5,21 @@
5
5
  module Unit
6
6
  module Card
7
7
  class CreateIndividualVirtualCardRequest
8
- attr_reader :account_id, :customer_id, :idempotency_key, :tags, :limits
8
+ attr_reader :account_id, :customer_id, :idempotency_key, :tags, :limits, :expiry_date
9
9
 
10
10
  # @param account_id [String]
11
11
  # @param customer_id [String] - optional
12
12
  # @param idempotency_key [String] - optional
13
13
  # @param tags [Hash] - optional
14
14
  # @param limits [Hash] - optional
15
- def initialize(account_id, customer_id = nil, idempotency_key = nil, tags = nil, limits = nil)
15
+ # @param expiry_date [String] - optional
16
+ def initialize(account_id, customer_id = nil, idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
16
17
  @account_id = account_id
17
18
  @customer_id = customer_id
18
19
  @idempotency_key = idempotency_key
19
20
  @tags = tags
20
21
  @limits = limits
22
+ @expiry_date = expiry_date
21
23
  end
22
24
 
23
25
  def to_json_api
@@ -27,7 +29,8 @@ module Unit
27
29
  "attributes": {
28
30
  "idempotencyKey": idempotency_key,
29
31
  "tags": tags,
30
- "limits": limits
32
+ "limits": limits,
33
+ "expiryDate": expiry_date
31
34
  },
32
35
  "relationships": {
33
36
  "account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to create business card request
4
+ # @see https://docs.unit.co/cards/#update-business-debit-card
5
+ module Unit
6
+ module Card
7
+ class PatchBusinessCardRequest
8
+ attr_reader :card_id, :shipping_address, :address, :phone, :email, :design, :tags, :limits, :type
9
+
10
+ # @param card_id [String]
11
+ # @param shipping_address [Address] - optional
12
+ # @param address [Address] - optional
13
+ # @param phone [Phone] - optional
14
+ # @param email [String] - optional
15
+ # @param design [String] - optional
16
+ # @param tags [Hash] - optional
17
+ # @param limits [Hash] - optional
18
+ def initialize(card_id, shipping_address = nil, address = nil, phone = nil, email = nil, design = nil, tags = nil, limits = nil)
19
+ @card_id = card_id
20
+ @shipping_address = shipping_address
21
+ @address = address
22
+ @phone = phone
23
+ @email = email
24
+ @design = design
25
+ @tags = tags
26
+ @limits = limits
27
+ @type = "businessDebitCard"
28
+ end
29
+
30
+ def to_json_api
31
+ payload = {
32
+ "data": {
33
+ "type": type,
34
+ "attributes": {
35
+ "shippingAddress": shipping_address,
36
+ "address": address,
37
+ "phone": phone,
38
+ "email": email,
39
+ "design": design,
40
+ "tags": tags,
41
+ "limits": limits
42
+ }
43
+ }
44
+ }
45
+ payload[:data][:attributes].compact!
46
+ payload.to_json
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to create business credit card request
4
+ # @see https://guides.unit.co/business-charge-cards/
5
+ module Unit
6
+ module Card
7
+ class PatchBusinessCreditCardRequest < PatchBusinessCardRequest
8
+ # @param card_id [String]
9
+ # @param shipping_address [Address] - optional
10
+ # @param address [Address] - optional
11
+ # @param phone [Phone] - optional
12
+ # @param email [String] - optional
13
+ # @param design [String] - optional
14
+ # @param tags [Hash] - optional
15
+ # @param limits [Hash] - optional
16
+ def initialize(card_id, shipping_address = nil, address = nil, phone = nil, email = nil, design = nil, tags = nil, limits = nil)
17
+ super
18
+ @type = "businessCreditCard"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to update a business virtual debit card
4
+ # @see https://docs.unit.co/cards/#update-business-virtual-debit-card
5
+ module Unit
6
+ module Card
7
+ class PatchBusinessVirtualCardRequest
8
+ attr_reader :card_id, :address, :phone, :email, :tags, :limits, :type
9
+
10
+ # @param card_id [String]
11
+ # @param address [Address] - optional
12
+ # @param phone [Phone] - optional
13
+ # @param email [String] - optional
14
+ # @param tags [Hash] - optional
15
+ # @param limits [Hash] - optional
16
+ def initialize(card_id, address = nil, phone = nil, email = nil, tags = nil, limits = nil)
17
+ @card_id = card_id
18
+ @address = address
19
+ @phone = phone
20
+ @email = email
21
+ @tags = tags
22
+ @limits = limits
23
+ @type = "businessVirtualDebitCard"
24
+ end
25
+
26
+ def to_json_api
27
+ payload = {
28
+ "data": {
29
+ "type": type,
30
+ "attributes": {
31
+ "address": address,
32
+ "phone": phone,
33
+ "email": email,
34
+ "tags": tags,
35
+ "limits": limits
36
+ }.compact
37
+ }
38
+ }
39
+ payload.to_json
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to update a business virtual credit card
4
+ # @see https://guides.unit.co/business-charge-cards/
5
+ module Unit
6
+ module Card
7
+ class PatchBusinessVirtualCreditCardRequest < PatchBusinessVirtualCardRequest
8
+ # @param card_id [String]
9
+ # @param address [Address] - optional
10
+ # @param phone [Phone] - optional
11
+ # @param email [String] - optional
12
+ # @param tags [Hash] - optional
13
+ # @param limits [Hash] - optional
14
+ def initialize(card_id, address = nil, phone = nil, email = nil, tags = nil, limits = nil)
15
+ super
16
+ @type = "businessVirtualCreditCard"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -12,7 +12,7 @@ module Unit
12
12
  # @param query [String] - optional
13
13
  # @param email [String] - optional
14
14
  # @param tags [Hash] - optional
15
- # @param status [String] - optional
15
+ # @param status [Array<String>] - optional
16
16
  # @param sort [String] - optional
17
17
  def initialize(limit = CUSTOMER_LIST_LIMIT, offset = CUSTOMER_LIST_OFFSET, query = nil, email = nil, tags = nil, status = nil,
18
18
  sort = nil)
@@ -31,8 +31,10 @@ module Unit
31
31
  "filter[query]": query,
32
32
  "filter[email]": email,
33
33
  "filter[tags]": tags,
34
- "filter[status]": status,
35
34
  "sort": sort }
35
+ status&.each_with_index&.map do |val, index|
36
+ params.merge!({ "filter[status][#{index}]": val })
37
+ end
36
38
  params.compact
37
39
  end
38
40
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unit
4
+ module Event
5
+ EVENT_LIST_LIMIT = 100
6
+ EVENT_LIST_OFFSET = 0
7
+
8
+ autoload :ListEventParams, "unit/models/event/list_event_params"
9
+ class << self
10
+ # Get event by id
11
+ # @see https://docs.unit.co/events#get-event
12
+ # @param event_id [String]
13
+ def get_event(event_id:)
14
+ Unit::Resource::EventResource.get(event_id)
15
+ end
16
+
17
+ # List events
18
+ # @see https://docs.unit.co/events#list-events
19
+ # @param limit [Integer]
20
+ # @param offset [Integer]
21
+ # @param type [Array<String>] - optional
22
+ # @param since [String] - optional
23
+ # @param _until [String] - optional
24
+ def list_events(limit: EVENT_LIST_LIMIT, offset: EVENT_LIST_OFFSET, type: nil, since: nil, _until: nil)
25
+ params = ListEventParams.new(limit, offset, type, since, _until)
26
+ Unit::Resource::EventResource.list(params)
27
+ end
28
+
29
+ # Fire event
30
+ # @see https://docs.unit.co/events#fire-event
31
+ # @param event_id [String]
32
+ def fire_event(event_id:)
33
+ Unit::Resource::EventResource.fire(event_id)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # params for listing events
4
+ # https://docs.unit.co/events#list-events
5
+ module Unit
6
+ module Event
7
+ class ListEventParams
8
+ attr_reader :limit, :offset, :type, :since, :_until
9
+
10
+ # @param limit [Integer]
11
+ # @param offset [Integer]
12
+ # @param type [Array<String>] - optional
13
+ # @param since [String] - optional
14
+ # @param _until [String] - optional
15
+ def initialize(limit = EVENT_LIST_LIMIT, offset = EVENT_LIST_OFFSET, type = nil, since = nil, _until = nil)
16
+ @limit = limit
17
+ @offset = offset
18
+ @type = type
19
+ @since = since
20
+ @_until = _until
21
+ end
22
+
23
+ def to_hash
24
+ params = {
25
+ "page[limit]": limit,
26
+ "page[offset]": offset,
27
+ "filter[since]": since,
28
+ "filter[until]": _until
29
+ }
30
+ type&.each_with_index&.map do |val, index|
31
+ params.merge!({ "filter[type][#{index}]": val })
32
+ end
33
+ params.compact
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to create fee
4
+ # @see https://docs.unit.co/fees/#create-fee
5
+ module Unit
6
+ module Fee
7
+ class CreateFeeRequest
8
+ attr_reader :account_id, :amount, :description, :tags, :idempotency_key
9
+
10
+ # @param account_id [String]
11
+ # @param amount [Integer]
12
+ # @param description [String]
13
+ # @param tags [Hash] - optional
14
+ # @param idempotency_key [String] - optional
15
+ def initialize(account_id, amount, description, tags = nil, idempotency_key = nil)
16
+ @account_id = account_id
17
+ @amount = amount
18
+ @description = description
19
+ @tags = tags
20
+ @idempotency_key = idempotency_key
21
+ end
22
+
23
+ def to_json_api
24
+ payload = {
25
+ "data": {
26
+ "type": "fee",
27
+ "attributes": {
28
+ "amount": amount,
29
+ "description": description,
30
+ "tags": tags,
31
+ "idempotencyKey": idempotency_key
32
+ },
33
+ "relationships": {
34
+ "account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
35
+ }
36
+ }
37
+ }
38
+ payload[:data][:attributes].compact!
39
+ payload.to_json
40
+ end
41
+ end
42
+ end
43
+ end