lago-ruby-client 1.33.3 → 1.35.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77539910cb74fde63c0520e5166bbe5a4da9a9896345a88be8f5643d45ffe10b
4
- data.tar.gz: f890af33e6cd99250e4fdab71f06c0cb3bbd00ea23b827f2f62899f752049e2b
3
+ metadata.gz: aa5e9bcd28c915dd10e0d3aa5676c82ef6ac36b6e32413db8fff40983d298621
4
+ data.tar.gz: 60e48e0f100c01afa0ebff4c0b01216876ce013f8da3bc11c70079c1e1c134ed
5
5
  SHA512:
6
- metadata.gz: c8e2429ccaf48d8958b302d5c9ce11576596c138570b36b310b229c146be1d3912a581c2980b315fdc2c874d7293e462cbf87f8b577f5dab726436144cb7b848
7
- data.tar.gz: bb53fc7f5793292f732066f6915dc4b99c75ad62d88a1b16ed3d375e8ce44da8e22d14b4c7f9720515b6756e0ed9b911ba1a0c3912e42d7581b3e082c3997d61
6
+ metadata.gz: 870668ed7485af2119524c9621a3b8cd0b2e4f82ed6d95ba8e14473f9098195d93ed5230e27a9a2f41618ce5d2e0ee50ea111bb9199373a03705658957a3f9c5
7
+ data.tar.gz: 02e656a9e580d3fef35c860b39c60d907157c6959ef58db4297d15031896435642cc0e43fb67c619030c147a83a6cf0eae4d864af98076a67589e20404d60806
@@ -10,6 +10,14 @@ require 'lago/api/resources/billing_entity'
10
10
  require 'lago/api/resources/coupon'
11
11
  require 'lago/api/resources/credit_note'
12
12
  require 'lago/api/resources/customer'
13
+ require 'lago/api/resources/customers/base'
14
+ require 'lago/api/resources/customers/applied_coupon'
15
+ require 'lago/api/resources/customers/credit_note'
16
+ require 'lago/api/resources/customers/invoice'
17
+ require 'lago/api/resources/customers/payment'
18
+ require 'lago/api/resources/customers/payment_request'
19
+ require 'lago/api/resources/customers/subscription'
20
+ require 'lago/api/resources/customers/wallet'
13
21
  require 'lago/api/resources/event'
14
22
  require 'lago/api/resources/feature'
15
23
  require 'lago/api/resources/fee'
@@ -98,6 +106,34 @@ module Lago
98
106
  Resources::Customer.new(self)
99
107
  end
100
108
 
109
+ def customer_applied_coupons(resource_id)
110
+ Resources::Customers::AppliedCoupon.new(self, resource_id)
111
+ end
112
+
113
+ def customer_credit_notes(resource_id)
114
+ Resources::Customers::CreditNote.new(self, resource_id)
115
+ end
116
+
117
+ def customer_invoices(resource_id)
118
+ Resources::Customers::Invoice.new(self, resource_id)
119
+ end
120
+
121
+ def customer_payments(resource_id)
122
+ Resources::Customers::Payment.new(self, resource_id)
123
+ end
124
+
125
+ def customer_payment_requests(resource_id)
126
+ Resources::Customers::PaymentRequest.new(self, resource_id)
127
+ end
128
+
129
+ def customer_subscriptions(resource_id)
130
+ Resources::Customers::Subscription.new(self, resource_id)
131
+ end
132
+
133
+ def customer_wallets(resource_id)
134
+ Resources::Customers::Wallet.new(self, resource_id)
135
+ end
136
+
101
137
  def events
102
138
  Resources::Event.new(self)
103
139
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class AppliedCoupon < Base
10
+ def api_resource
11
+ "#{base_api_resource}/applied_coupons"
12
+ end
13
+
14
+ def root_name
15
+ 'applied_coupon'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class Base < Lago::Api::Resources::Base
10
+ def initialize(client, resource_id)
11
+ super(client)
12
+ @resource_id = resource_id
13
+ end
14
+
15
+ def base_api_resource
16
+ "customers/#{resource_id}"
17
+ end
18
+
19
+ def create(params)
20
+ raise NotImplementedError
21
+ end
22
+
23
+ def update(params, identifier = nil)
24
+ raise NotImplementedError
25
+ end
26
+
27
+ def get(identifier)
28
+ raise NotImplementedError
29
+ end
30
+
31
+ def destroy(identifier, options: nil)
32
+ raise NotImplementedError
33
+ end
34
+
35
+ private
36
+
37
+ attr_reader :resource_id
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class CreditNote < Base
10
+ def api_resource
11
+ "#{base_api_resource}/credit_notes"
12
+ end
13
+
14
+ def root_name
15
+ 'credit_note'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class Invoice < Base
10
+ def api_resource
11
+ "#{base_api_resource}/invoices"
12
+ end
13
+
14
+ def root_name
15
+ 'invoice'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class Payment < Base
10
+ def api_resource
11
+ "#{base_api_resource}/payments"
12
+ end
13
+
14
+ def root_name
15
+ 'payment'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class PaymentRequest < Base
10
+ def api_resource
11
+ "#{base_api_resource}/payment_requests"
12
+ end
13
+
14
+ def root_name
15
+ 'payment_request'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class Subscription < Base
10
+ def api_resource
11
+ "#{base_api_resource}/subscriptions"
12
+ end
13
+
14
+ def root_name
15
+ 'subscription'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lago/api/resources/base'
4
+
5
+ module Lago
6
+ module Api
7
+ module Resources
8
+ module Customers
9
+ class Wallet < Base
10
+ def api_resource
11
+ "#{base_api_resource}/wallets"
12
+ end
13
+
14
+ def root_name
15
+ 'wallet'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -28,7 +28,8 @@ module Lago
28
28
  uri = URI("#{client.base_api_url}#{api_resource}/batch")
