squake 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/squake/calculation.rb +6 -1
- data/lib/squake/calculation_with_pricing.rb +7 -2
- data/lib/squake/version.rb +1 -1
- data/lib/squake.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe25ba449a2b7838a20ae80a5bcd9106bfe21a2f2626185a9eb901dc9e2f58a
|
4
|
+
data.tar.gz: 18b8e92dabac3f0f0657a27b6adadd9616530421c640c4b6a584f1d454e16596
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b302c402858193ee25d25ed3ed610362b1bb00ce477956c9c6f7e440b312e758b9eddd6861841f5fb8059eb0300728d85707b44964d2f10614a4f20429c3bf4c
|
7
|
+
data.tar.gz: ee363ceeb88006801dfcc7a6be2535ac82357e001cd3e71c6b4d86e722f71719b84fcc536897cb1505374cd7a2226f17764ddc2e7bff678c0cef62ac234473ae
|
data/lib/squake/calculation.rb
CHANGED
@@ -11,12 +11,17 @@ module Squake
|
|
11
11
|
sig do
|
12
12
|
params(
|
13
13
|
client: Squake::Client,
|
14
|
-
items: T::Array[Squake::Model::Items::BaseType],
|
14
|
+
items: T::Array[T.any(Squake::Model::Items::BaseType, T::Hash[T.any(String, Symbol), T.untyped])],
|
15
15
|
carbon_unit: String,
|
16
16
|
expand: T::Array[String],
|
17
17
|
).returns(Squake::Model::Carbon)
|
18
18
|
end
|
19
19
|
def self.create(client:, items:, carbon_unit: 'gram', expand: [])
|
20
|
+
# @TODO: add typed objects for all possible items. Until then, we allow either a Hash or a T::Struct
|
21
|
+
items = items.map do |item|
|
22
|
+
item.is_a?(T::Struct) ? item.serialize : item
|
23
|
+
end
|
24
|
+
|
20
25
|
result = client.call(
|
21
26
|
path: ENDPOINT,
|
22
27
|
method: :post,
|
@@ -11,7 +11,7 @@ module Squake
|
|
11
11
|
sig do
|
12
12
|
params(
|
13
13
|
client: Squake::Client,
|
14
|
-
items: T::Array[Squake::Model::Items::BaseType],
|
14
|
+
items: T::Array[T.any(Squake::Model::Items::BaseType, T::Hash[T.any(String, Symbol), T.untyped])],
|
15
15
|
product: String,
|
16
16
|
currency: String,
|
17
17
|
carbon_unit: String,
|
@@ -19,11 +19,16 @@ module Squake
|
|
19
19
|
).returns(Squake::Model::Pricing)
|
20
20
|
end
|
21
21
|
def self.quote(client:, items:, product:, currency: 'EUR', carbon_unit: 'gram', expand: [])
|
22
|
+
# @TODO: add typed objects for all possible items. Until then, we allow either a Hash or a T::Struct
|
23
|
+
items = items.map do |item|
|
24
|
+
item.is_a?(T::Struct) ? item.serialize : item
|
25
|
+
end
|
26
|
+
|
22
27
|
result = client.call(
|
23
28
|
path: ENDPOINT,
|
24
29
|
method: :post,
|
25
30
|
params: {
|
26
|
-
items: items
|
31
|
+
items: items,
|
27
32
|
product: product,
|
28
33
|
currency: currency,
|
29
34
|
carbon_unit: carbon_unit,
|
data/lib/squake/version.rb
CHANGED
data/lib/squake.rb
CHANGED