lago-ruby-client 0.23.0.pre.beta → 0.27.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: dd132752862adc36956bf02495d20bcf41792419e181d747a39ecc061a06239b
4
- data.tar.gz: 5912a8f2932f5e551d045bc4408add87d7d22c6eade02b1d50fd42ce80b87223
3
+ metadata.gz: 6c7e6bca3327173d541f187c6fd1681de16a8ded711e91f6ce16afa62d432d95
4
+ data.tar.gz: 5f8154c8a9bcdf2b5b404dee32088dee9210fc9eebac14807bb4d6ff9b837174
5
5
  SHA512:
6
- metadata.gz: a3ea8757a95674741092ab95c3925012745f87258a9d3a5392ac21dc0f202b6e556aefdc770c550606980a53bf87d0ffe6d207d9d00df68e1272bd9edac6fb35
7
- data.tar.gz: 8d6a45f173887447cc24a1938d2bc1476bec952c56c433dfd8083734a3a1f78f4f985555bc1151038bdc3be39325892918e0028953141963269acf2531739547
6
+ metadata.gz: ab74a11d2c06c5a0dbac928d443a7bfc477d7f6953f69eea1c628c1766b5d68eea2f4b41b7b6a59d18d58f31997d0215d9bbd7cbb8ef9fab4daada80c6f38659
7
+ data.tar.gz: a403f2aa1f16153987146b43f209e00c7476229efeb915eb15f2756c4af384f6b64434c38b3d153c9b12eecc7e9d989dbbe488461c0c3d106079e7ee1c0f1567
@@ -35,6 +35,10 @@ module Lago
35
35
  Lago::Api::Resources::Event.new(self)
36
36
  end
37
37
 
38
+ def fees
39
+ Lago::Api::Resources::Fee.new(self)
40
+ end
41
+
38
42
  def groups
39
43
  Lago::Api::Resources::Group.new(self)
40
44
  end
@@ -19,6 +19,16 @@ module Lago
19
19
  connection.get(uri, identifier: nil)
20
20
  end
21
21
 
22
+ def portal_url(external_customer_id)
23
+ uri = URI(
24
+ "#{client.base_api_url}#{api_resource}/#{external_customer_id}/portal_url"
25
+ )
26
+
27
+ response = connection.get(uri, identifier: nil)[root_name]
28
+
29
+ JSON.parse(response.to_json, object_class: OpenStruct).portal_url
30
+ end
31
+
22
32
  def whitelist_params(params)
23
33
  result_hash = {
24
34
  external_id: params[:external_id],
@@ -43,6 +53,9 @@ module Lago
43
53
  result_hash[:billing_configuration] = config unless config.empty?
44
54
  end
45
55
 
56
+ metadata = whitelist_metadata(params[:metadata])
57
+ result_hash[:metadata] = metadata unless metadata.empty?
58
+
46
59
  { root_name => result_hash }
47
60
  end
48
61
 
@@ -57,6 +70,18 @@ module Lago
57
70
  :document_locale,
58
71
  )
59
72
  end
73
+
74
+ def whitelist_metadata(metadata)
75
+ processed_metadata = []
76
+
77
+ metadata.each do |m|
78
+ result = (m || {}).slice(:id, :key, :value, :display_in_invoice)
79
+
80
+ processed_metadata << result unless result.empty?
81
+ end
82
+
83
+ processed_metadata
84
+ end
60
85
  end
61
86
  end
62
87
  end
@@ -24,6 +24,13 @@ module Lago
24
24
  connection.post(payload, uri)
25
25
  end
26
26
 
27
+ def estimate_fees(params)
28
+ uri = URI("#{client.base_api_url}#{api_resource}/estimate_fees")
29
+
30
+ payload = whitelist_estimate_params(params)
31
+ connection.post(payload, uri)
32
+ end
33
+
27
34
  def whitelist_params(params)