29
29
 
30
30
  payload = whitelist_batch_params(params)
31
- connection.post(payload, uri)
31
+ response = connection.post(payload, uri)
32
+ JSON.parse(response.to_json, object_class: OpenStruct)
32
33
  end
33
34
 
34
35
  def estimate_fees(params)
@@ -15,23 +15,27 @@ module Lago
15
15
  end
16
16
 
17
17
  def whitelist_params(params)
18
- result_hash = {
19
- external_customer_id: params[:external_customer_id],
20
- rate_amount: params[:rate_amount],
21
- name: params[:name],
22
- paid_credits: params[:paid_credits],
23
- granted_credits: params[:granted_credits],
24
- currency: params[:currency],
25
- expiration_at: params[:expiration_at],
26
- transaction_metadata: params[:transaction_metadata],
27
- invoice_requires_successful_payment: params[:invoice_requires_successful_payment],
28
- }.compact
18
+ result_hash = params.compact.slice(
19
+ :external_customer_id,
20
+ :rate_amount,
21
+ :name,
22
+ :paid_credits,
23
+ :granted_credits,
24
+ :currency,
25
+ :expiration_at,
26
+ :transaction_metadata,
27
+ :invoice_requires_successful_payment,
28
+ :ignore_paid_top_up_limits_on_creation,
29
+ :transaction_name,
30
+ :paid_top_up_min_amount_cents,
31
+ :paid_top_up_max_amount_cents
32
+ )
29
33
 
30
34
  recurring_rules = whitelist_recurring_rules(params[:recurring_transaction_rules])
31
- result_hash[:recurring_transaction_rules] = recurring_rules unless recurring_rules.empty?
35
+ result_hash[:recurring_transaction_rules] = recurring_rules if recurring_rules.any?
32
36
 
33
37
  applies_to = whitelist_applies_to(params[:applies_to])
34
- result_hash[:applies_to] = applies_to unless applies_to.empty?
38
+ result_hash[:applies_to] = applies_to if applies_to.any?
35
39
 
36
40
  { root_name => result_hash }
37
41
  end
@@ -52,7 +56,9 @@ module Lago
52
56
  :started_at,
53
57
  :expiration_at,
54
58
  :target_ongoing_balance,
55
- :transaction_metadata
59
+ :transaction_metadata,
60
+ :transaction_name,
61
+ :ignore_paid_top_up_limits
56
62
  )
57
63
 
58
64
  processed_rules << result unless result.empty?
@@ -30,15 +30,16 @@ module Lago
30
30
 
31
31
  def whitelist_params(params)
32
32
  {
33
- 'wallet_transaction' => {
34
- wallet_id: params[:wallet_id],
35
- name: params[:name],
36
- paid_credits: params[:paid_credits],
37
- granted_credits: params[:granted_credits],
38
- voided_credits: params[:voided_credits],
39
- invoice_requires_successful_payment: params[:invoice_requires_successful_payment],
40
- metadata: params[:metadata],
41
- }.compact
33
+ 'wallet_transaction' => params.compact.slice(
34
+ :wallet_id,
35
+ :name,
36
+ :paid_credits,
37
+ :granted_credits,
38
+ :voided_credits,
39
+ :invoice_requires_successful_payment,
40
+ :ignore_paid_top_up_limits,
41
+ :metadata,
42
+ )
42
43
  }
43
44
  end
44
45
  end
data/lib/lago/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lago
4
- VERSION = '1.33.3'
4
+ VERSION = '1.35.0'
5
5
  end
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.33.3
4
+ version: 1.35.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: 2025-09-15 00:00:00.000000000 Z
11
+ date: 2025-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ostruct
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bigdecimal
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +178,6 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: rubocop-rails
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubocop-rspec
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -241,6 +241,14 @@ files:
241
241
  - lib/lago/api/resources/coupon.rb
242
242
  - lib/lago/api/resources/credit_note.rb
243
243
  - lib/lago/api/resources/customer.rb
244
+ - lib/lago/api/resources/customers/applied_coupon.rb
245
+ - lib/lago/api/resources/customers/base.rb
246
+ - lib/lago/api/resources/customers/credit_note.rb
247
+ - lib/lago/api/resources/customers/invoice.rb
248
+ - lib/lago/api/resources/customers/payment.rb
249
+ - lib/lago/api/resources/customers/payment_request.rb
250
+ - lib/lago/api/resources/customers/subscription.rb
251
+ - lib/lago/api/resources/customers/wallet.rb
244
252
  - lib/lago/api/resources/event.rb
245
253
  - lib/lago/api/resources/feature.rb
246
254
  - lib/lago/api/resources/fee.rb