lago-ruby-client 1.10.0 → 1.11.0
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 +12 -2
- data/lib/lago/api/resources/customer.rb +1 -0
- data/lib/lago/api/resources/event.rb +10 -0
- data/lib/lago/api/resources/invoice.rb +7 -0
- data/lib/lago/api/resources/organization.rb +1 -0
- data/lib/lago/api/resources/payment_request.rb +10 -0
- data/lib/lago/api/resources/subscription.rb +29 -0
- data/lib/lago/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a023542440c173fcf116ddf4a7b6fdfbf35a8e1cbd6c3777ebe8ccf57937a091
|
4
|
+
data.tar.gz: f760dab07b17914619072ce29f609094b8d19b80be0aa8413c772c9e3da5f575
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 912d82e80c071eb39d0b8ade98cac367bfec53598649b3a7ce480860d4d539806f0836befb6a8bf1bfcb41555045848c15c2f3e2dbdd4f203239d2f51987568e
|
7
|
+
data.tar.gz: 2cb0ba95a24dab5bff7b4e9d6755d1827f34c6486234f40ed23501d35a4699986cc4d729117fcb7901e4ebafefce83874c2a903527336c2c7d56a10d40acff66
|
data/lib/lago/api/client.rb
CHANGED
@@ -3,14 +3,17 @@
|
|
3
3
|
module Lago
|
4
4
|
module Api
|
5
5
|
BASE_URL = 'https://api.getlago.com/'
|
6
|
+
BASE_INGEST_URL = 'https://ingest.getlago.com/'
|
6
7
|
API_PATH = 'api/v1/'
|
7
8
|
|
8
9
|
class Client
|
9
|
-
attr_reader :api_key, :api_url
|
10
|
+
attr_reader :api_key, :api_url, :use_ingest_service, :ingest_api_url
|
10
11
|
|
11
|
-
def initialize(api_key: nil, api_url: nil)
|
12
|
+
def initialize(api_key: nil, api_url: nil, use_ingest_service: false, ingest_api_url: nil)
|
12
13
|
@api_key = api_key
|
13
14
|
@api_url = api_url
|
15
|
+
@use_ingest_service = use_ingest_service
|
16
|
+
@ingest_api_url = ingest_api_url
|
14
17
|
end
|
15
18
|
|
16
19
|
def base_api_url
|
@@ -19,6 +22,13 @@ module Lago
|
|
19
22
|
URI.join(base_url, Lago::Api::API_PATH)
|
20
23
|
end
|
21
24
|
|
25
|
+
def base_ingest_api_url
|
26
|
+
return base_api_url unless use_ingest_service
|
27
|
+
|
28
|
+
ingest_url = ingest_api_url.nil? ? Lago::Api::BASE_INGEST_URL : ingest_api_url
|
29
|
+
URI.join(ingest_url, Lago::Api::API_PATH)
|
30
|
+
end
|
31
|
+
|
22
32
|
def customers
|
23
33
|
Lago::Api::Resources::Customer.new(self)
|
24
34
|
end
|
@@ -72,6 +72,7 @@ module Lago
|
|
72
72
|
currency: params[:currency],
|
73
73
|
tax_codes: params[:tax_codes],
|
74
74
|
timezone: params[:timezone],
|
75
|
+
finalize_zero_amount_invoice: params[:finalize_zero_amount_invoice],
|
75
76
|
}
|
76
77
|
|
77
78
|
whitelist_billing_configuration(params[:billing_configuration]).tap do |config|
|
@@ -12,6 +12,16 @@ module Lago
|
|
12
12
|
'event'
|
13
13
|
end
|
14
14
|
|
15
|
+
def create(params)
|
16
|
+
uri = URI("#{client.base_ingest_api_url}#{api_resource}")
|
17
|
+
connection = Lago::Api::Connection.new(client.api_key, uri)
|
18
|
+
|
19
|
+
payload = whitelist_params(params)
|
20
|
+
response = connection.post(payload, uri)[root_name]
|
21
|
+
|
22
|
+
JSON.parse(response.to_json, object_class: OpenStruct)
|
23
|
+
end
|
24
|
+
|
15
25
|
def batch_create(params)
|
16
26
|
uri = URI("#{client.base_api_url}#{api_resource}/batch")
|
17
27
|
|
@@ -56,6 +56,13 @@ module Lago
|
|
56
56
|
JSON.parse(response.to_json, object_class: OpenStruct)
|
57
57
|
end
|
58
58
|
|
59
|
+
def retry(invoice_id)
|
60
|
+
path = "/api/v1/invoices/#{invoice_id}/retry"
|
61
|
+
response = connection.post({}, path)
|
62
|
+
|
63
|
+
JSON.parse(response.to_json, object_class: OpenStruct).invoice
|
64
|
+
end
|
65
|
+
|
59
66
|
def payment_url(invoice_id)
|
60
67
|
path = "/api/v1/invoices/#{invoice_id}/payment_url"
|
61
68
|
response = connection.post({}, path)['invoice_payment_details']
|
@@ -32,6 +32,7 @@ module Lago
|
|
32
32
|
email_settings: params[:email_settings],
|
33
33
|
document_numbering: params[:document_numbering],
|
34
34
|
document_number_prefix: params[:document_number_prefix],
|
35
|
+
finalize_zero_amount_invoice: params[:finalize_zero_amount_invoice],
|
35
36
|
}.compact
|
36
37
|
|
37
38
|
whitelist_billing_configuration(params[:billing_configuration]).tap do |config|
|
@@ -11,6 +11,16 @@ module Lago
|
|
11
11
|
def root_name
|
12
12
|
'payment_request'
|
13
13
|
end
|
14
|
+
|
15
|
+
def whitelist_params(params)
|
16
|
+
result_hash = {
|
17
|
+
email: params[:email],
|
18
|
+
external_customer_id: params[:external_customer_id],
|
19
|
+
lago_invoice_ids: params[:lago_invoice_ids]
|
20
|
+
}.compact
|
21
|
+
|
22
|
+
{ root_name => result_hash }
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
@@ -12,6 +12,27 @@ module Lago
|
|
12
12
|
'subscription'
|
13
13
|
end
|
14
14
|
|
15
|
+
def lifetime_usage(external_subscription_id)
|
16
|
+
uri = URI(
|
17
|
+
"#{client.base_api_url}#{api_resource}/#{external_subscription_id}/lifetime_usage",
|
18
|
+
)
|
19
|
+
response = connection.get(uri, identifier: nil)
|
20
|
+
JSON.parse(response.to_json, object_class: OpenStruct).lifetime_usage
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_lifetime_usage(external_subscription_id, params)
|
24
|
+
uri = URI(
|
25
|
+
"#{client.base_api_url}#{api_resource}/#{external_subscription_id}/lifetime_usage",
|
26
|
+
)
|
27
|
+
|
28
|
+
response = connection.put(
|
29
|
+
uri,
|
30
|
+
identifier: nil,
|
31
|
+
body: whitelist_lifetime_usage_params(params),
|
32
|
+
)
|
33
|
+
JSON.parse(response.to_json, object_class: OpenStruct).lifetime_usage
|
34
|
+
end
|
35
|
+
|
15
36
|
def whitelist_params(params)
|
16
37
|
{
|
17
38
|
root_name => {
|
@@ -26,6 +47,14 @@ module Lago
|
|
26
47
|
}.compact,
|
27
48
|
}
|
28
49
|
end
|
50
|
+
|
51
|
+
def whitelist_lifetime_usage_params(params)
|
52
|
+
{
|
53
|
+
lifetime_usage: {
|
54
|
+
external_historical_usage_amount_cents: params[:external_historical_usage_amount_cents],
|
55
|
+
},
|
56
|
+
}
|
57
|
+
end
|
29
58
|
end
|
30
59
|
end
|
31
60
|
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.11.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: 2024-09-
|
11
|
+
date: 2024-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|