lago-ruby-client 1.40.0 → 1.43.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.
- checksums.yaml +4 -4
- data/lib/lago/api/client.rb +5 -0
- data/lib/lago/api/resources/customers/payment_method.rb +36 -0
- data/lib/lago/api/resources/invoice.rb +14 -2
- data/lib/lago/api/resources/plan.rb +182 -0
- data/lib/lago/api/resources/subscription.rb +174 -20
- data/lib/lago/api/resources/wallet.rb +13 -0
- data/lib/lago/api/resources/wallet_transaction.rb +21 -12
- data/lib/lago/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cd4e9ed7d1b0f3eac5940fb37ea3b7b2616ceda00c5e3e4e42e0e80b0d0b3ba
|
|
4
|
+
data.tar.gz: 761ed874e1fb31e466ae0a5309132853ded262940f0504fcb6dc827a3af05c87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21a3cb1cd0b107edb3ac23e4a08738dd4c9f6ae96a8dee6ed07267a72b48cafdeb5d580afc631519961974c761dc44da151358ad9e3951f88c8a8f42e57f7c65
|
|
7
|
+
data.tar.gz: 87d47fc5d9f9039ca63975f697b30f1300314bc2448967e180944c1e68c0fc8576f8ddef53055e8c092cd0f28581fad43640ffeac638f3dcc3c6ca2f79f8d13d
|
data/lib/lago/api/client.rb
CHANGED
|
@@ -15,6 +15,7 @@ require 'lago/api/resources/customers/applied_coupon'
|
|
|
15
15
|
require 'lago/api/resources/customers/credit_note'
|
|
16
16
|
require 'lago/api/resources/customers/invoice'
|
|
17
17
|
require 'lago/api/resources/customers/payment'
|
|
18
|
+
require 'lago/api/resources/customers/payment_method'
|
|
18
19
|
require 'lago/api/resources/customers/payment_request'
|
|
19
20
|
require 'lago/api/resources/customers/subscription'
|
|
20
21
|
require 'lago/api/resources/customers/wallet'
|
|
@@ -122,6 +123,10 @@ module Lago
|
|
|
122
123
|
Resources::Customers::Payment.new(self, resource_id)
|
|
123
124
|
end
|
|
124
125
|
|
|
126
|
+
def customer_payment_methods(resource_id)
|
|
127
|
+
Resources::Customers::PaymentMethod.new(self, resource_id)
|
|
128
|
+
end
|
|
129
|
+
|
|
125
130
|
def customer_payment_requests(resource_id)
|
|
126
131
|
Resources::Customers::PaymentRequest.new(self, resource_id)
|
|
127
132
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'lago/api/resources/customers/base'
|
|
4
|
+
|
|
5
|
+
module Lago
|
|
6
|
+
module Api
|
|
7
|
+
module Resources
|
|
8
|
+
module Customers
|
|
9
|
+
class PaymentMethod < Base
|
|
10
|
+
def api_resource
|
|
11
|
+
"#{base_api_resource}/payment_methods"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def root_name
|
|
15
|
+
'payment_method'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def destroy(id, options: nil)
|
|
19
|
+
response = connection.destroy(identifier: id, options:)[root_name]
|
|
20
|
+
|
|
21
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# rubocop:disable Naming/AccessorMethodName
|
|
25
|
+
def set_as_default(payment_method_id)
|
|
26
|
+
path = "/api/v1/#{api_resource}/#{payment_method_id}/set_as_default"
|
|
27
|
+
response = connection.put(path, identifier: nil, body: {})[root_name]
|
|
28
|
+
|
|
29
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
30
|
+
end
|
|
31
|
+
# rubocop:enable Naming/AccessorMethodName
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -59,9 +59,12 @@ module Lago
|
|
|
59
59
|
JSON.parse(response.to_json, object_class: OpenStruct).invoice
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
def retry_payment(invoice_id)
|
|
62
|
+
def retry_payment(invoice_id, params = {})
|
|
63
63
|
path = "/api/v1/invoices/#{invoice_id}/retry_payment"
|
|
64
|
-
|
|
64
|
+
payment_method_params = whitelist_payment_method_params(params[:payment_method])
|
|
65
|
+
payload = { payment_method: payment_method_params }.compact
|
|
66
|
+
|
|
67
|
+
response = connection.post(payload, path)
|
|
65
68
|
|
|
66
69
|
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
67
70
|
end
|
|
@@ -128,6 +131,9 @@ module Lago
|
|
|
128
131
|
fees = whitelist_fees(params[:fees])
|
|
129
132
|
result[:fees] = fees unless fees.empty?
|
|
130
133
|
|
|
134
|
+
payment_method_params = whitelist_payment_method_params(params[:payment_method])
|
|
135
|
+
result[:payment_method] = payment_method_params if payment_method_params.present?
|
|
136
|
+
|
|
131
137
|
{ root_name => result }
|
|
132
138
|
end
|
|
133
139
|
|
|
@@ -161,6 +167,12 @@ module Lago
|
|
|
161
167
|
credit_amount: params[:credit_amount]
|
|
162
168
|
}.compact
|
|
163
169
|
end
|
|
170
|
+
|
|
171
|
+
private
|
|
172
|
+
|
|
173
|
+
def whitelist_payment_method_params(payment_method_param)
|
|
174
|
+
payment_method_param&.slice(:payment_method_type, :payment_method_id)
|
|
175
|
+
end
|
|
164
176
|
end
|
|
165
177
|
end
|
|
166
178
|
end
|
|
@@ -54,6 +54,117 @@ module Lago
|
|
|
54
54
|
JSON.parse(response.to_json, object_class: OpenStruct).entitlement
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
# Charges
|
|
58
|
+
def get_all_charges(plan_code, options = {})
|
|
59
|
+
response = connection.get_all(options, charges_uri(plan_code))
|
|
60
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def get_charge(plan_code, charge_code)
|
|
64
|
+
response = connection.get(charges_uri(plan_code, charge_code), identifier: nil)
|
|
65
|
+
JSON.parse(response.to_json, object_class: OpenStruct).charge
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def create_charge(plan_code, params)
|
|
69
|
+
response = connection.post(
|
|
70
|
+
whitelist_charge_params(params),
|
|
71
|
+
charges_uri(plan_code),
|
|
72
|
+
)
|
|
73
|
+
JSON.parse(response.to_json, object_class: OpenStruct).charge
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def update_charge(plan_code, charge_code, params)
|
|
77
|
+
response = connection.put(
|
|
78
|
+
charges_uri(plan_code, charge_code),
|
|
79
|
+
identifier: nil,
|
|
80
|
+
body: whitelist_charge_params(params),
|
|
81
|
+
)
|
|
82
|
+
JSON.parse(response.to_json, object_class: OpenStruct).charge
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def destroy_charge(plan_code, charge_code, params = {})
|
|
86
|
+
response = connection.destroy(
|
|
87
|
+
charges_uri(plan_code, charge_code),
|
|
88
|
+
identifier: nil,
|
|
89
|
+
options: params.empty? ? nil : params,
|
|
90
|
+
)
|
|
91
|
+
JSON.parse(response.to_json, object_class: OpenStruct).charge
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Fixed Charges
|
|
95
|
+
def get_all_fixed_charges(plan_code, options = {})
|
|
96
|
+
response = connection.get_all(options, fixed_charges_uri(plan_code))
|
|
97
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def get_fixed_charge(plan_code, fixed_charge_code)
|
|
101
|
+
response = connection.get(fixed_charges_uri(plan_code, fixed_charge_code), identifier: nil)
|
|
102
|
+
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charge
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def create_fixed_charge(plan_code, params)
|
|
106
|
+
response = connection.post(
|
|
107
|
+
whitelist_fixed_charge_params(params),
|
|
108
|
+
fixed_charges_uri(plan_code),
|
|
109
|
+
)
|
|
110
|
+
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charge
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def update_fixed_charge(plan_code, fixed_charge_code, params)
|
|
114
|
+
response = connection.put(
|
|
115
|
+
fixed_charges_uri(plan_code, fixed_charge_code),
|
|
116
|
+
identifier: nil,
|
|
117
|
+
body: whitelist_fixed_charge_params(params),
|
|
118
|
+
)
|
|
119
|
+
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charge
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def destroy_fixed_charge(plan_code, fixed_charge_code, params = {})
|
|
123
|
+
response = connection.destroy(
|
|
124
|
+
fixed_charges_uri(plan_code, fixed_charge_code),
|
|
125
|
+
identifier: nil,
|
|
126
|
+
options: params.empty? ? nil : params,
|
|
127
|
+
)
|
|
128
|
+
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charge
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Charge Filters
|
|
132
|
+
def get_all_charge_filters(plan_code, charge_code, options = {})
|
|
133
|
+
response = connection.get_all(options, charge_filters_uri(plan_code, charge_code))
|
|
134
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def get_charge_filter(plan_code, charge_code, filter_id)
|
|
138
|
+
response = connection.get(charge_filters_uri(plan_code, charge_code, filter_id), identifier: nil)
|
|
139
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def create_charge_filter(plan_code, charge_code, params)
|
|
143
|
+
response = connection.post(
|
|
144
|
+
whitelist_charge_filter_params(params),
|
|
145
|
+
charge_filters_uri(plan_code, charge_code),
|
|
146
|
+
)
|
|
147
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def update_charge_filter(plan_code, charge_code, filter_id, params)
|
|
151
|
+
response = connection.put(
|
|
152
|
+
charge_filters_uri(plan_code, charge_code, filter_id),
|
|
153
|
+
identifier: nil,
|
|
154
|
+
body: whitelist_charge_filter_params(params),
|
|
155
|
+
)
|
|
156
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def destroy_charge_filter(plan_code, charge_code, filter_id, params = {})
|
|
160
|
+
response = connection.destroy(
|
|
161
|
+
charge_filters_uri(plan_code, charge_code, filter_id),
|
|
162
|
+
identifier: nil,
|
|
163
|
+
options: params.empty? ? nil : params,
|
|
164
|
+
)
|
|
165
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
166
|
+
end
|
|
167
|
+
|
|
57
168
|
def whitelist_params(params)
|
|
58
169
|
result_hash = {
|
|
59
170
|
name: params[:name],
|
|
@@ -119,6 +230,7 @@ module Lago
|
|
|
119
230
|
:filters,
|
|
120
231
|
:tax_codes,
|
|
121
232
|
:applied_pricing_unit,
|
|
233
|
+
:accepts_target_wallet,
|
|
122
234
|
)
|
|
123
235
|
|
|
124
236
|
processed_charges << result unless result.empty?
|
|
@@ -216,6 +328,76 @@ module Lago
|
|
|
216
328
|
url += "/#{action}" if action
|
|
217
329
|
URI(url)
|
|
218
330
|
end
|
|
331
|
+
|
|
332
|
+
def charges_uri(plan_code, charge_code = nil)
|
|
333
|
+
url = "#{client.base_api_url}#{api_resource}/#{plan_code}/charges"
|
|
334
|
+
url += "/#{charge_code}" if charge_code
|
|
335
|
+
URI(url)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def fixed_charges_uri(plan_code, fixed_charge_code = nil)
|
|
339
|
+
url = "#{client.base_api_url}#{api_resource}/#{plan_code}/fixed_charges"
|
|
340
|
+
url += "/#{fixed_charge_code}" if fixed_charge_code
|
|
341
|
+
URI(url)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def charge_filters_uri(plan_code, charge_code, filter_id = nil)
|
|
345
|
+
url = "#{client.base_api_url}#{api_resource}/#{plan_code}/charges/#{charge_code}/filters"
|
|
346
|
+
url += "/#{filter_id}" if filter_id
|
|
347
|
+
URI(url)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def whitelist_charge_params(params)
|
|
351
|
+
{
|
|
352
|
+
charge: (params || {}).slice(
|
|
353
|
+
:billable_metric_id,
|
|
354
|
+
:code,
|
|
355
|
+
:invoice_display_name,
|
|
356
|
+
:charge_model,
|
|
357
|
+
:pay_in_advance,
|
|
358
|
+
:prorated,
|
|
359
|
+
:invoiceable,
|
|
360
|
+
:regroup_paid_fees,
|
|
361
|
+
:min_amount_cents,
|
|
362
|
+
:accepts_target_wallet,
|
|
363
|
+
:properties,
|
|
364
|
+
:filters,
|
|
365
|
+
:tax_codes,
|
|
366
|
+
:applied_pricing_unit,
|
|
367
|
+
:cascade_updates,
|
|
368
|
+
),
|
|
369
|
+
}
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
def whitelist_fixed_charge_params(params)
|
|
373
|
+
{
|
|
374
|
+
fixed_charge: (params || {}).slice(
|
|
375
|
+
:add_on_id,
|
|
376
|
+
:add_on_code,
|
|
377
|
+
:code,
|
|
378
|
+
:invoice_display_name,
|
|
379
|
+
:charge_model,
|
|
380
|
+
:pay_in_advance,
|
|
381
|
+
:prorated,
|
|
382
|
+
:units,
|
|
383
|
+
:apply_units_immediately,
|
|
384
|
+
:properties,
|
|
385
|
+
:tax_codes,
|
|
386
|
+
:cascade_updates,
|
|
387
|
+
),
|
|
388
|
+
}
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
def whitelist_charge_filter_params(params)
|
|
392
|
+
{
|
|
393
|
+
filter: (params || {}).slice(
|
|
394
|
+
:invoice_display_name,
|
|
395
|
+
:properties,
|
|
396
|
+
:values,
|
|
397
|
+
:cascade_updates,
|
|
398
|
+
),
|
|
399
|
+
}
|
|
400
|
+
end
|
|
219
401
|
end
|
|
220
402
|
end
|
|
221
403
|
end
|
|
@@ -86,14 +86,6 @@ module Lago
|
|
|
86
86
|
JSON.parse(response.to_json, object_class: OpenStruct).alerts
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
def fixed_charges(external_subscription_id)
|
|
90
|
-
uri = URI(
|
|
91
|
-
"#{client.base_api_url}#{api_resource}/#{external_subscription_id}/fixed_charges",
|
|
92
|
-
)
|
|
93
|
-
response = connection.get(uri, identifier: nil)
|
|
94
|
-
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charges
|
|
95
|
-
end
|
|
96
|
-
|
|
97
89
|
def create_alert(external_subscription_id, params)
|
|
98
90
|
response = connection.post(
|
|
99
91
|
whitelist_alert_create_params(params),
|
|
@@ -102,19 +94,110 @@ module Lago
|
|
|
102
94
|
JSON.parse(response.to_json, object_class: OpenStruct).alert
|
|
103
95
|
end
|
|
104
96
|
|
|
97
|
+
def create_alerts(external_subscription_id, params)
|
|
98
|
+
response = connection.post(
|
|
99
|
+
whitelist_alert_batch_create_params(params),
|
|
100
|
+
alert_uri(external_subscription_id),
|
|
101
|
+
)
|
|
102
|
+
JSON.parse(response.to_json, object_class: OpenStruct).alerts
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def delete_alerts(external_subscription_id)
|
|
106
|
+
connection.destroy(alert_uri(external_subscription_id), identifier: nil)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Charges
|
|
110
|
+
def get_all_charges(external_id, options = {})
|
|
111
|
+
response = connection.get_all(options, charges_uri(external_id))
|
|
112
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def get_charge(external_id, charge_code)
|
|
116
|
+
response = connection.get(charges_uri(external_id, charge_code), identifier: nil)
|
|
117
|
+
JSON.parse(response.to_json, object_class: OpenStruct).charge
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def update_charge(external_id, charge_code, params)
|
|
121
|
+
response = connection.put(
|
|
122
|
+
charges_uri(external_id, charge_code),
|
|
123
|
+
identifier: nil,
|
|
124
|
+
body: whitelist_subscription_charge_params(params),
|
|
125
|
+
)
|
|
126
|
+
JSON.parse(response.to_json, object_class: OpenStruct).charge
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Fixed Charges
|
|
130
|
+
def get_all_fixed_charges(external_id, options = {})
|
|
131
|
+
response = connection.get_all(options, fixed_charges_uri(external_id))
|
|
132
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def get_fixed_charge(external_id, fixed_charge_code)
|
|
136
|
+
response = connection.get(fixed_charges_uri(external_id, fixed_charge_code), identifier: nil)
|
|
137
|
+
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charge
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def update_fixed_charge(external_id, fixed_charge_code, params)
|
|
141
|
+
response = connection.put(
|
|
142
|
+
fixed_charges_uri(external_id, fixed_charge_code),
|
|
143
|
+
identifier: nil,
|
|
144
|
+
body: whitelist_subscription_fixed_charge_params(params),
|
|
145
|
+
)
|
|
146
|
+
JSON.parse(response.to_json, object_class: OpenStruct).fixed_charge
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Charge Filters
|
|
150
|
+
def get_all_charge_filters(external_id, charge_code, options = {})
|
|
151
|
+
response = connection.get_all(options, charge_filters_uri(external_id, charge_code))
|
|
152
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def get_charge_filter(external_id, charge_code, filter_id)
|
|
156
|
+
response = connection.get(charge_filters_uri(external_id, charge_code, filter_id), identifier: nil)
|
|
157
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def create_charge_filter(external_id, charge_code, params)
|
|
161
|
+
response = connection.post(
|
|
162
|
+
whitelist_subscription_charge_filter_params(params),
|
|
163
|
+
charge_filters_uri(external_id, charge_code),
|
|
164
|
+
)
|
|
165
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def update_charge_filter(external_id, charge_code, filter_id, params)
|
|
169
|
+
response = connection.put(
|
|
170
|
+
charge_filters_uri(external_id, charge_code, filter_id),
|
|
171
|
+
identifier: nil,
|
|
172
|
+
body: whitelist_subscription_charge_filter_params(params),
|
|
173
|
+
)
|
|
174
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def destroy_charge_filter(external_id, charge_code, filter_id)
|
|
178
|
+
response = connection.destroy(
|
|
179
|
+
charge_filters_uri(external_id, charge_code, filter_id),
|
|
180
|
+
identifier: nil,
|
|
181
|
+
)
|
|
182
|
+
JSON.parse(response.to_json, object_class: OpenStruct).filter
|
|
183
|
+
end
|
|
184
|
+
|
|
105
185
|
def whitelist_params(params)
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
186
|
+
result = {
|
|
187
|
+
external_customer_id: params[:external_customer_id],
|
|
188
|
+
plan_code: params[:plan_code],
|
|
189
|
+
name: params[:name],
|
|
190
|
+
external_id: params[:external_id],
|
|
191
|
+
billing_time: params[:billing_time],
|
|
192
|
+
subscription_at: params[:subscription_at],
|
|
193
|
+
ending_at: params[:ending_at],
|
|
194
|
+
plan_overrides: params[:plan_overrides],
|
|
195
|
+
}.compact
|
|
196
|
+
|
|
197
|
+
payment_method_params = whitelist_payment_method_params(params[:payment_method])
|
|
198
|
+
result[:payment_method] = payment_method_params if payment_method_params.present?
|
|
199
|
+
|
|
200
|
+
{ root_name => result }
|
|
118
201
|
end
|
|
119
202
|
|
|
120
203
|
def whitelist_lifetime_usage_params(params)
|
|
@@ -137,6 +220,20 @@ module Lago
|
|
|
137
220
|
}
|
|
138
221
|
end
|
|
139
222
|
|
|
223
|
+
def whitelist_alert_batch_create_params(params)
|
|
224
|
+
{
|
|
225
|
+
alerts: (params[:alerts] || []).map do |alert|
|
|
226
|
+
{
|
|
227
|
+
alert_type: alert[:alert_type],
|
|
228
|
+
name: alert[:name],
|
|
229
|
+
code: alert[:code],
|
|
230
|
+
billable_metric_code: alert[:billable_metric_code],
|
|
231
|
+
thresholds: alert[:thresholds],
|
|
232
|
+
}.compact
|
|
233
|
+
end,
|
|
234
|
+
}
|
|
235
|
+
end
|
|
236
|
+
|
|
140
237
|
def whitelist_alert_update_params(params)
|
|
141
238
|
{
|
|
142
239
|
alert: {
|
|
@@ -162,6 +259,10 @@ module Lago
|
|
|
162
259
|
|
|
163
260
|
private
|
|
164
261
|
|
|
262
|
+
def whitelist_payment_method_params(payment_method_param)
|
|
263
|
+
payment_method_param&.slice(:payment_method_type, :payment_method_id)
|
|
264
|
+
end
|
|
265
|
+
|
|
165
266
|
def entitlements_uri(external_subscription_id, feature_code = nil, action = nil)
|
|
166
267
|
url = "#{client.base_api_url}#{api_resource}/#{external_subscription_id}/entitlements"
|
|
167
268
|
url += "/#{feature_code}" if feature_code
|
|
@@ -172,6 +273,59 @@ module Lago
|
|
|
172
273
|
def alert_uri(external_subscription_id, code = nil)
|
|
173
274
|
URI("#{client.base_api_url}#{api_resource}/#{external_subscription_id}/alerts#{code ? "/#{code}" : ''}")
|
|
174
275
|
end
|
|
276
|
+
|
|
277
|
+
def charges_uri(external_id, charge_code = nil)
|
|
278
|
+
url = "#{client.base_api_url}#{api_resource}/#{external_id}/charges"
|
|
279
|
+
url += "/#{charge_code}" if charge_code
|
|
280
|
+
URI(url)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def fixed_charges_uri(external_id, fixed_charge_code = nil)
|
|
284
|
+
url = "#{client.base_api_url}#{api_resource}/#{external_id}/fixed_charges"
|
|
285
|
+
url += "/#{fixed_charge_code}" if fixed_charge_code
|
|
286
|
+
URI(url)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def charge_filters_uri(external_id, charge_code, filter_id = nil)
|
|
290
|
+
url = "#{client.base_api_url}#{api_resource}/#{external_id}/charges/#{charge_code}/filters"
|
|
291
|
+
url += "/#{filter_id}" if filter_id
|
|
292
|
+
URI(url)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def whitelist_subscription_charge_params(params)
|
|
296
|
+
{
|
|
297
|
+
charge: (params || {}).slice(
|
|
298
|
+
:invoice_display_name,
|
|
299
|
+
:min_amount_cents,
|
|
300
|
+
:properties,
|
|
301
|
+
:filters,
|
|
302
|
+
:tax_codes,
|
|
303
|
+
:applied_pricing_unit,
|
|
304
|
+
),
|
|
305
|
+
}
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def whitelist_subscription_fixed_charge_params(params)
|
|
309
|
+
{
|
|
310
|
+
fixed_charge: (params || {}).slice(
|
|
311
|
+
:invoice_display_name,
|
|
312
|
+
:units,
|
|
313
|
+
:apply_units_immediately,
|
|
314
|
+
:properties,
|
|
315
|
+
:tax_codes,
|
|
316
|
+
),
|
|
317
|
+
}
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def whitelist_subscription_charge_filter_params(params)
|
|
321
|
+
{
|
|
322
|
+
filter: (params || {}).slice(
|
|
323
|
+
:invoice_display_name,
|
|
324
|
+
:properties,
|
|
325
|
+
:values,
|
|
326
|
+
),
|
|
327
|
+
}
|
|
328
|
+
end
|
|
175
329
|
end
|
|
176
330
|
end
|
|
177
331
|
end
|
|
@@ -19,6 +19,7 @@ module Lago
|
|
|
19
19
|
:external_customer_id,
|
|
20
20
|
:rate_amount,
|
|
21
21
|
:name,
|
|
22
|
+
:code,
|
|
22
23
|
:priority,
|
|
23
24
|
:paid_credits,
|
|
24
25
|
:granted_credits,
|
|
@@ -41,6 +42,9 @@ module Lago
|
|
|
41
42
|
metadata = whitelist_metadata(params[:metadata])
|
|
42
43
|
result_hash[:metadata] = metadata if metadata
|
|
43
44
|
|
|
45
|
+
payment_method_params = whitelist_payment_method_params(params[:payment_method])
|
|
46
|
+
result_hash[:payment_method] = payment_method_params if payment_method_params.present?
|
|
47
|
+
|
|
44
48
|
{ root_name => result_hash }
|
|
45
49
|
end
|
|
46
50
|
|
|
@@ -65,6 +69,9 @@ module Lago
|
|
|
65
69
|
:ignore_paid_top_up_limits
|
|
66
70
|
)
|
|
67
71
|
|
|
72
|
+
payment_method_params = whitelist_payment_method_params(r[:payment_method])
|
|
73
|
+
result[:payment_method] = payment_method_params if payment_method_params.present?
|
|
74
|
+
|
|
68
75
|
processed_rules << result unless result.empty?
|
|
69
76
|
end
|
|
70
77
|
|
|
@@ -108,6 +115,12 @@ module Lago
|
|
|
108
115
|
|
|
109
116
|
response['metadata']
|
|
110
117
|
end
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
def whitelist_payment_method_params(payment_method_param)
|
|
122
|
+
payment_method_param&.slice(:payment_method_type, :payment_method_id)
|
|
123
|
+
end
|
|
111
124
|
end
|
|
112
125
|
end
|
|
113
126
|
end
|
|
@@ -29,18 +29,27 @@ module Lago
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def whitelist_params(params)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
result = params.compact.slice(
|
|
33
|
+
:wallet_id,
|
|
34
|
+
:name,
|
|
35
|
+
:paid_credits,
|
|
36
|
+
:granted_credits,
|
|
37
|
+
:voided_credits,
|
|
38
|
+
:invoice_requires_successful_payment,
|
|
39
|
+
:ignore_paid_top_up_limits,
|
|
40
|
+
:metadata,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
payment_method_params = whitelist_payment_method_params(params[:payment_method])
|
|
44
|
+
result[:payment_method] = payment_method_params if payment_method_params.present?
|
|
45
|
+
|
|
46
|
+
{ 'wallet_transaction' => result }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def whitelist_payment_method_params(payment_method_param)
|
|
52
|
+
payment_method_param&.slice(:payment_method_type, :payment_method_id)
|
|
44
53
|
end
|
|
45
54
|
end
|
|
46
55
|
end
|
data/lib/lago/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lago-ruby-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.43.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lovro Colic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-02-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jwt
|
|
@@ -302,6 +302,7 @@ files:
|
|
|
302
302
|
- lib/lago/api/resources/customers/credit_note.rb
|
|
303
303
|
- lib/lago/api/resources/customers/invoice.rb
|
|
304
304
|
- lib/lago/api/resources/customers/payment.rb
|
|
305
|
+
- lib/lago/api/resources/customers/payment_method.rb
|
|
305
306
|
- lib/lago/api/resources/customers/payment_request.rb
|
|
306
307
|
- lib/lago/api/resources/customers/subscription.rb
|
|
307
308
|
- lib/lago/api/resources/customers/wallet.rb
|