my_john_deere_api 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/my_john_deere_api/authorize.rb +12 -2
- data/lib/my_john_deere_api/client.rb +10 -3
- data/lib/my_john_deere_api/consumer.rb +11 -3
- data/lib/my_john_deere_api/version.rb +1 -1
- data/test/lib/my_john_deere_api/authorize_test.rb +17 -3
- data/test/lib/my_john_deere_api/client_test.rb +16 -2
- data/test/lib/my_john_deere_api/consumer_test.rb +12 -4
- 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: 43721caccbde8bfdc7a91686c00d8b312d3c93f28c6e3b9a3e06575028102d0c
|
4
|
+
data.tar.gz: '09599905c0d5e75026cc716646361b4d4061c56c7fdbba079f149b51b215f3a5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d9d9f4394a30f4e2fe3bf7672af804c7f0979b5ef57237068afaee997c37c94ac68b6ccadec71a8205b2a3646306aa7e1dab8baa0835e29f0a8d37a4618796
|
7
|
+
data.tar.gz: c737bd823842d703840a8e3d54f23b12f6ed3a8945ff67e40ce93902485b6277ee7d8f54c80e15314be3fbe575aad68a8fb51e75d2feec7ee5dd8975c78e6f0c
|
data/README.md
CHANGED
@@ -2,4 +2,10 @@
|
|
2
2
|
|
3
3
|
[![CircleCI](https://circleci.com/gh/Intellifarm/my_john_deere_api.svg?style=svg)](https://circleci.com/gh/Intellifarm/my_john_deere_api)
|
4
4
|
|
5
|
-
|
5
|
+
This client allows you to connect the MyJohnDeere API without having to code your own oauth process, API requests, and pagination.
|
6
|
+
|
7
|
+
* Supports both sandbox and live mode
|
8
|
+
* Simplifies the oAuth negotiation process
|
9
|
+
* Uses ruby enumerables to handle pagination behind the scenes. Calls like `each`, `map`, etc will fetch new pages of data as needed.
|
10
|
+
|
11
|
+
More details coming soon.
|
@@ -5,7 +5,7 @@ class MyJohnDeereApi::Authorize
|
|
5
5
|
:environment, :options
|
6
6
|
|
7
7
|
DEFAULTS = {
|
8
|
-
environment: :
|
8
|
+
environment: :live
|
9
9
|
}
|
10
10
|
|
11
11
|
##
|
@@ -19,7 +19,7 @@ class MyJohnDeereApi::Authorize
|
|
19
19
|
|
20
20
|
@api_key = api_key
|
21
21
|
@api_secret = api_secret
|
22
|
-
|
22
|
+
self.environment = @options[:environment]
|
23
23
|
end
|
24
24
|
|
25
25
|
##
|
@@ -62,4 +62,14 @@ class MyJohnDeereApi::Authorize
|
|
62
62
|
@access_secret = access_object.secret
|
63
63
|
nil
|
64
64
|
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
##
|
69
|
+
# intelligently sets the environment
|
70
|
+
|
71
|
+
def environment=(value)
|
72
|
+
value = value.to_sym
|
73
|
+
@environment = value == :production ? :live : value
|
74
|
+
end
|
65
75
|
end
|
@@ -2,7 +2,7 @@ class MyJohnDeereApi::Client
|
|
2
2
|
attr_reader :api_key, :api_secret, :access_token, :access_secret, :environment
|
3
3
|
|
4
4
|
DEFAULTS = {
|
5
|
-
environment: :
|
5
|
+
environment: :live
|
6
6
|
}
|
7
7
|
|
8
8
|
##
|
@@ -12,7 +12,7 @@ class MyJohnDeereApi::Client
|
|
12
12
|
#
|
13
13
|
# options:
|
14
14
|
#
|
15
|
-
# [:environment] :sandbox or :
|
15
|
+
# [:environment] :sandbox or :live
|
16
16
|
#
|
17
17
|
# [:access] an array with two elements, the access_token
|
18
18
|
# and the access_secret of the given user
|
@@ -27,7 +27,7 @@ class MyJohnDeereApi::Client
|
|
27
27
|
@access_token, @access_secret = options[:access]
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
self.environment = options[:environment]
|
31
31
|
end
|
32
32
|
|
33
33
|
##
|
@@ -81,6 +81,13 @@ class MyJohnDeereApi::Client
|
|
81
81
|
|
82
82
|
private
|
83
83
|
|
84
|
+
##
|
85
|
+
# allows :production param to be a synonym for :live
|
86
|
+
|
87
|
+
def environment=(value)
|
88
|
+
@environment = value == :production ? :live : value
|
89
|
+
end
|
90
|
+
|
84
91
|
##
|
85
92
|
# Returns an oAuth consumer which can be used to build requests
|
86
93
|
|
@@ -7,11 +7,11 @@ module MyJohnDeereApi
|
|
7
7
|
# valid API urls
|
8
8
|
URLS = {
|
9
9
|
sandbox: 'https://sandboxapi.deere.com',
|
10
|
-
|
10
|
+
live: 'https://api.soa-proxy.deere.com',
|
11
11
|
}
|
12
12
|
|
13
13
|
DEFAULTS = {
|
14
|
-
environment: :
|
14
|
+
environment: :live
|
15
15
|
}
|
16
16
|
|
17
17
|
def initialize(api_key, api_secret, options={})
|
@@ -20,7 +20,7 @@ module MyJohnDeereApi
|
|
20
20
|
@api_key = api_key
|
21
21
|
@api_secret = api_secret
|
22
22
|
|
23
|
-
|
23
|
+
self.environment = options[:environment]
|
24
24
|
@base_url = options[:base_url] || URLS[@environment]
|
25
25
|
end
|
26
26
|
|
@@ -41,6 +41,14 @@ module MyJohnDeereApi
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
+
##
|
45
|
+
# intelligently sets the environment
|
46
|
+
|
47
|
+
def environment=(value)
|
48
|
+
value = value.to_sym
|
49
|
+
@environment = value == :production ? :live : value
|
50
|
+
end
|
51
|
+
|
44
52
|
def consumer(site)
|
45
53
|
OAuth::Consumer.new(
|
46
54
|
api_key,
|
@@ -23,13 +23,27 @@ describe 'MyJohnDeereApi::Authorize' do
|
|
23
23
|
assert_equal API_SECRET, authorize.api_secret
|
24
24
|
end
|
25
25
|
|
26
|
-
it 'sets the environment' do
|
26
|
+
it 'sets the sandbox environment' do
|
27
27
|
environment = :sandbox
|
28
28
|
|
29
29
|
authorize = VCR.use_cassette('catalog') { JD::Authorize.new(API_KEY, API_SECRET, environment: environment) }
|
30
30
|
assert_equal environment, authorize.environment
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'sets the live environment' do
|
34
|
+
environment = :live
|
35
|
+
|
36
|
+
authorize = VCR.use_cassette('catalog') { JD::Authorize.new(API_KEY, API_SECRET, environment: environment) }
|
37
|
+
assert_equal environment, authorize.environment
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'accepts production as a synonym for live environment' do
|
41
|
+
environment = :production
|
42
|
+
|
43
|
+
authorize = VCR.use_cassette('catalog') { JD::Authorize.new(API_KEY, API_SECRET, environment: environment) }
|
44
|
+
assert_equal :live, authorize.environment
|
45
|
+
end
|
46
|
+
|
33
47
|
it 'converts environment to symbol' do
|
34
48
|
environment = 'sandbox'
|
35
49
|
|
@@ -37,8 +51,8 @@ describe 'MyJohnDeereApi::Authorize' do
|
|
37
51
|
assert_equal environment.to_sym, authorize.environment
|
38
52
|
end
|
39
53
|
|
40
|
-
it 'defaults
|
41
|
-
environment = :
|
54
|
+
it 'defaults to live environment' do
|
55
|
+
environment = :live
|
42
56
|
|
43
57
|
authorize = VCR.use_cassette('catalog') { JD::Authorize.new(API_KEY, API_SECRET) }
|
44
58
|
assert_equal environment, authorize.environment
|
@@ -19,16 +19,30 @@ describe 'MyJohnDeereApi::Client' do
|
|
19
19
|
assert_equal access_secret, client.access_secret
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'accepts environment' do
|
22
|
+
it 'accepts sandbox environment' do
|
23
23
|
environment = :sandbox
|
24
24
|
|
25
25
|
client = JD::Client.new(API_KEY, API_SECRET, environment: environment)
|
26
26
|
assert_equal environment, client.environment
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
29
|
+
it 'accepts live environment' do
|
30
|
+
environment = :live
|
31
|
+
|
32
|
+
client = JD::Client.new(API_KEY, API_SECRET, environment: environment)
|
33
|
+
assert_equal environment, client.environment
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'accepts production as a synonym for live' do
|
30
37
|
environment = :production
|
31
38
|
|
39
|
+
client = JD::Client.new(API_KEY, API_SECRET, environment: environment)
|
40
|
+
assert_equal :live, client.environment
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'defaults to live environment' do
|
44
|
+
environment = :live
|
45
|
+
|
32
46
|
client = JD::Client.new(API_KEY, API_SECRET)
|
33
47
|
assert_equal environment, client.environment
|
34
48
|
end
|
@@ -17,16 +17,24 @@ describe 'JD::Consumer' do
|
|
17
17
|
assert_equal JD::Consumer::URLS[environment], consumer.base_url
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'accepts
|
21
|
-
environment = :
|
20
|
+
it 'accepts live environment' do
|
21
|
+
environment = :live
|
22
22
|
consumer = JD::Consumer.new(API_KEY, API_SECRET, environment: environment)
|
23
23
|
|
24
24
|
assert_equal environment, consumer.environment
|
25
25
|
assert_equal JD::Consumer::URLS[environment], consumer.base_url
|
26
26
|
end
|
27
27
|
|
28
|
-
it '
|
29
|
-
|
28
|
+
it 'accepts production as a synonym for live environment' do
|
29
|
+
environment = :production
|
30
|
+
consumer = JD::Consumer.new(API_KEY, API_SECRET, environment: environment)
|
31
|
+
|
32
|
+
assert_equal :live, consumer.environment
|
33
|
+
assert_equal JD::Consumer::URLS[:live], consumer.base_url
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'defaults to live environment' do
|
37
|
+
default_environment = :live
|
30
38
|
consumer = JD::Consumer.new(API_KEY, API_SECRET)
|
31
39
|
|
32
40
|
assert_equal default_environment, consumer.environment
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_john_deere_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaime Bellmyer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-01-
|
12
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vcr
|