lago-ruby-client 1.10.0 → 1.15.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 +10 -1
- data/lib/lago/api/resources/event.rb +12 -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 +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4efab650d00c696bc613e6c879bf324c08d2da347af5d5e72d751832bd1fefcb
|
4
|
+
data.tar.gz: 4cb506189165871f589e3d604aee86f32757b5ef1f3355d81e20f7d9f44b1f38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efe8d1361cc3e868afdf4f5e9516cb9c6e97e9241018b574063bf7a1511e6d29561421b2aadaa6731d24fd4985dc97f015393542ef9b3ab2e0bf23d5a4e49241
|
7
|
+
data.tar.gz: b2f47a00dabbcbf56931bfe2d9e2a2e72c2495fcd79cfaa4592381db4cfff81146abe2d58a037854ba1ab41e40bb38639fbffa2eb6ac8af69d9516c757b7c538
|
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
|
@@ -65,6 +65,9 @@ module Lago
|
|
65
65
|
tax_identification_number: params[:tax_identification_number],
|
66
66
|
logo_url: params[:logo_url],
|
67
67
|
name: params[:name],
|
68
|
+
firstname: params[:firstname],
|
69
|
+
lastname: params[:lastname],
|
70
|
+
customer_type: params[:customer_type],
|
68
71
|
phone: params[:phone],
|
69
72
|
state: params[:state],
|
70
73
|
url: params[:url],
|
@@ -72,6 +75,7 @@ module Lago
|
|
72
75
|
currency: params[:currency],
|
73
76
|
tax_codes: params[:tax_codes],
|
74
77
|
timezone: params[:timezone],
|
78
|
+
finalize_zero_amount_invoice: params[:finalize_zero_amount_invoice],
|
75
79
|
}
|
76
80
|
|
77
81
|
whitelist_billing_configuration(params[:billing_configuration]).tap do |config|
|
@@ -120,7 +124,12 @@ module Lago
|
|
120
124
|
|
121
125
|
(integration_customers || []).each do |m|
|
122
126
|
result = (m || {})
|
123
|
-
.slice(:id,
|
127
|
+
.slice(:id,
|
128
|
+
:external_customer_id,
|
129
|
+
:integration_type,
|
130
|
+
:integration_code,
|
131
|
+
:subsidiary_id,
|
132
|
+
:sync_with_provider)
|
124
133
|
|
125
134
|
processed_integration_customers << result unless result.empty?
|
126
135
|
end
|
@@ -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
|
|
@@ -33,6 +43,7 @@ module Lago
|
|
33
43
|
code: params[:code],
|
34
44
|
timestamp: params[:timestamp],
|
35
45
|
external_subscription_id: params[:external_subscription_id],
|
46
|
+
precise_total_amount_cents: params[:precise_total_amount_cents],
|
36
47
|
properties: params[:properties],
|
37
48
|
}.compact,
|
38
49
|
}
|
@@ -49,6 +60,7 @@ module Lago
|
|
49
60
|
root_name => {
|
50
61
|
code: params[:code],
|
51
62
|
external_subscription_id: params[:external_subscription_id],
|
63
|
+
precise_total_amount_cents: params[:precise_total_amount_cents],
|
52
64
|
properties: params[:properties],
|
53
65
|
}.compact,
|
54
66
|
}
|
@@ -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.15.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-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.3.
|
183
|
+
rubygems_version: 3.3.27
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Lago Rest API client
|