tops_connect 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -17
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/lib/tops_connect/client.rb +4 -5
- data/lib/tops_connect/communities.rb +3 -3
- data/lib/tops_connect/configuration.rb +3 -3
- data/lib/tops_connect/errors.rb +12 -1
- data/lib/tops_connect/owner.rb +30 -19
- data/lib/tops_connect/property.rb +7 -6
- data/lib/tops_connect/version.rb +1 -1
- data/tops_connect.gemspec +17 -18
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9e0900387c5f85dd15922e37502820ad5ee15042312e15b3eb855079e662b06
|
4
|
+
data.tar.gz: 4bfa6fd9cf330257df1dbb962dc56d76bfe2de776506a6681cec6bb84e384389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba3de1e94b3ea6dec558f0f8a36dee04f891d4915db9a03ec30e61585fb44509d8dfb4bc1c8ea1ce108662e9c00c4d94a41fe0994cb9b1b7f4af053de7bc6b80
|
7
|
+
data.tar.gz: 2a405e7ea5799f377a236723643ed0b5935c245ad71687743437bbb76809395c7bdcca108dcd365f4635fbb9fa450628294aa87b051a64c20d49b3269e2e9386
|
data/.rubocop.yml
CHANGED
@@ -1,23 +1,12 @@
|
|
1
1
|
AllCops:
|
2
|
-
Include:
|
3
|
-
- Gemfile
|
4
|
-
- Rakefile
|
5
2
|
TargetRubyVersion: 2.5
|
6
3
|
|
7
|
-
Metrics/AbcSize:
|
8
|
-
Enabled: false
|
9
|
-
|
10
|
-
Metrics/CyclomaticComplexity:
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
Metrics/MethodLength:
|
14
|
-
Max: 32
|
15
|
-
|
16
|
-
Metrics/PerceivedComplexity:
|
17
|
-
Enabled: false
|
18
|
-
|
19
4
|
Style/Documentation:
|
20
5
|
Enabled: false
|
21
6
|
|
22
|
-
|
23
|
-
|
7
|
+
Layout/MultilineMethodCallIndentation:
|
8
|
+
EnforcedStyle: indented
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*.rb'
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/tops_connect/client.rb
CHANGED
@@ -11,6 +11,7 @@ module TopsConnect
|
|
11
11
|
|
12
12
|
headers 'Content-Type' => 'application/json'
|
13
13
|
|
14
|
+
# TODO: Sandbox uses /sandbox/api/v2, Broad uses /v2/broad/api
|
14
15
|
base_uri 'https://topsconnectapi.azure-api.net/v2'
|
15
16
|
|
16
17
|
def initialize(community_id, community_api_key)
|
@@ -73,12 +74,10 @@ module TopsConnect
|
|
73
74
|
|
74
75
|
def raise_exception(response)
|
75
76
|
case response.code
|
76
|
-
when 404
|
77
|
-
|
78
|
-
when 400..499
|
79
|
-
raise TopsConnect::ClientError, response
|
77
|
+
when 404 then raise TopsConnect::NotFoundError, response
|
78
|
+
when 400..499 then raise TopsConnect::ClientError, response
|
80
79
|
when 500..599
|
81
|
-
message = response.parsed_response
|
80
|
+
message = TopsConnect::ApiError.error_message(response.parsed_response)
|
82
81
|
|
83
82
|
# These errors can largely be ignored - it's not our fault
|
84
83
|
raise TopsConnect::TimeoutError, response if message['Timeout expired']
|
@@ -24,9 +24,9 @@ module TopsConnect
|
|
24
24
|
def charge_codes
|
25
25
|
get('/chargecode').map do |charge_code|
|
26
26
|
{
|
27
|
-
key: charge_code['
|
28
|
-
code: charge_code['
|
29
|
-
description: charge_code['
|
27
|
+
key: charge_code['key'],
|
28
|
+
code: charge_code['code'],
|
29
|
+
description: charge_code['description']
|
30
30
|
}
|
31
31
|
end
|
32
32
|
end
|
@@ -5,7 +5,7 @@ module TopsConnect
|
|
5
5
|
attr_reader :subscription_key, :client_id, :software_key, :zone
|
6
6
|
|
7
7
|
def subscription_key=(key)
|
8
|
-
unless key
|
8
|
+
unless key&.match?(/\A\h{32}\z/i)
|
9
9
|
raise 'Invalid TOPS Subscription Key. Expected 32 hex characters.'
|
10
10
|
end
|
11
11
|
|
@@ -13,7 +13,7 @@ module TopsConnect
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def client_id=(key)
|
16
|
-
unless key
|
16
|
+
unless key&.match?(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
|
17
17
|
raise 'Invalid TOPS Client ID. Expected a GUID.'
|
18
18
|
end
|
19
19
|
|
@@ -21,7 +21,7 @@ module TopsConnect
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def software_key=(key)
|
24
|
-
unless key
|
24
|
+
unless key&.match?(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
|
25
25
|
raise 'Invalid TOPS Software Key. Expected a GUID.'
|
26
26
|
end
|
27
27
|
|
data/lib/tops_connect/errors.rb
CHANGED
@@ -10,10 +10,21 @@ module TopsConnect
|
|
10
10
|
format(
|
11
11
|
'%<code>s: %<message>s (%<uri>s)',
|
12
12
|
code: @response.code,
|
13
|
-
message: @response.parsed_response
|
13
|
+
message: self.class.error_message(@response.parsed_response),
|
14
14
|
uri: @response.request.last_uri.to_s
|
15
15
|
)
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.error_message(parsed_response)
|
19
|
+
case parsed_response
|
20
|
+
when String
|
21
|
+
parsed_response
|
22
|
+
when Hash
|
23
|
+
parsed_response.dig('Message')
|
24
|
+
else
|
25
|
+
''
|
26
|
+
end
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
# The client submitted invalid information.
|
data/lib/tops_connect/owner.rb
CHANGED
@@ -8,25 +8,10 @@ module TopsConnect
|
|
8
8
|
alias id owner_key
|
9
9
|
|
10
10
|
def alternate_mailing_addresses
|
11
|
-
data['Addresses']
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if row['AddressLine1'].match?(/[[:graph:]]/)
|
17
|
-
lines << row['AddressLine1']
|
18
|
-
end
|
19
|
-
|
20
|
-
if row['AddressLine2'].match?(/[[:graph:]]/)
|
21
|
-
lines << row['AddressLine2']
|
22
|
-
end
|
23
|
-
|
24
|
-
next if lines.empty?
|
25
|
-
|
26
|
-
lines << "#{row['City']}, #{row['State']} #{row['Zip']}"
|
27
|
-
|
28
|
-
lines.map(&:strip).join("\n")
|
29
|
-
end.compact
|
11
|
+
data['Addresses']
|
12
|
+
.select { |row| row['Type']['Name'] == 'Alternate' }
|
13
|
+
.map { |row| offsite_address(row) }
|
14
|
+
.compact
|
30
15
|
end
|
31
16
|
|
32
17
|
def property_key
|
@@ -108,5 +93,31 @@ module TopsConnect
|
|
108
93
|
def tops_id
|
109
94
|
data['Metadata']['TopsId']
|
110
95
|
end
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
def offsite_address(address)
|
100
|
+
lines = address_lines(address)
|
101
|
+
|
102
|
+
return if lines.empty?
|
103
|
+
|
104
|
+
lines << "#{address['City']}, #{address['State']} #{address['Zip']}"
|
105
|
+
|
106
|
+
lines.map(&:strip).join("\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
def address_lines(address)
|
110
|
+
lines = []
|
111
|
+
|
112
|
+
if address['AddressLine1'].match?(/[[:graph:]]/)
|
113
|
+
lines << address['AddressLine1']
|
114
|
+
end
|
115
|
+
|
116
|
+
if address['AddressLine2'].match?(/[[:graph:]]/)
|
117
|
+
lines << address['AddressLine2']
|
118
|
+
end
|
119
|
+
|
120
|
+
lines
|
121
|
+
end
|
111
122
|
end
|
112
123
|
end
|
@@ -13,18 +13,15 @@ module TopsConnect
|
|
13
13
|
|
14
14
|
def address
|
15
15
|
property = data['Addresses']
|
16
|
-
.find { |row| row
|
16
|
+
.find { |row| row.dig('Type', 'Name') == 'Property' }
|
17
17
|
|
18
18
|
lines = [
|
19
19
|
property['AddressLine1'],
|
20
20
|
property['AddressLine2'],
|
21
|
-
|
21
|
+
city_state_zip
|
22
22
|
]
|
23
23
|
|
24
|
-
lines
|
25
|
-
.map(&:strip)
|
26
|
-
.select { |line| line.match?(/[[:graph:]]/) }
|
27
|
-
.join("\n")
|
24
|
+
lines.map(&:strip).select { |line| line.match?(/[[:graph:]]/) }.join("\n")
|
28
25
|
end
|
29
26
|
|
30
27
|
def community_key
|
@@ -37,5 +34,9 @@ module TopsConnect
|
|
37
34
|
Time.parse data['Metadata']['ModifiedDate']
|
38
35
|
end
|
39
36
|
alias updated_at modified_date
|
37
|
+
|
38
|
+
def city_state_zip
|
39
|
+
"#{property['City']}, #{property['State']} #{property['Zip']}"
|
40
|
+
end
|
40
41
|
end
|
41
42
|
end
|
data/lib/tops_connect/version.rb
CHANGED
data/tops_connect.gemspec
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'tops_connect/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = 'tops_connect'
|
9
|
+
spec.version = TopsConnect::VERSION
|
10
|
+
spec.authors = ['Steven Hoffman']
|
11
|
+
spec.email = ['shoffman@valenciamgmt.com']
|
12
12
|
|
13
|
-
spec.summary
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
13
|
+
spec.summary = 'Make use of the Tops Connect API'
|
14
|
+
spec.homepage = 'https://github.com/ValenciaMgmt/tops_connect'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
|
19
|
-
spec.
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
20
|
spec.require_paths = ['lib']
|
22
21
|
|
23
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
24
|
-
spec.add_development_dependency 'rake', '~>
|
25
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
26
|
-
spec.add_development_dependency 'webmock', '~>
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
23
|
+
spec.add_development_dependency 'rake', '~> 12'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
25
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
27
26
|
|
28
|
-
spec.add_dependency 'httparty', '~> 0.
|
27
|
+
spec.add_dependency 'httparty', '~> 0.16'
|
29
28
|
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.6.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: 2018-
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12'
|
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
|
-
version: '
|
40
|
+
version: '12'
|
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: '3.
|
47
|
+
version: '3.7'
|
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: '3.
|
54
|
+
version: '3.7'
|
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: '
|
61
|
+
version: '3.4'
|
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: '
|
68
|
+
version: '3.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.16'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.16'
|
83
83
|
description:
|
84
84
|
email:
|
85
85
|
- shoffman@valenciamgmt.com
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.7.
|
132
|
+
rubygems_version: 2.7.7
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Make use of the Tops Connect API
|