28
35
  {
29
36
  root_name => {
@@ -32,8 +39,8 @@ module Lago
32
39
  code: params[:code],
33
40
  timestamp: params[:timestamp],
34
41
  external_subscription_id: params[:external_subscription_id],
35
- properties: params[:properties]
36
- }.compact
42
+ properties: params[:properties],
43
+ }.compact,
37
44
  }
38
45
  end
39
46
 
@@ -45,8 +52,19 @@ module Lago
45
52
  code: params[:code],
46
53
  timestamp: params[:timestamp],
47
54
  external_subscription_ids: params[:external_subscription_ids],
48
- properties: params[:properties]
49
- }.compact
55
+ properties: params[:properties],
56
+ }.compact,
57
+ }
58
+ end
59
+
60
+ def whitelist_estimate_params(params)
61
+ {
62
+ root_name => {
63
+ code: params[:code],
64
+ external_customer_id: params[:external_customer_id],
65
+ external_subscription_id: params[:external_subscription_id],
66
+ properties: params[:properties],
67
+ }.compact,
50
68
  }
51
69
  end
52
70
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lago
4
+ module Api
5
+ module Resources
6
+ class Fee < Base
7
+ def api_resource
8
+ 'fees'
9
+ end
10
+
11
+ def root_name
12
+ 'fee'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -41,11 +41,26 @@ module Lago
41
41
  end
42
42
 
43
43
  def whitelist_params(params)
44
- {
45
- root_name => {
46
- payment_status: params[:payment_status],
47
- },
44
+ result = {
45
+ payment_status: params[:payment_status],
48
46
  }
47
+
48
+ metadata = whitelist_metadata(params[:metadata])
49
+ result[:metadata] = metadata unless metadata.empty?
50
+
51
+ { root_name => result }
52
+ end
53
+
54
+ def whitelist_metadata(metadata)
55
+ processed_metadata = []
56
+
57
+ metadata.each do |m|
58
+ result = (m || {}).slice(:id, :key, :value)
59
+
60
+ processed_metadata << result unless result.empty?
61
+ end
62
+
63
+ processed_metadata
49
64
  end
50
65
  end
51
66
  end
@@ -25,6 +25,7 @@ module Lago
25
25
  legal_name: params[:legal_name],
26
26
  legal_number: params[:legal_number],
27
27
  timezone: params[:timezone],
28
+ email_settings: params[:email_settings],
28
29
  }.compact
29
30
 
30
31
  whitelist_billing_configuration(params[:billing_configuration]).tap do |config|
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.23.0-beta'
4
+ VERSION = '0.27.0-beta'
5
5
  end
@@ -20,6 +20,7 @@ require 'lago/api/resources/coupon'
20
20
  require 'lago/api/resources/credit_note'
21
21
  require 'lago/api/resources/customer'
22
22
  require 'lago/api/resources/event'
23
+ require 'lago/api/resources/fee'
23
24
  require 'lago/api/resources/group'
24
25
  require 'lago/api/resources/invoice'
25
26
  require 'lago/api/resources/organization'
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.23.0.pre.beta
4
+ version: 0.27.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-02-21 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -142,6 +142,7 @@ files:
142
142
  - lib/lago/api/resources/credit_note.rb
143
143
  - lib/lago/api/resources/customer.rb
144
144
  - lib/lago/api/resources/event.rb
145
+ - lib/lago/api/resources/fee.rb
145
146
  - lib/lago/api/resources/group.rb
146
147
  - lib/lago/api/resources/invoice.rb
147
148
  - lib/lago/api/resources/organization.rb
@@ -153,7 +154,7 @@ files:
153
154
  - lib/lago/version.rb
154
155
  homepage: https://github.com/getlago/lago-ruby-client
155
156
  licenses:
156
- - AGPL-3.0
157
+ - MIT
157
158
  metadata:
158
159
  homepage_uri: https://www.getlago.com/
159
160
  source_code_uri: https://github.com/getlago/lago-ruby-client