lago-ruby-client 0.32.0.pre.beta → 0.34.0.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d97772a2f0dcee821ce6e0013f2f6e9f65384677c0ee3625a73d6232254f78e
4
- data.tar.gz: 2eb6ad88336e733ce70276f6a30d3d72851b7817a815985f1fd777444756b4e5
3
+ metadata.gz: deb3eba2034074188358ea0ce20b4ac7718a02488011549fe784330dec840377
4
+ data.tar.gz: 1f5af1474abcab68c1f8d007f807c74e41fb3880a97cb38917621c905ef9254e
5
5
  SHA512:
6
- metadata.gz: 90a5a8c868ca8731f6c8ff97cb8ec0eb77cb6b8ebcb3c58322bf7d057e50ca6dbdab65c187ed08f91c75ff9f50671022dc68379bbcc50d345c9421393343dd8b
7
- data.tar.gz: e2dd1f11deaa09b86bd1658c094042764a28c2db8ca847af073a45e95778bf27b283f4a56ab2da98d1681dc12058a910cf4cc66e7822d0d252a35005bc74586e
6
+ metadata.gz: 41999a6fb04cf188e1d591a62d9227413918d37152703f99f9bf1ba0deb40750a88d3c503baca0695ede06979b27d2cac4846f7108a7fec8a128acba26bfb159
7
+ data.tar.gz: 244e27bec3a0425d5e9f519249b8ebd35f772af32bbf09711f54d69dbcc448b2cfd5aef4d92817fa946b2c320d28002674ca89aed8e70b099d35566854f63bea
@@ -51,6 +51,10 @@ module Lago
51
51
  Lago::Api::Resources::AppliedAddOn.new(self)
52
52
  end
53
53
 
54
+ def applied_taxes
55
+ Lago::Api::Resources::AppliedTax.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 taxes
83
+ Lago::Api::Resources::Tax.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 AppliedTax < Base
7
+ def api_resource
8
+ 'applied_tax'
9
+ end
10
+
11
+ def root_name
12
+ 'applied_tax'
13
+ end
14
+
15
+ def create(external_customer_id, params)
16
+ path = "/api/v1/customers/#{external_customer_id}/applied_taxes"
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_code)
24
+ path = "/api/v1/customers/#{external_customer_id}/applied_taxes"
25
+ response = connection.destroy(path, identifier: tax_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_code: params[:tax_code],
34
+ }.compact,
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -29,7 +29,7 @@ module Lago
29
29
  def whitelist_items(items)
30
30
  items.each_with_object([]) do |item, result|
31
31
  filtered_item = (item || {}).slice(
32
- :fee_id, :credit_amount_cents, :refund_amount_cents
32
+ :fee_id, :amount_cents
33
33
  )
34
34
 
35
35
  result << filtered_item unless filtered_item.empty?
@@ -40,6 +40,8 @@ module Lago
40
40
  path = "/api/v1/credit_notes/#{credit_note_id}/download"
41
41
  response = connection.post({}, path)
42
42
 
43
+ return response unless response.is_a?(Hash)
44
+
43
45
  JSON.parse(response.to_json, object_class: OpenStruct).credit_note
44
46
  end
45
47
 
@@ -23,6 +23,8 @@ module Lago
23
23
  path = "/api/v1/invoices/#{invoice_id}/download"
24
24
  response = connection.post({}, path)
25
25
 
26
+ return response unless response.is_a?(Hash)
27
+
26
28
  JSON.parse(response.to_json, object_class: OpenStruct).invoice
27
29
  end
28
30
 
@@ -40,7 +40,7 @@ module Lago
40
40
  :id,
41
41
  :billable_metric_id,
42
42
  :charge_model,
43
- :instant,
43
+ :pay_in_advance,
44
44
  :min_amount_cents,
45
45
  :properties,
46
46
  :group_properties,
@@ -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
- subscription_date: params[:subscription_date],
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 Tax < Base
7
+ def api_resource
8
+ 'taxes'
9
+ end
10
+
11
+ def root_name
12
+ 'tax'
13
+ end
14
+
15
+ def whitelist_params(params)
16
+ {
17
+ root_name => {
18
+ name: params[:name],
19
+ code: params[:code],
20
+ rate: params[:rate],
21
+ description: params[:description],
22
+ applied_to_organization: params[:applied_to_organization],
23
+ }.compact,
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -20,6 +20,7 @@ module Lago
20
20
  name: params[:name],
21
21
  paid_credits: params[:paid_credits],
22
22
  granted_credits: params[:granted_credits],
23
+ currency: params[:currency],
23
24
  expiration_at: params[:expiration_at],
24
25
  }.compact,
25
26
  }
data/lib/lago/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lago
4
- VERSION = '0.32.0-beta'
4
+ VERSION = '0.34.0-beta'
5
5
  end
@@ -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'
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'
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.32.0.pre.beta
4
+ version: 0.34.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-10 00:00:00.000000000 Z
11
+ date: 2023-05-29 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.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.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