squake 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b4d311a5ad4fb22fd6ec57a34bf0c1a2d79434d8a90129b79b5bd0bb2336587
4
- data.tar.gz: 19dfd1352aa055fe5ee427a5ce4f8b1cb518b8259c770c77c6360c23a7116e06
3
+ metadata.gz: 9998b15ce76aa8dbc8be90d10591fcc590a6371f49ff5f18782ce77081ff1420
4
+ data.tar.gz: 68b42dec21a0f57f64b1fd12b1a206496cd7b0e2c2aefccb75d3890914865f2a
5
5
  SHA512:
6
- metadata.gz: 109e5a1cc4e00f3c840252507b17a740a15a4afee802917e56df9d7e3a0c32f0c6d213313193fa2e03b429b821dcddcf4668bf5aac07744c65a4e8425b9fb3b5
7
- data.tar.gz: 3f956999206d2b89d4989728a07c75d318fd8e95793df0346237ece389a069d03f31c8103eaf2526d81ab983dc4f1304b5401ea271579a284a378bb83d2b0a16
6
+ metadata.gz: 20b305cc676a3fce372ca814206a4299b173ae9560115f582dd957abd2387b3d8defd44f254ec5a835a94e1eb6e366fe7c23ecb9bf5c71edc360ee92268ebb05
7
+ data.tar.gz: ef97791c2cfb0bddde5cc0e15eca9e5d2055d24daceffee4e77473d3595bb4fa5f1ee5eeb6430580b7da2efdc0a610763f5d75bcee65010d727a04774706ade0
data/README.md CHANGED
@@ -123,11 +123,12 @@ end
123
123
 
124
124
  ```ruby
125
125
  Squake::Pricing.quote(
126
- client: squake_client, # optional
127
- carbon_quantity: 1000, # required
128
- carbon_unit: 'kilogram', # optional, default: 'gram', other options: 'kilogram', 'tonne'
129
- product_id: 'some_product_id', # required
130
- expand: [], # optional, default: [], allowed values: 'product', 'price' to enrich the response
126
+ client: squake_client, # optional
127
+ carbon_quantity: 1000, # required
128
+ carbon_unit: 'kilogram', # optional, default: 'gram', other options: 'kilogram', 'tonne'
129
+ product_id: 'some_product_id', # required
130
+ expand: [], # optional, default: [], allowed values: 'product', 'price' to enrich the response
131
+ payment_link_return_url: 'https://squake.earth', # optional, default: nil
131
132
  )
132
133
 
133
134
  if context.success?
@@ -159,12 +160,13 @@ end
159
160
 
160
161
  ```ruby
161
162
  context = Squake::CalculationWithPricing.quote(
162
- items: items, # required
163
- product: 'product-id', # required
164
- currency: 'EUR', # optional, default: 'EUR'
165
- carbon_unit: 'gram', # optional, default: 'gram', other options: 'kilogram', 'tonne'
166
- expand: [], # optional, default: [], allowed values: 'items', 'product', 'price' to enrich the response
167
- client: client, # optional
163
+ items: items, # required
164
+ product: 'product-id', # required
165
+ currency: 'EUR', # optional, default: 'EUR'
166
+ carbon_unit: 'gram', # optional, default: 'gram', other options: 'kilogram', 'tonne'
167
+ expand: [], # optional, default: [], allowed values: 'items', 'product', 'price' to enrich the response
168
+ payment_link_return_url: 'https://squake.earth', # optional, default: nil
169
+ client: client, # optional
168
170
  )
169
171
 
170
172
  if context.success?
@@ -15,12 +15,14 @@ module Squake
15
15
  currency: String,
16
16
  carbon_unit: String,
17
17
  expand: T::Array[String],
18
+ payment_link_return_url: T.nilable(String),
18
19
  client: Squake::Client,
19
20
  request_id: T.nilable(String),
20
21
  ).returns(Squake::Return[Squake::Model::Pricing])
21
22
  end
22
23
  def self.quote(
23
- items:, product:, currency: 'EUR', carbon_unit: 'gram', expand: [], client: Squake::Client.new, request_id: nil
24
+ items:, product:, currency: 'EUR', carbon_unit: 'gram',
25
+ expand: [], payment_link_return_url: nil, client: Squake::Client.new, request_id: nil
24
26
  )
25
27
  # @TODO: add typed objects for all possible items. Until then, we allow either a Hash or a T::Struct
26
28
  items = items.map do |item|
@@ -37,6 +39,7 @@ module Squake
37
39
  currency: currency,
38
40
  carbon_unit: carbon_unit,
39
41
  expand: expand,
42
+ payment_link_return_url: payment_link_return_url,
40
43
  },
41
44
  )
42
45
 
@@ -16,13 +16,14 @@ module Squake
16
16
  carbon_quantity: T.nilable(Numeric),
17
17
  carbon_unit: T.nilable(String),
18
18
  expand: T::Array[String],
19
+ payment_link_return_url: T.nilable(String),
19
20
  client: Squake::Client,
20
21
  request_id: T.nilable(String),
21
22
  ).returns(Squake::Return[Squake::Model::Pricing])
22
23
  end
23
- def self.quote(
24
+ def self.quote( # rubocop:disable Metrics/ParameterLists
24
25
  product_id:, fixed_total: nil, currency: 'EUR', carbon_quantity: nil, carbon_unit: 'gram',
25
- expand: [], client: Squake::Client.new, request_id: nil
26
+ expand: [], payment_link_return_url: nil, client: Squake::Client.new, request_id: nil
26
27
  )
27
28
 
28
29
  result = client.call(
@@ -36,6 +37,7 @@ module Squake
36
37
  carbon_quantity: carbon_quantity,
37
38
  carbon_unit: carbon_unit,
38
39
  expand: expand,
40
+ payment_link_return_url: payment_link_return_url,
39
41
  },
40
42
  )
41
43
 
data/lib/squake/util.rb CHANGED
@@ -9,10 +9,15 @@ module Squake
9
9
  # parameters in a URI or as form parameters in a request body. This mainly
10
10
  # involves escaping special characters from parameter keys and values (e.g.
11
11
  # `&`).
12
- sig { params(params: T::Hash[Symbol, String]).returns(String) }
12
+ sig { params(params: T::Hash[Symbol, T.any(String, T::Array[String])]).returns(String) }
13
13
  def self.encode_parameters(params)
14
14
  params.map do |k, v|
15
- "#{url_encode(k.to_s)}=#{url_encode(v.to_s)}" unless v.nil?
15
+ case v
16
+ when Array
17
+ v.map { |e| "#{url_encode(k.to_s)}[]=#{url_encode(e.to_s)}" }.join('&')
18
+ else
19
+ "#{url_encode(k.to_s)}=#{url_encode(v.to_s)}" unless v.nil?
20
+ end
16
21
  end.join('&')
17
22
  end
18
23
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Squake
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SQUAKE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-17 00:00:00.000000000 Z
11
+ date: 2023-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  - !ruby/object:Gem::Version
219
219
  version: '0'
220
220
  requirements: []
221
- rubygems_version: 3.2.3
221
+ rubygems_version: 3.4.19
222
222
  signing_key:
223
223
  specification_version: 4
224
224
  summary: The industry solution for sustainable travel and logistics.