tops_connect 0.1.4 → 0.2.0
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 +2 -5
- data/lib/tops_connect/base.rb +3 -3
- data/lib/tops_connect/client.rb +9 -9
- data/lib/tops_connect/communities.rb +5 -5
- data/lib/tops_connect/community.rb +4 -3
- data/lib/tops_connect/configuration.rb +1 -10
- data/lib/tops_connect/owner.rb +3 -1
- data/lib/tops_connect/owners.rb +5 -5
- data/lib/tops_connect/version.rb +1 -1
- data/tops_connect.gemspec +3 -3
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5867e71a798feb5d737263d749fb3b4dd009a19f
|
4
|
+
data.tar.gz: b5510fb2c07a486eac402485f78fdbba12f02134
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80f5fb0f17b286f461ad626600ad4555693955a6b2dd7b1d3c30ab728766ac2c005c86a5335f2c86f068b5bed496c96d22c29c345101ffc8b1adb8bb70ecd589
|
7
|
+
data.tar.gz: 1a57806bd996195daba9aa889c64644558c949f53283f167b21135928d5375c9c4b20edae8a529ea63d2eb6d8c559ee93b2157ec69a217279ba20daa0a966cd5
|
data/README.md
CHANGED
@@ -25,15 +25,12 @@ TopsConnect.configure do |config|
|
|
25
25
|
config.subscription_key = '0123456789abcdef0123456789abcdef'
|
26
26
|
config.client_id = '00000000-1111-2222-3333-444444444444'
|
27
27
|
config.software_key = '55555555-6666-7777-8888-999999999999'
|
28
|
-
config.community_api_key = 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE'
|
29
28
|
config.zone = :broad
|
30
29
|
end
|
31
30
|
|
32
|
-
tops = TopsConnect::Client.new
|
31
|
+
tops = TopsConnect::Client.new(6, 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE')
|
33
32
|
|
34
|
-
tops.
|
35
|
-
puts community['Name']
|
36
|
-
end
|
33
|
+
puts "Loaded #{tops.community.name}"
|
37
34
|
```
|
38
35
|
|
39
36
|
## Development
|
data/lib/tops_connect/base.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module TopsConnect
|
3
3
|
class Base
|
4
|
-
|
5
|
-
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
6
|
end
|
7
7
|
|
8
8
|
def get(*args)
|
9
|
-
|
9
|
+
@client.get(*args)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/tops_connect/client.rb
CHANGED
@@ -5,31 +5,31 @@ module TopsConnect
|
|
5
5
|
include TopsConnect::Communities
|
6
6
|
include TopsConnect::Owners
|
7
7
|
|
8
|
+
attr_reader :community_id, :community_api_key
|
9
|
+
|
8
10
|
headers 'Content-Type' => 'application/json'
|
9
11
|
headers 'api-version' => '1'
|
10
12
|
|
11
13
|
base_uri 'https://topsconnectapi.azure-api.net'
|
12
14
|
|
13
|
-
def initialize
|
15
|
+
def initialize(community_id, community_api_key)
|
14
16
|
authorization = Base64.strict_encode64 [
|
15
17
|
TopsConnect.configuration.client_id,
|
16
18
|
TopsConnect.configuration.software_key
|
17
19
|
].join(':')
|
18
20
|
|
19
|
-
self.class.headers(
|
20
|
-
'authorization' => "Basic #{authorization}",
|
21
|
-
'community-api-key' => TopsConnect.configuration.community_api_key
|
22
|
-
)
|
21
|
+
self.class.headers('authorization' => "Basic #{authorization}")
|
23
22
|
|
24
23
|
@subscription_key = TopsConnect.configuration.subscription_key
|
25
|
-
|
26
|
-
|
24
|
+
@community_id = community_id
|
25
|
+
@community_api_key = community_api_key
|
27
26
|
end
|
28
27
|
|
29
|
-
def get(endpoint,
|
28
|
+
def get(endpoint, headers: {}, query: {})
|
30
29
|
response = self.class.get(
|
31
30
|
"/#{TopsConnect.configuration.zone}/api#{endpoint}",
|
32
|
-
query:
|
31
|
+
query: query.merge('subscription-key' => @subscription_key),
|
32
|
+
headers: headers.merge('community-api-key' => @community_api_key)
|
33
33
|
)
|
34
34
|
|
35
35
|
case response.code
|
@@ -3,16 +3,16 @@ module TopsConnect
|
|
3
3
|
module Communities
|
4
4
|
# Method: GET
|
5
5
|
# Endpoint: Community_GetList
|
6
|
+
# Returns: Array<Hash>
|
6
7
|
def communities
|
7
|
-
get('/community')
|
8
|
-
TopsConnect::Community.new community['CommunityKey'], community
|
9
|
-
end
|
8
|
+
get('/community')
|
10
9
|
end
|
11
10
|
|
12
11
|
# Method: GET
|
13
12
|
# Endpoint: Community_Get
|
14
|
-
|
15
|
-
|
13
|
+
# Returns: TopsConnect::Community
|
14
|
+
def community
|
15
|
+
TopsConnect::Community.new self
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -3,9 +3,10 @@ module TopsConnect
|
|
3
3
|
class Community < Base
|
4
4
|
attr_reader :id
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@id = id.to_i
|
6
|
+
def initialize(client, data = nil)
|
8
7
|
@data = data
|
8
|
+
|
9
|
+
super client
|
9
10
|
end
|
10
11
|
|
11
12
|
def data
|
@@ -13,7 +14,7 @@ module TopsConnect
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def reload!
|
16
|
-
@data = get "/community/#{@
|
17
|
+
@data = get "/community/#{@client.community_id}"
|
17
18
|
end
|
18
19
|
|
19
20
|
def code
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module TopsConnect
|
3
3
|
class Configuration
|
4
|
-
attr_reader :subscription_key, :client_id, :software_key,
|
5
|
-
:community_api_key, :zone
|
4
|
+
attr_reader :subscription_key, :client_id, :software_key, :zone
|
6
5
|
|
7
6
|
def initialize
|
8
7
|
end
|
@@ -31,14 +30,6 @@ module TopsConnect
|
|
31
30
|
@software_key = key.upcase
|
32
31
|
end
|
33
32
|
|
34
|
-
def community_api_key=(key)
|
35
|
-
unless key =~ /\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/
|
36
|
-
raise 'Invalid TOPS Community API Key. Expected a GUID.'
|
37
|
-
end
|
38
|
-
|
39
|
-
@community_api_key = key.upcase
|
40
|
-
end
|
41
|
-
|
42
33
|
def zone=(new_zone)
|
43
34
|
unless %i(broad limited sandbox).include?(new_zone.to_sym)
|
44
35
|
raise 'Invalid TOPS Zone. Accepted values are broad, limited, sandbox.'
|
data/lib/tops_connect/owner.rb
CHANGED
data/lib/tops_connect/owners.rb
CHANGED
@@ -4,17 +4,17 @@ module TopsConnect
|
|
4
4
|
# Method: GET
|
5
5
|
# Endpoint: Owner_Get
|
6
6
|
def owner(owner_id)
|
7
|
-
TopsConnect::Owner.new owner_id
|
7
|
+
TopsConnect::Owner.new self, owner_id, get("/owner/#{owner_id}")
|
8
8
|
end
|
9
9
|
|
10
10
|
# Method: GET
|
11
11
|
# Endpoint: Owner_GetList
|
12
12
|
def owners(property_id = nil)
|
13
|
-
|
14
|
-
|
13
|
+
query = {}
|
14
|
+
query['PropertyKey'] = property_id.to_i if property_id
|
15
15
|
|
16
|
-
get('/owner',
|
17
|
-
TopsConnect::Owner.new owner['OwnerKey'], owner
|
16
|
+
get('/owner', query: query).map do |owner|
|
17
|
+
TopsConnect::Owner.new self, owner['OwnerKey'], owner
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/tops_connect/version.rb
CHANGED
data/tops_connect.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
24
|
-
spec.add_development_dependency 'rake', '
|
25
|
-
spec.add_development_dependency 'rspec'
|
26
|
-
spec.add_development_dependency 'webmock'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
26
|
+
spec.add_development_dependency 'webmock', '~> 2.0'
|
27
27
|
|
28
28
|
spec.add_dependency 'httparty', '~> 0.13'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tops_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Hoffman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,44 +28,44 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '2.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|