lago-ruby-client 0.29.1.pre.beta → 0.32.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: d123d4384a928523d2422a554663aa839c6713c1a3406c99b1d21366b84f03f5
4
- data.tar.gz: 9d8cbaabff2d94dcba6ea5145525e98c620c9628cc6c82ea949aebfa00211673
3
+ metadata.gz: 0d97772a2f0dcee821ce6e0013f2f6e9f65384677c0ee3625a73d6232254f78e
4
+ data.tar.gz: 2eb6ad88336e733ce70276f6a30d3d72851b7817a815985f1fd777444756b4e5
5
5
  SHA512:
6
- metadata.gz: f83582c09fb440fce45fc67bfa5a4a4c65e47d874d749ebeee7aa6ea8f1dee9eac973365bb08d8adaf6e8fe8a18c4fd46491c09a2256d65b086cf9ca9ee7f8ec
7
- data.tar.gz: 398c56164bbdfe2e0a88ca905c68eec770456ff80153aa72311a128ba91e8d0d0ed6ac13903bd5f9437a76cdd9b5e66ed7e56e62054ab8e4a04fab5853dbbc89
6
+ metadata.gz: 90a5a8c868ca8731f6c8ff97cb8ec0eb77cb6b8ebcb3c58322bf7d057e50ca6dbdab65c187ed08f91c75ff9f50671022dc68379bbcc50d345c9421393343dd8b
7
+ data.tar.gz: e2dd1f11deaa09b86bd1658c094042764a28c2db8ca847af073a45e95778bf27b283f4a56ab2da98d1681dc12058a910cf4cc66e7822d0d252a35005bc74586e
@@ -12,6 +12,13 @@ module Lago
12
12
  'invoice'
13
13
  end
14
14
 
15
+ def create(params)
16
+ payload = one_off_params(params)
17
+ response = connection.post(payload)[root_name]
18
+
19
+ JSON.parse(response.to_json, object_class: OpenStruct)
20
+ end
21
+
15
22
  def download(invoice_id)
16
23
  path = "/api/v1/invoices/#{invoice_id}/download"
17
24
  response = connection.post({}, path)
@@ -62,6 +69,30 @@ module Lago
62
69
 
63
70
  processed_metadata
64
71
  end
72
+
73
+ def one_off_params(params)
74
+ result = {
75
+ external_customer_id: params[:external_customer_id],
76
+ currency: params[:currency],
77
+ }
78
+
79
+ fees = whitelist_fees(params[:fees])
80
+ result[:fees] = fees unless fees.empty?
81
+
82
+ { root_name => result }
83
+ end
84
+
85
+ def whitelist_fees(fees)
86
+ processed_fees = []
87
+
88
+ fees.each do |f|
89
+ result = (f || {}).slice(:add_on_code, :unit_amount_cents, :units, :description)
90
+
91
+ processed_fees << result unless result.empty?
92
+ end
93
+
94
+ processed_fees
95
+ end
65
96
  end
66
97
  end
67
98
  end
@@ -36,7 +36,15 @@ module Lago
36
36
  processed_charges = []
37
37
 
38
38
  charges.each do |c|
39
- result = (c || {}).slice(:id, :billable_metric_id, :charge_model, :instant, :properties, :group_properties)
39
+ result = (c || {}).slice(
40
+ :id,
41
+ :billable_metric_id,
42
+ :charge_model,
43
+ :instant,
44
+ :min_amount_cents,
45
+ :properties,
46
+ :group_properties,
47
+ )
40
48
 
41
49
  processed_charges << result unless result.empty?
42
50
  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 = '0.29.1-beta'
4
+ VERSION = '0.32.0-beta'
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: 0.29.1.pre.beta
4
+ version: 0.32.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-04-24 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt