order_cloud 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +23 -0
- data/README.md +5 -5
- data/git_push.sh +1 -1
- data/lib/order_cloud/api_auth.rb +11 -2
- data/lib/order_cloud/configuration.rb +4 -3
- data/lib/order_cloud/version.rb +1 -1
- data/spec/api_auth_spec.rb +1 -1
- metadata +2 -3
- data/order_cloud-0.0.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fa92c234e765c40fcad785ad62bf60508189748
|
4
|
+
data.tar.gz: 4c092f862bea6d0b0ef10cd9a5d22b3ea5d1b837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40caddc7f35545595a05af2cc0fca41d745c4cf281d4477a7d0abe6dcde0fc6d5202544376f5d5fce41a0180b1f54ea50d56c6760a6f4c315d96f41beea1ec10
|
7
|
+
data.tar.gz: 26670c5091e2c34f544295cf4ae2386f438d075dd5f60b1c7189e53d6a0994b0a24c4a6d06bde1b6c4956e6ef0f74e17689939a514738d66671686f3409eb7e3
|
data/Gemfile
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
=begin
|
2
|
+
#OrderCloud
|
3
|
+
|
4
|
+
#A full ecommerce backend as a service.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
Contact: ordercloud@four51.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
1
24
|
source 'https://rubygems.org'
|
2
25
|
|
3
26
|
gem 'typhoeus'
|
data/README.md
CHANGED
@@ -9,8 +9,8 @@ OrderCloud - the Ruby gem for the OrderCloud
|
|
9
9
|
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
10
10
|
|
11
11
|
- API version: 1.0
|
12
|
-
- Package version: 0.0.
|
13
|
-
- Build date: 2016-09-
|
12
|
+
- Package version: 0.0.4
|
13
|
+
- Build date: 2016-09-27T14:37:05.237-05:00
|
14
14
|
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
15
15
|
|
16
16
|
For more information, please visit [http://public.four51.com/](http://public.four51.com/)
|
@@ -22,7 +22,7 @@ For more information, please visit [http://public.four51.com/](http://public.fou
|
|
22
22
|
|
23
23
|
Add this line to your `Gemfile`:
|
24
24
|
|
25
|
-
gem 'order_cloud', '~> 0.0.
|
25
|
+
gem 'order_cloud', '~> 0.0.4'
|
26
26
|
|
27
27
|
Or run this in your terminal:
|
28
28
|
```shell
|
@@ -57,10 +57,10 @@ user_instance = OrderCloud::UserApi.new
|
|
57
57
|
impersonation_token = user_instance.get_access_token(buyer_id, user_id, { :claims => ['YOUR_CLAIM'] })
|
58
58
|
|
59
59
|
OrderCloud::ApiAuth::start_impersonate(impersonation_token)
|
60
|
-
puts 'Impersonation status: #{
|
60
|
+
puts 'Impersonation status: #{ OrderCloud::Configuration.default.impersonating?}'
|
61
61
|
|
62
62
|
OrderCloud::ApiAuth::stop_impersonate
|
63
|
-
puts 'Impersonation status: #{
|
63
|
+
puts 'Impersonation status: #{ OrderCloud::Configuration.default.impersonating?}'
|
64
64
|
```
|
65
65
|
|
66
66
|
## Example
|
data/git_push.sh
CHANGED
data/lib/order_cloud/api_auth.rb
CHANGED
@@ -55,7 +55,16 @@ module OrderCloud
|
|
55
55
|
)
|
56
56
|
request.on_complete do |response|
|
57
57
|
if response.success?
|
58
|
-
|
58
|
+
token = JSON.parse(response.body)
|
59
|
+
if(token.key?("error"))
|
60
|
+
fail token["error"]
|
61
|
+
else
|
62
|
+
OrderCloud::Configuration.default.access_token = OrderCloud::AccessToken.new({
|
63
|
+
:access_token => token["access_token"],
|
64
|
+
:expires_in => token["expires_in"],
|
65
|
+
:token_type => token["token_type"]
|
66
|
+
})
|
67
|
+
end
|
59
68
|
elsif response.timed_out?
|
60
69
|
fail "HTTP Request timed out"
|
61
70
|
elsif response.code == 0
|
@@ -93,7 +102,7 @@ module OrderCloud
|
|
93
102
|
end
|
94
103
|
|
95
104
|
def self.stop_impersonate
|
96
|
-
OrderCloud::Configuration.default.impersonation_token =
|
105
|
+
OrderCloud::Configuration.default.impersonation_token = nil
|
97
106
|
end
|
98
107
|
end
|
99
108
|
end
|
@@ -33,7 +33,7 @@ module OrderCloud
|
|
33
33
|
|
34
34
|
# Returns true if impersonation is on, false otherwise
|
35
35
|
def impersonating?
|
36
|
-
|
36
|
+
@impersonation_token
|
37
37
|
end
|
38
38
|
|
39
39
|
# Returns the appropriate token
|
@@ -171,7 +171,8 @@ module OrderCloud
|
|
171
171
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
172
172
|
|
173
173
|
@auth_url = 'https://auth.ordercloud.io/oauth/token'
|
174
|
-
@impersonation_token =
|
174
|
+
@impersonation_token = nil
|
175
|
+
@access_token = nil
|
175
176
|
@client_id = ''
|
176
177
|
@scopes = []
|
177
178
|
|
@@ -236,7 +237,7 @@ module OrderCloud
|
|
236
237
|
type: 'oauth2',
|
237
238
|
in: 'header',
|
238
239
|
key: 'Authorization',
|
239
|
-
value: "Bearer #{get_access_token}"
|
240
|
+
value: "Bearer #{get_access_token.access_token}"
|
240
241
|
},
|
241
242
|
}
|
242
243
|
end
|
data/lib/order_cloud/version.rb
CHANGED
data/spec/api_auth_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe OrderCloud::ApiAuth do
|
|
37
37
|
let(:scopes) { ['FullAccess'] }
|
38
38
|
let(:bad_auth_url) { 'thisshouldnotwork.com' }
|
39
39
|
|
40
|
-
let(:impersonation_token) { '4QAtuGBvK8bj22XdT0H5' }
|
40
|
+
let(:impersonation_token) { OrderCloud::AccessToken.new({:access_token => '4QAtuGBvK8bj22XdT0H5', :expires_in => 1000, :token_type => 'Bearer' }) }
|
41
41
|
|
42
42
|
let(:config) { OrderCloud::Configuration.default }
|
43
43
|
before(:each) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: order_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Le Cam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -473,7 +473,6 @@ files:
|
|
473
473
|
- lib/order_cloud/models/web_hook_route.rb
|
474
474
|
- lib/order_cloud/models/xp_index.rb
|
475
475
|
- lib/order_cloud/version.rb
|
476
|
-
- order_cloud-0.0.2.gem
|
477
476
|
- order_cloud.gemspec
|
478
477
|
- spec/api/address_api_spec.rb
|
479
478
|
- spec/api/admin_address_api_spec.rb
|
data/order_cloud-0.0.2.gem
DELETED
Binary file
|