lago-ruby-client 0.31.0.pre.beta → 0.33.0.pre.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lago/api/client.rb +8 -0
- data/lib/lago/api/resources/applied_tax_rate.rb +40 -0
- data/lib/lago/api/resources/credit_note.rb +2 -0
- data/lib/lago/api/resources/invoice.rb +33 -0
- data/lib/lago/api/resources/subscription.rb +2 -1
- data/lib/lago/api/resources/tax_rate.rb +29 -0
- data/lib/lago/api/resources/wallet.rb +1 -0
- data/lib/lago/version.rb +1 -1
- data/lib/lago-ruby-client.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a2d26e098a96ed560b8580c884b1cbd55ea2143751692f6a66bc1478319a7d
|
4
|
+
data.tar.gz: 569e11dd032057aa3251bfa362059bf498e3fe1a84510cde5abe8750c0e75a60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2499ea51611d00912d6bc1ad70631946ccbd38ec948faf71dcc9edb92ab0d58e17ed3519878df70bb1973f5df265332847a9e5ec3f0bd06c224c0c57ae474a3d
|
7
|
+
data.tar.gz: 6b511afdc35d5cc1edffbb739783a1026e3d0593baa54e3fc08b12bc122eb870085bb3ab17910a91f555548c920f7237f562aefada8a932fdfa653e703972bc1
|
data/lib/lago/api/client.rb
CHANGED
@@ -51,6 +51,10 @@ module Lago
|
|
51
51
|
Lago::Api::Resources::AppliedAddOn.new(self)
|
52
52
|
end
|
53
53
|
|
54
|
+
def applied_tax_rates
|
55
|
+
Lago::Api::Resources::AppliedTaxRate.new(self)
|
56
|
+
end
|
57
|
+
|
54
58
|
def billable_metrics
|
55
59
|
Lago::Api::Resources::BillableMetric.new(self)
|
56
60
|
end
|
@@ -75,6 +79,10 @@ module Lago
|
|
75
79
|
Lago::Api::Resources::Organization.new(self)
|
76
80
|
end
|
77
81
|
|
82
|
+
def tax_rates
|
83
|
+
Lago::Api::Resources::TaxRate.new(self)
|
84
|
+
end
|
85
|
+
|
78
86
|
def wallets
|
79
87
|
Lago::Api::Resources::Wallet.new(self)
|
80
88
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lago
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class AppliedTaxRate < Base
|
7
|
+
def api_resource
|
8
|
+
'applied_tax_rates'
|
9
|
+
end
|
10
|
+
|
11
|
+
def root_name
|
12
|
+
'applied_tax_rate'
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(external_customer_id, params)
|
16
|
+
path = "/api/v1/customers/#{external_customer_id}/applied_tax_rates"
|
17
|
+
payload = whitelist_params(params)
|
18
|
+
response = connection.post(payload, path)[root_name]
|
19
|
+
|
20
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy(external_customer_id, tax_rate_code)
|
24
|
+
path = "/api/v1/customers/#{external_customer_id}/applied_tax_rates"
|
25
|
+
response = connection.destroy(path, identifier: tax_rate_code)[root_name]
|
26
|
+
|
27
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
28
|
+
end
|
29
|
+
|
30
|
+
def whitelist_params(params)
|
31
|
+
{
|
32
|
+
root_name => {
|
33
|
+
tax_rate_code: params[:tax_rate_code],
|
34
|
+
}.compact
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -12,10 +12,19 @@ module Lago
|
|
12
12
|
'invoice'
|
13
13
|
end
|
14
14
|
|
15
|
+
def create(params)
|
16
|
+
payload = one_off_params(params)
|
17
|
+
response = connection.post(payload)[root_name]
|
18
|
+
|
19
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
20
|
+
end
|
21
|
+
|
15
22
|
def download(invoice_id)
|
16
23
|
path = "/api/v1/invoices/#{invoice_id}/download"
|
17
24
|
response = connection.post({}, path)
|
18
25
|
|
26
|
+
return response unless response.is_a?(Hash)
|
27
|
+
|
19
28
|
JSON.parse(response.to_json, object_class: OpenStruct).invoice
|
20
29
|
end
|
21
30
|
|
@@ -62,6 +71,30 @@ module Lago
|
|
62
71
|
|
63
72
|
processed_metadata
|
64
73
|
end
|
74
|
+
|
75
|
+
def one_off_params(params)
|
76
|
+
result = {
|
77
|
+
external_customer_id: params[:external_customer_id],
|
78
|
+
currency: params[:currency],
|
79
|
+
}
|
80
|
+
|
81
|
+
fees = whitelist_fees(params[:fees])
|
82
|
+
result[:fees] = fees unless fees.empty?
|
83
|
+
|
84
|
+
{ root_name => result }
|
85
|
+
end
|
86
|
+
|
87
|
+
def whitelist_fees(fees)
|
88
|
+
processed_fees = []
|
89
|
+
|
90
|
+
fees.each do |f|
|
91
|
+
result = (f || {}).slice(:add_on_code, :unit_amount_cents, :units, :description)
|
92
|
+
|
93
|
+
processed_fees << result unless result.empty?
|
94
|
+
end
|
95
|
+
|
96
|
+
processed_fees
|
97
|
+
end
|
65
98
|
end
|
66
99
|
end
|
67
100
|
end
|
@@ -20,7 +20,8 @@ module Lago
|
|
20
20
|
name: params[:name],
|
21
21
|
external_id: params[:external_id],
|
22
22
|
billing_time: params[:billing_time],
|
23
|
-
|
23
|
+
subscription_at: params[:subscription_at],
|
24
|
+
subscription_date: params[:subscription_date], # Deprecated
|
24
25
|
}.compact
|
25
26
|
}
|
26
27
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lago
|
4
|
+
module Api
|
5
|
+
module Resources
|
6
|
+
class TaxRate < Base
|
7
|
+
def api_resource
|
8
|
+
'tax_rates'
|
9
|
+
end
|
10
|
+
|
11
|
+
def root_name
|
12
|
+
'tax_rate'
|
13
|
+
end
|
14
|
+
|
15
|
+
def whitelist_params(params)
|
16
|
+
{
|
17
|
+
root_name => {
|
18
|
+
name: params[:name],
|
19
|
+
code: params[:code],
|
20
|
+
value: params[:value],
|
21
|
+
description: params[:description],
|
22
|
+
applied_by_default: params[:applied_by_default],
|
23
|
+
}.compact
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/lago/version.rb
CHANGED
data/lib/lago-ruby-client.rb
CHANGED
@@ -15,6 +15,7 @@ require 'lago/api/resources/base'
|
|
15
15
|
require 'lago/api/resources/add_on'
|
16
16
|
require 'lago/api/resources/applied_add_on'
|
17
17
|
require 'lago/api/resources/applied_coupon'
|
18
|
+
require 'lago/api/resources/applied_tax_rate'
|
18
19
|
require 'lago/api/resources/billable_metric'
|
19
20
|
require 'lago/api/resources/coupon'
|
20
21
|
require 'lago/api/resources/credit_note'
|
@@ -26,6 +27,7 @@ require 'lago/api/resources/invoice'
|
|
26
27
|
require 'lago/api/resources/organization'
|
27
28
|
require 'lago/api/resources/plan'
|
28
29
|
require 'lago/api/resources/subscription'
|
30
|
+
require 'lago/api/resources/tax_rate'
|
29
31
|
require 'lago/api/resources/wallet'
|
30
32
|
require 'lago/api/resources/wallet_transaction'
|
31
33
|
require 'lago/api/resources/webhook'
|
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: 0.
|
4
|
+
version: 0.33.0.pre.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovro Colic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/lago/api/resources/add_on.rb
|
137
137
|
- lib/lago/api/resources/applied_add_on.rb
|
138
138
|
- lib/lago/api/resources/applied_coupon.rb
|
139
|
+
- lib/lago/api/resources/applied_tax_rate.rb
|
139
140
|
- lib/lago/api/resources/base.rb
|
140
141
|
- lib/lago/api/resources/billable_metric.rb
|
141
142
|
- lib/lago/api/resources/coupon.rb
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- lib/lago/api/resources/organization.rb
|
149
150
|
- lib/lago/api/resources/plan.rb
|
150
151
|
- lib/lago/api/resources/subscription.rb
|
152
|
+
- lib/lago/api/resources/tax_rate.rb
|
151
153
|
- lib/lago/api/resources/wallet.rb
|
152
154
|
- lib/lago/api/resources/wallet_transaction.rb
|
153
155
|
- lib/lago/api/resources/webhook.rb
|