hubrise_client 2.0.14 → 2.0.15
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 +4 -4
- data/README.md +46 -38
- data/lib/hubrise_client/v1.rb +4 -4
- data/lib/hubrise_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b05c00e55ba2498337eacf6f67d8d8e4c56a48d41c7bdb280dd475219efff7c6
|
4
|
+
data.tar.gz: '079dc44ad7cd1728fbf50fe5c8a6226d78615a8738a01655fe23e9ba8f5af056'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25477048e5358e52ed29bc5a32294dbfad3c9a703388bb8a5fa698c64fcc3a236596d0c1e70fe7f7c22217322ab6ce52881c35ade25b062599229d5828ef5a8c
|
7
|
+
data.tar.gz: 1e51ad7068e667ed17640456e80d6ecf3802bb7d1904ac6d0860f2f33a1a0939ef9654c81bbd4f5eb6f1f1808e8ceb98e38ab9f19d6a2977d8079303b3d92596
|
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
|
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
|
-
|
29
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
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
|
-
|
53
|
-
|
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
|
-
|
57
|
-
|
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
|
-
|
60
|
-
|
55
|
+
```ruby
|
56
|
+
# controllers/hubrise_oauth_controller.rb
|
61
57
|
|
62
|
-
|
63
|
-
|
64
|
-
# location_id = client.location_id
|
65
|
-
end
|
66
|
-
```
|
58
|
+
def authorize_callback
|
59
|
+
client.authorize!(params[:code])
|
67
60
|
|
68
|
-
|
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
|
-
#
|
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.
|
118
|
+
VERSION=2.0.9
|
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/lib/hubrise_client/v1.rb
CHANGED
@@ -177,10 +177,10 @@ module HubriseClient
|
|
177
177
|
# --------------------
|
178
178
|
# Images
|
179
179
|
# --------------------
|
180
|
-
def create_image(data, mime_type, catalog_id = nil)
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
def create_image(data, mime_type, catalog_id = nil, options = {})
|
181
|
+
path = "/catalogs/#{catalog_id_fallback(catalog_id)}/images"
|
182
|
+
path += "?private_ref=#{CGI.escape(options[:private_ref])}" if options[:private_ref]
|
183
|
+
call_api(path, :post, data: data, headers: { "Content-Type" => mime_type }, json: false)
|
184
184
|
end
|
185
185
|
|
186
186
|
def get_images(catalog_id = nil)
|
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.
|
4
|
+
version: 2.0.15
|
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-
|
12
|
+
date: 2025-06-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|