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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e693e4f20693b51e9ef1729c307abae6e8e49cd0d92a04fa8f79a9c83ab43c60
4
- data.tar.gz: cc1f4bcc3c10588236114facebba06c693eafa5a20f930a109510ce6c2fd2828
3
+ metadata.gz: f9e0900387c5f85dd15922e37502820ad5ee15042312e15b3eb855079e662b06
4
+ data.tar.gz: 4bfa6fd9cf330257df1dbb962dc56d76bfe2de776506a6681cec6bb84e384389
5
5
  SHA512:
6
- metadata.gz: 8d27cd2cfbfc12ca9e3199fb2893ce1540e5f0c6de448306d346b93a053879e8b7621811fadf0de1ba6541f8d2c80cc507e9a642857251d66c099ef16476b1ea
7
- data.tar.gz: 90b74c5944b310533fc7b521340712c550c3369c74f42fd3dc6afe6e181d6bae41df4288ee7f192165126c0adf32eb93035eb554bd1b2fb5f1bbb4db9513d726
6
+ metadata.gz: ba3de1e94b3ea6dec558f0f8a36dee04f891d4915db9a03ec30e61585fb44509d8dfb4bc1c8ea1ce108662e9c00c4d94a41fe0994cb9b1b7f4af053de7bc6b80
7
+ data.tar.gz: 2a405e7ea5799f377a236723643ed0b5935c245ad71687743437bbb76809395c7bdcca108dcd365f4635fbb9fa450628294aa87b051a64c20d49b3269e2e9386
@@ -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
- Style/MultilineMethodCallIndentation:
23
- Enabled: false
7
+ Layout/MultilineMethodCallIndentation:
8
+ EnforcedStyle: indented
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - 'spec/**/*.rb'
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  source 'https://rubygems.org'
3
4
 
4
5
  # Specify your gem's dependencies in tops_connect.gemspec
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rspec/core/rake_task'
3
4
  require 'bundler/gem_tasks'
4
5
 
@@ -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
- raise TopsConnect::NotFoundError, response
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&.dig('Message') || ''
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['ChargeCodeKey'],
28
- code: charge_code['Code'],
29
- description: charge_code['Description']
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.match?(/\A\h{32}\z/i)
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.match?(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
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.match?(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
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
 
@@ -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&.dig('Message'),
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.
@@ -8,25 +8,10 @@ module TopsConnect
8
8
  alias id owner_key
9
9
 
10
10
  def alternate_mailing_addresses
11
- data['Addresses'].map do |row|
12
- next unless row['Type']['Name'] == 'Alternate'
13
-
14
- lines = []
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['Type']['Name'] == 'Property' }
16
+ .find { |row| row.dig('Type', 'Name') == 'Property' }
17
17
 
18
18
  lines = [
19
19
  property['AddressLine1'],
20
20
  property['AddressLine2'],
21
- "#{property['City']}, #{property['State']} #{property['Zip']}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TopsConnect
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -1,29 +1,28 @@
1
1
  # frozen_string_literal: true
2
- # coding: utf-8
3
- lib = File.expand_path('../lib', __FILE__)
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 = 'tops_connect'
9
- spec.version = TopsConnect::VERSION
10
- spec.authors = ['Steven Hoffman']
11
- spec.email = ['shoffman@valenciamgmt.com']
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 = 'Make use of the Tops Connect API'
14
- spec.homepage = 'https://github.com/ValenciaMgmt/tops_connect'
15
- spec.license = 'MIT'
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 = `git ls-files -z`.split("\x0")
18
- .reject { |f| f.match(%r{^spec/}) }
19
- spec.bindir = 'exe'
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.13'
24
- spec.add_development_dependency 'rake', '~> 10'
25
- spec.add_development_dependency 'rspec', '~> 3.5'
26
- spec.add_development_dependency 'webmock', '~> 2.3'
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.13'
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.5.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-02-22 00:00:00.000000000 Z
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.13'
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.13'
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: '10'
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: '10'
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.5'
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.5'
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: '2.3'
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: '2.3'
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.13'
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.13'
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.3
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