hubrise_client 2.0.14 → 2.0.16

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: 89e7c3b037501ae07c44e6cfef51a9e39d5d0aa06c229493716957835146c64e
4
- data.tar.gz: 34643d28e45cad280f62bc8e826cfaf0d7bbd19cedcd003faeeda087d3d5e428
3
+ metadata.gz: 5a5efc4d9d115b36d1644adbdb7760808eed52c6532272520bbed995e0a18425
4
+ data.tar.gz: 3a930aec0a980055b08694c3af4e76db5f5a477dd3d0cd46aae4e8fe55b54172
5
5
  SHA512:
6
- metadata.gz: 78e35af2ae3b43e4a3e73339abd261cbe515cddac733dbd930831f6fea512ec686683b4e681875d429d9d07edbe4d396ba44858d95a134ef6e4cab0c922a3852
7
- data.tar.gz: 15ad66f6d58e868117ead6678921b0f70b9954525b60e28930c0af6e599daca371f1faf6105399f904980d5dcb73bfc9ae2dfdf0f15bbadef88a2a972afd3bde
6
+ metadata.gz: 7d184e875c81ef04dcf3d839afbe07345011eb01ac2705c4ccb9f8ae6ee2362bba6159b2e00cf7c170b8af755b78bab3aeba72e8df0c7f117b9d5d262c56fa1a
7
+ data.tar.gz: 718bffe6ff5551ea8b011922ae194d63831a513130b24a7bf9266ee8354117f5d92488ce17f5f2d7da278a3ca61a24883491e55b5ee13bd0e02440b594a9d956
data/README.md CHANGED
@@ -14,59 +14,57 @@ Or install via [gem](http://rubygems.org/)
14
14
  gem install hubrise_client
15
15
  ```
16
16
 
17
-
18
17
  # Prerequisites
19
18
 
20
- 1) Read the [docs](https://www.hubrise.com/developers)
21
-
22
- 2) [Create a Hubrise Client](https://www.hubrise.com/developers/quick-start#create-the-oauth-client) to get your `CLIENT_ID` and `CLIENT_SECRET`.
19
+ 1. Read the [docs](https://www.hubrise.com/developers)
23
20
 
21
+ 2. [Create a Hubrise Client](https://www.hubrise.com/developers/quick-start#create-the-oauth-client) to get your `CLIENT_ID` and `CLIENT_SECRET`.
24
22
 
25
23
  # Get an access token
26
24
 
27
25
  1. Initialize anonymous `HubriseClient`
28
- ```ruby
29
- client = HubriseClient::V1.new(CLIENT_ID, CLIENT_SECRET)
30
- ```
26
+
27
+ ```ruby
28
+ client = HubriseClient::V1.new(CLIENT_ID, CLIENT_SECRET)
29
+ ```
31
30
 
32
31
  2. Prepare a route to handle `REDIRECT_URI` callback
33
- ```ruby
34
- # routes.rb
35
- namespace :hubrise_oauth do
36
- get :authorize_callback
37
- # => creates hubrise_oauth_authorize_callback_url helper
38
- end
39
- ```
40
-
41
32
 
42
- 3. Initiate an OAuth flow by redirecting a user to [OAuth Authorization URL](https://www.hubrise.com/developers/authentication#request-authorisation)
43
- ```ruby
44
- oauth_scope = "location[orders.read]" # adjust to your needs
45
- authorization_url = client.build_authorization_url(hubrise_oauth_authorize_callback_url, oauth_scope)
46
- ...
47
- redirect_to(authorization_url)
48
- ```
33
+ ```ruby
34
+ # routes.rb
35
+ namespace :hubrise_oauth do
36
+ get :authorize_callback
37
+ # => creates hubrise_oauth_authorize_callback_url helper
38
+ end
39
+ ```
49
40
 
50
- 4. Complete the OAuth flow
41
+ 3. Initiate an OAuth flow by redirecting a user to [OAuth Authorization URL](https://www.hubrise.com/developers/authentication#request-authorisation)
51
42
 
52
- Once the user accepts your request he or she will be redirected to the REDIRECT_URI
53
- At this step you need to [exchange](https://www.hubrise.com/developers/authentication#get-an-access-token) the `authorization_code` (received as a query param) for a new `access_token`
43
+ ```ruby
44
+ oauth_scope = "location[orders.read]" # adjust to your needs
45
+ authorization_url = client.build_authorization_url(hubrise_oauth_authorize_callback_url, oauth_scope)
46
+ ...
47
+ redirect_to(authorization_url)
48
+ ```
54
49
 
50
+ 4. Complete the OAuth flow
55
51
 
56
- ```ruby
57
- # controllers/hubrise_oauth_controller.rb
52
+ Once the user accepts your request he or she will be redirected to the REDIRECT_URI
53
+ At this step you need to [exchange](https://www.hubrise.com/developers/authentication#get-an-access-token) the `authorization_code` (received as a query param) for a new `access_token`
58
54
 
59
- def authorize_callback
60
- client.authorize!(params[:code])
55
+ ```ruby
56
+ # controllers/hubrise_oauth_controller.rb
61
57
 
62
- current_user.update!(hubrise_access_token: client.access_token)
63
- # account_id = client.account_id
64
- # location_id = client.location_id
65
- end
66
- ```
58
+ def authorize_callback
59
+ client.authorize!(params[:code])
67
60
 
68
- The `access_token` reffers to this specific user's permission so it should be securely persisted and not shared with other users.
61
+ current_user.update!(hubrise_access_token: client.access_token)
62
+ # account_id = client.account_id
63
+ # location_id = client.location_id
64
+ end
65
+ ```
69
66
 
67
+ The `access_token` reffers to this specific user's permission so it should be securely persisted and not shared with other users.
70
68
 
71
69
  # Use the access token
72
70
 
@@ -75,6 +73,7 @@ client = HubriseClient::V1.new(CLIENT_ID, CLIENT_SECRET, access_token: current_u
75
73
  ```
76
74
 
77
75
  Now you can call the [helper methods](https://github.com/HubRise/ruby-client/blob/master/V1_ENDPOINTS.md) on behalf of the user
76
+
78
77
  ```ruby
79
78
  client.get_account
80
79
  ```
@@ -98,7 +97,16 @@ response.each_page do |page_response|
98
97
  end
99
98
  ```
100
99
 
101
- # Publish changes to this gem
100
+ # Development
101
+
102
+ ## Run tests
103
+
104
+ ```bash
105
+ bundle install
106
+ bundle exec rspec
107
+ ```
108
+
109
+ ## Release
102
110
 
103
111
  1. Make sure all local changes are committed.
104
112
 
@@ -107,7 +115,7 @@ end
107
115
  3. Tag the repository:
108
116
 
109
117
  ```bash
110
- VERSION=2.0.14
118
+ VERSION=2.0.16
111
119
  git add lib/hubrise_client/version.rb
112
120
  git commit -m "Version $VERSION"
113
121
  git tag v$VERSION
@@ -122,4 +130,4 @@ rm -f hubrise_client-*.gem
122
130
  gem build hubrise_client
123
131
  gem push hubrise_client-*.gem
124
132
  rm -f hubrise_client-*.gem
125
- ```
133
+ ```
data/V1_ENDPOINTS.md CHANGED
@@ -119,6 +119,38 @@ client = HubriseClient::V1.new(CLIENT_ID, CLIENT_SECRET, client_attrs)
119
119
  # [PATCH] /locations/locationIdX/orders/orderIdX/delivery with { headers: { "Content-Type": "application/json" }, body: "{\"status\":\"delivered\" }" }
120
120
  ```
121
121
 
122
+ ### GET_DELIVERY_QUOTES
123
+
124
+ - Initialized with `client_attrs = { access_token: "accessTokenX" }`
125
+ ```ruby
126
+ client.get_delivery_quotes("locationIdX", "orderIdX")
127
+ # [GET] /locations/locationIdX/orders/orderIdX/delivery_quotes with { headers: { "X-Access-Token": "accessTokenX" }}
128
+ ```
129
+
130
+ ### GET_DELIVERY_QUOTE
131
+
132
+ - Initialized with `client_attrs = { access_token: "accessTokenX" }`
133
+ ```ruby
134
+ client.get_delivery_quote("locationIdX", "orderIdX", "quoteIdX")
135
+ # [GET] /locations/locationIdX/orders/orderIdX/delivery_quotes/quoteIdX with { headers: { "X-Access-Token": "accessTokenX" }}
136
+ ```
137
+
138
+ ### CREATE_DELIVERY_QUOTE
139
+
140
+ - Initialized with `client_attrs = { access_token: "accessTokenX" }`
141
+ ```ruby
142
+ client.create_delivery_quote("locationIdX", "orderIdX", { carrier: "UPS" })
143
+ # [POST] /locations/locationIdX/orders/orderIdX/delivery_quotes with { headers: { "Content-Type": "application/json" }, body: "{\"carrier\":\"UPS\" }" }
144
+ ```
145
+
146
+ ### ACCEPT_DELIVERY_QUOTE
147
+
148
+ - Initialized with `client_attrs = { access_token: "accessTokenX" }`
149
+ ```ruby
150
+ client.accept_delivery_quote("locationIdX", "orderIdX", "quoteIdX")
151
+ # [POST] /locations/locationIdX/orders/orderIdX/delivery_quotes/quoteIdX/accept with { headers: { "X-Access-Token": "accessTokenX" }}
152
+ ```
153
+
122
154
  ### GET_CALLBACK
123
155
 
124
156
  - Initialized with `client_attrs = { access_token: "accessTokenX" }`
@@ -38,8 +38,8 @@ module HubriseClient
38
38
 
39
39
  def build_authorization_url(redirect_uri, scope, params = {})
40
40
  params = params.merge(
41
- redirect_uri: redirect_uri,
42
- scope: scope,
41
+ redirect_uri:,
42
+ scope:,
43
43
  client_id: @app_id
44
44
  )
45
45
 
@@ -83,9 +83,9 @@ module HubriseClient
83
83
  raise(HubriseAccessTokenMissing) if @access_token.nil?
84
84
 
85
85
  api_request(
86
- "#{@api_host}:#{@api_port}/#{version}", path, method, data: data,
87
- json: json,
88
- headers: headers,
86
+ "#{@api_host}:#{@api_port}/#{version}", path, method, data:,
87
+ json:,
88
+ headers:,
89
89
  access_token: @access_token,
90
90
  callback: @request_callback
91
91
  ).perform
@@ -94,9 +94,9 @@ module HubriseClient
94
94
  def api_request(hostname, path, method, attrs = {})
95
95
  Request.from_h(
96
96
  {
97
- hostname: hostname,
98
- path: path,
99
- method: method,
97
+ hostname:,
98
+ path:,
99
+ method:,
100
100
  use_https: @use_https,
101
101
  logger: @verbous && @logger,
102
102
  json: true,
@@ -83,6 +83,25 @@ module HubriseClient
83
83
  call_api("/locations/#{location_id}/orders/#{order_id}/delivery", :patch, data: params)
84
84
  end
85
85
 
86
+ # --------------------
87
+ # Delivery quotes
88
+ # --------------------
89
+ def get_delivery_quotes(location_id, order_id)
90
+ call_api("/locations/#{location_id}/orders/#{order_id}/delivery_quotes")
91
+ end
92
+
93
+ def get_delivery_quote(location_id, order_id, quote_id)
94
+ call_api("/locations/#{location_id}/orders/#{order_id}/delivery_quotes/#{quote_id}")
95
+ end
96
+
97
+ def create_delivery_quote(location_id, order_id, params)
98
+ call_api("/locations/#{location_id}/orders/#{order_id}/delivery_quotes", :post, data: params)
99
+ end
100
+
101
+ def accept_delivery_quote(location_id, order_id, quote_id)
102
+ call_api("/locations/#{location_id}/orders/#{order_id}/delivery_quotes/#{quote_id}/accept", :post)
103
+ end
104
+
86
105
  # --------------------
87
106
  # Callback, events
88
107
  # --------------------
@@ -177,10 +196,10 @@ module HubriseClient
177
196
  # --------------------
178
197
  # Images
179
198
  # --------------------
180
- def create_image(data, mime_type, catalog_id = nil)
181
- call_api("/catalogs/#{catalog_id_fallback(catalog_id)}/images", :post, data: data,
182
- headers: { "Content-Type" => mime_type },
183
- json: false)
199
+ def create_image(data, mime_type, catalog_id = nil, options = {})
200
+ path = "/catalogs/#{catalog_id_fallback(catalog_id)}/images"
201
+ path += "?private_ref=#{CGI.escape(options[:private_ref])}" if options[:private_ref]
202
+ call_api(path, :post, data:, headers: { "Content-Type" => mime_type }, json: false)
184
203
  end
185
204
 
186
205
  def get_images(catalog_id = nil)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module HubriseClient
3
- VERSION = "2.0.14"
3
+ VERSION = "2.0.16"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubrise_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Monnier
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-04-11 00:00:00.000000000 Z
12
+ date: 2025-09-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -39,14 +39,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 2.7.7
42
+ version: 3.1.4
43
43
  required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements: []
49
- rubygems_version: 3.4.20
49
+ rubygems_version: 3.3.26
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: HubRise Ruby client