nuorder 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/nuorder.rb +4 -3
- data/lib/nuorder/client.rb +7 -6
- data/lib/nuorder/version.rb +1 -1
- data/spec/nuorder/client_spec.rb +38 -45
- data/spec/nuorder_spec.rb +3 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c9905d128b4337115539c618b22c2ab5dd3509a
|
4
|
+
data.tar.gz: 96474ad261bdf5de1c0b69873ae9d5e57f98b002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ee768824c8f394b75663d190253690f7c807ef2bc16839e6a0fa1c5345b2537e7cd83b01152befc917efd07b135a8fbaf7df6878f49dc6d48ccec02f0dca6d0
|
7
|
+
data.tar.gz: 9824264e27139b65bf95227590f9010b31bbf787078d1866405e47045baed6b7eced36b142c7648f137bc43174d563cf405db6cf0167d8b781e2409a396fbb65
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,7 @@ The following options are available when configuring NuORDER:
|
|
37
37
|
6. `oauth_token_secret`
|
38
38
|
7. `oauth_callback` Default: `'oob'`
|
39
39
|
* NuORDER will POST the callback the `oauth_verifier` token.
|
40
|
-
* If the callback is set to `'oob'`, the `oauth_verifier` token must be supplied manually by the user.
|
40
|
+
* If the callback is set to `'oob'`, the `oauth_verifier` token must be supplied manually by the user.
|
41
41
|
|
42
42
|
#### Example
|
43
43
|
|
@@ -66,7 +66,7 @@ To get the oauth tokens the following methods must be called:
|
|
66
66
|
* An inital call will be made in order to get the temporary tokens.
|
67
67
|
2. `Nuorder.get_oauth_token(oauth_verifier)`
|
68
68
|
* Call for getting the permanent tokens.
|
69
|
-
* `oauth_verifier` must be supplied.
|
69
|
+
* `oauth_verifier` must be supplied.
|
70
70
|
|
71
71
|
Retrieve tokens:
|
72
72
|
|
data/lib/nuorder.rb
CHANGED
@@ -8,6 +8,10 @@ module Nuorder
|
|
8
8
|
extend Nuorder::Configurable
|
9
9
|
|
10
10
|
class << self
|
11
|
+
def new(options = {})
|
12
|
+
Nuorder::Client.new(options)
|
13
|
+
end
|
14
|
+
|
11
15
|
def client
|
12
16
|
@client = Nuorder::Client.new(options) unless defined?(@client) && @client.same_options?(options)
|
13
17
|
@client
|
@@ -21,7 +25,4 @@ module Nuorder
|
|
21
25
|
client.send(method_name, *args, &block)
|
22
26
|
end
|
23
27
|
end
|
24
|
-
|
25
28
|
end
|
26
|
-
|
27
|
-
Nuorder.setup
|
data/lib/nuorder/client.rb
CHANGED
@@ -11,6 +11,7 @@ module Nuorder
|
|
11
11
|
include Nuorder::Client::Oauth
|
12
12
|
|
13
13
|
def initialize(options = {})
|
14
|
+
options = Nuorder::Default.options.merge(options)
|
14
15
|
set_instance_variables(options)
|
15
16
|
end
|
16
17
|
|
@@ -23,8 +24,8 @@ module Nuorder
|
|
23
24
|
headers = oauth_headers('GET', '/api/initiate', addons)
|
24
25
|
response = connection.get '/api/initiate', {}, headers
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
@oauth_token = response.body['oauth_token']
|
28
|
+
@oauth_token_secret = response.body['oauth_token_secret']
|
28
29
|
|
29
30
|
response
|
30
31
|
end
|
@@ -35,8 +36,8 @@ module Nuorder
|
|
35
36
|
headers = oauth_headers('GET', '/api/token', { 'oauth_verifier' => oauth_verifier })
|
36
37
|
response = connection.get '/api/token', {}, headers
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
@oauth_token = response.body['oauth_token']
|
40
|
+
@oauth_token_secret = response.body['oauth_token_secret']
|
40
41
|
|
41
42
|
response
|
42
43
|
end
|
@@ -65,10 +66,10 @@ module Nuorder
|
|
65
66
|
|
66
67
|
private
|
67
68
|
|
68
|
-
# Set instance variables passed in options
|
69
|
+
# Set instance variables passed in options
|
69
70
|
def set_instance_variables(options)
|
70
71
|
Nuorder::Configurable.keys.each do |key|
|
71
|
-
instance_variable_set(:"@#{key}", options[key]
|
72
|
+
instance_variable_set(:"@#{key}", options[key])
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
data/lib/nuorder/version.rb
CHANGED
data/spec/nuorder/client_spec.rb
CHANGED
@@ -1,54 +1,48 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Nuorder::Client do
|
4
|
-
before do
|
5
|
-
Nuorder.reset!
|
6
|
-
end
|
7
|
-
|
8
|
-
after do
|
9
|
-
Nuorder.reset!
|
10
|
-
end
|
11
|
-
|
12
4
|
include_examples 'options client'
|
13
5
|
|
14
6
|
specify { expect { described_class.new }.not_to raise_error }
|
15
|
-
|
7
|
+
|
16
8
|
subject(:client) do
|
17
9
|
described_class.new(options_client)
|
18
10
|
end
|
19
11
|
|
20
12
|
describe 'module configuration' do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
13
|
+
let (:opts) do
|
14
|
+
{
|
15
|
+
app_name: 'My APP',
|
16
|
+
oauth_callback: 'app.example.com/callback',
|
17
|
+
oauth_consumer_key: 'asdfa232042sdafal'
|
18
|
+
}
|
28
19
|
end
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
describe 'with options' do
|
22
|
+
it "doesn't share state with global options" do
|
23
|
+
client = Nuorder::Client.new(opts)
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
expect(client.
|
25
|
+
Nuorder.configure do |config|
|
26
|
+
config.app_name = 'Nuorder app'
|
27
|
+
end
|
28
|
+
expect(client.app_name).to eq('My APP')
|
38
29
|
end
|
39
|
-
end
|
40
30
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
oauth_consumer_key: 'asdfa232042sdafal'
|
47
|
-
}
|
31
|
+
it 'overrides module configuration' do
|
32
|
+
client = Nuorder::Client.new(opts)
|
33
|
+
expect(client.app_name).to eq('My APP')
|
34
|
+
expect(client.oauth_callback).to eq('app.example.com/callback')
|
35
|
+
expect(client.oauth_consumer_key).to eq('asdfa232042sdafal')
|
48
36
|
end
|
37
|
+
end
|
49
38
|
|
39
|
+
describe '#configure' do
|
50
40
|
it 'overrides module configuration' do
|
51
|
-
client
|
41
|
+
client.configure do |config|
|
42
|
+
config.app_name = opts[:app_name]
|
43
|
+
config.oauth_callback = opts[:oauth_callback]
|
44
|
+
config.oauth_consumer_key = opts[:oauth_consumer_key]
|
45
|
+
end
|
52
46
|
expect(client.app_name).to eq('My APP')
|
53
47
|
expect(client.oauth_callback).to eq('app.example.com/callback')
|
54
48
|
expect(client.oauth_consumer_key).to eq('asdfa232042sdafal')
|
@@ -57,30 +51,29 @@ describe Nuorder::Client do
|
|
57
51
|
end
|
58
52
|
|
59
53
|
describe '#api_initiate' do
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
54
|
+
let(:client) do
|
55
|
+
described_class.new(
|
56
|
+
options_client.merge(oauth_token: nil, oauth_token_secret: nil)
|
57
|
+
)
|
65
58
|
end
|
66
59
|
|
67
60
|
it 'returns temp oauth_token and oauth_token_secret from API', :vcr do
|
68
61
|
client.api_initiate
|
69
62
|
|
70
|
-
expect(
|
71
|
-
expect(
|
63
|
+
expect(client.oauth_token).not_to be_nil
|
64
|
+
expect(client.oauth_token_secret).not_to be_nil
|
72
65
|
end
|
73
66
|
end
|
74
|
-
|
67
|
+
|
75
68
|
describe '#get_oauth_token' do
|
76
69
|
it 'returns real oauth_token and oauth_token_secret from API', :vcr do
|
77
70
|
oauth_verifier = 'aKRzurszYEA9mpun'
|
78
|
-
|
79
|
-
|
80
|
-
|
71
|
+
client.oauth_token = 'p5UzX46KqwdB5Bj3'
|
72
|
+
client.oauth_token_secret = 'YaRS2Vy9uSEDVhwu95NaCDPQ'
|
73
|
+
|
81
74
|
client.get_oauth_token(oauth_verifier)
|
82
|
-
expect(
|
83
|
-
expect(
|
75
|
+
expect(client.oauth_token).not_to be_nil
|
76
|
+
expect(client.oauth_token_secret).not_to be_nil
|
84
77
|
end
|
85
78
|
|
86
79
|
context 'no oauth_verifier provided' do
|
data/spec/nuorder_spec.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Nuorder do
|
4
|
-
|
5
|
-
Nuorder
|
6
|
-
|
7
|
-
|
8
|
-
after do
|
9
|
-
Nuorder.reset!
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'sets defaults' do
|
13
|
-
Nuorder::Configurable.keys.each do |key|
|
14
|
-
expect(Nuorder.instance_variable_get(:"@#{key}")).to eq(Nuorder::Default.options[key])
|
4
|
+
describe '#new' do
|
5
|
+
it 'creates a Nuorder::Client' do
|
6
|
+
expect(Nuorder.new).to be_kind_of Nuorder::Client
|
15
7
|
end
|
16
8
|
end
|
17
9
|
|
@@ -44,5 +36,4 @@ describe Nuorder do
|
|
44
36
|
end
|
45
37
|
end
|
46
38
|
end
|
47
|
-
|
48
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nuorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Springboard Retail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|