lago-ruby-client 0.31.0.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: a8c9bfb01820b9a318a83989ce0d080665c6d67ff66cf5a068a91b9abc5d4ea2
4
- data.tar.gz: 91babe2df17af3d908a6cd1a42ba094c26031d253377191a9301cf309f064669
3
+ metadata.gz: 0d97772a2f0dcee821ce6e0013f2f6e9f65384677c0ee3625a73d6232254f78e
4
+ data.tar.gz: 2eb6ad88336e733ce70276f6a30d3d72851b7817a815985f1fd777444756b4e5
5
5
  SHA512:
6
- metadata.gz: 24ec7bddb96299b1df4bf8b2f9af42e2c79030f29a28b13cef1d6e7978c8be8b4d21b83f25faf590f66c352bffff5b6a3bd988f36373b5a4de4ef2f0d99fd2d0
7
- data.tar.gz: 5f2e5e0fb9299c4a675181e06e1d5aed84c18cd537bdba39b6c207ffda81c0fc71562ed8e6c614488e1694ed8c77c2e6ea77290c4afc367882809ad6d396b7db
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
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.31.0-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.31.0.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-05-04 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