lago-ruby-client 0.50.0.pre.beta → 0.51.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: 6648835d8488417de038880a3124b10d68756f9185098fa54250e9167566a8e9
4
- data.tar.gz: a26d2b61479f46e1ba144c048aa7127f73889950d26bf0a761dc34e290df6663
3
+ metadata.gz: 498d6b5147ab708bbc13406f1b316af58ff461db03dc97065bc010643539afca
4
+ data.tar.gz: 2f346aa3288af414d787958bcbe941784065fd367f1c44ed301e2ec15aa68533
5
5
  SHA512:
6
- metadata.gz: 3b52dc25f131fb69f85ef12c6f7236cd48c7d839a883bc5b1407770b16a095c714f5f0c98f588c99cac026b5bb4899e78124678f297ffd42ab27495d8b4354e1
7
- data.tar.gz: a0e8af78ed0d728f77507391c78de2cb56a73e205c6560b850d21e46da9e1ef47b7933e299154a9f4656139bd622e2521c7f103c86cc395f5b97adca76a74d94
6
+ metadata.gz: 74ae5d6737ce4b643aadedd30ff4ab3ba0e3de3fa422ed24d36e71f92e9a76bde03b87a3a642ffcebfd400c336480fbc55f6ba1fd97826a5631e167d0c96c8b9
7
+ data.tar.gz: '0348874bd1b95be6fa3ca1aa0b6b0ce10e8d3580a65d481d3d84fa7178d161062e4257858f583509380c4f204a0591585f57ac8dd7fb0b59dcc7ff051e9eebad'
@@ -57,6 +57,25 @@ module Lago
57
57
 
58
58
  JSON.parse(response.to_json, object_class: OpenStruct).credit_note
59
59
  end
60
+
61
+ def estimate(params)
62
+ uri = URI("#{client.base_api_url}#{api_resource}/estimate")
63
+
64
+ payload = whitelist_estimate_params(params)
65
+ response = connection.post(payload, uri)['estimated_credit_note']
66
+
67
+ JSON.parse(response.to_json, object_class: OpenStruct)
68
+ end
69
+
70
+ def whitelist_estimate_params(params)
71
+ result_hash = { invoice_id: params[:invoice_id] }.compact
72
+
73
+ whitelist_items(params[:items] || []).tap do |items|
74
+ result_hash[:items] = items unless items.empty?
75
+ end
76
+
77
+ { root_name => result_hash }
78
+ end
60
79
  end
61
80
  end
62
81
  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.50.0-beta'
4
+ VERSION = '0.51.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.50.0.pre.beta
4
+ version: 0.51.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-10-17 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  - !ruby/object:Gem::Version
176
176
  version: 1.3.1
177
177
  requirements: []
178
- rubygems_version: 3.0.3.1
178
+ rubygems_version: 3.3.3
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Lago Rest API client