connect_wise_rest 0.4.1 → 0.5.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
- SHA1:
3
- metadata.gz: decfe27e68af0ed76de1037fdffd51009a2ecc6d
4
- data.tar.gz: 87071170b2581bbd0d50b7497770c2c16b0d525a
2
+ SHA256:
3
+ metadata.gz: 2f0f3fdbdbb40bd8b9f825cb46e4f85d10f5b9270868ff6018b7dd67b858c069
4
+ data.tar.gz: 805b98ddfdd17433f63442695149c6469d2d60070e59eba04c0a1e3242057d65
5
5
  SHA512:
6
- metadata.gz: 84626b8af66c1afa99f665b49721bc74dc2b5be5a9f9c7c213e5e65c5f7ed31b5abae9cc3f22a6f8d528b1faf95f8bc26e11c78104a569652d7d7369b179dd88
7
- data.tar.gz: 6e792cfcfb2bf8cc9853f4c8e71fe7419ba469e79e1d3563f3d247061268c9c017e28873efccfd1ef63b70f5407bdf8cb495e0f5f75c30a260ae2c3dcfc92b9d
6
+ metadata.gz: d85b164ff6e0910205f1118784efb2bf8773ac2c4425e8422e6c6be84dc4760a9a3116173cb8dcedbc6885f17c42b31899d779b3ac2c1318cfd5258c1f157046
7
+ data.tar.gz: f128174486933efba430c623e52d2d7967073118dc2ff34bdaf813501561b9032fb8a031c7e0f819a8bccc20ff75de74753db0ae4fa25740342dda83c1a262d2
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'connect_wise_rest'
8
8
  spec.version = ConnectWiseRest::VERSION
9
9
  spec.authors = ['Kevin Pheasey']
10
- spec.email = ['kevin@kpheasey.com']
10
+ spec.email = ['kevin@kpsoftware.io']
11
11
 
12
12
  spec.summary = %q{REST client wrapper for Connect Wise.}
13
13
  spec.description = %q{A dead simple REST client wrapper for Connect Wise.}
@@ -4,6 +4,7 @@ require 'httparty'
4
4
  require 'connect_wise_rest/version'
5
5
  require 'connect_wise_rest/configuration'
6
6
  require 'connect_wise_rest/client'
7
+ require 'connect_wise_rest/error'
7
8
  require 'connect_wise_rest/report'
8
9
 
9
10
  module ConnectWiseRest
@@ -5,10 +5,10 @@ module ConnectWiseRest
5
5
  attr_reader :resource
6
6
 
7
7
  DEFAULT_OPTIONS = ConnectWiseRest.configuration.to_hash.merge(
8
- {
9
- timeout: 300,
10
- query: { 'page' => 1, 'pageSize' => 75 }
11
- }
8
+ {
9
+ timeout: 300,
10
+ query: { 'page' => 1, 'pageSize' => 75 }
11
+ }
12
12
  )
13
13
 
14
14
  def initialize(resource, options = {})
@@ -31,17 +31,19 @@ module ConnectWiseRest
31
31
 
32
32
  def response
33
33
  @response ||= HTTParty.get(url, request_options)
34
+ rescue StandardError => e
35
+ raise ConnectionError.new(e.message)
34
36
  end
35
37
 
36
38
  def request_options
37
39
  request_options = {
38
- headers: { 'Accept' => 'application/json' },
39
- query: self.options[:query],
40
- timeout: options[:timeout],
41
- basic_auth: {
42
- username: "#{options[:company_id]}+#{options[:public_key]}",
43
- password: options[:private_key]
44
- }
40
+ headers: { 'Accept' => 'application/json' },
41
+ query: self.options[:query],
42
+ timeout: options[:timeout],
43
+ basic_auth: {
44
+ username: "#{options[:company_id]}+#{options[:public_key]}",
45
+ password: options[:private_key]
46
+ }
45
47
  }
46
48
 
47
49
  request_options[:debug_output] = options[:logger] if options[:debug] && options[:logger]
@@ -76,11 +78,13 @@ module ConnectWiseRest
76
78
  private
77
79
 
78
80
  def raise_error(response)
79
- if response.parsed_response
80
- raise "#{response.parsed_response['code']}: #{response.parsed_response['message']}"
81
- else
82
- raise response.body
83
- end
81
+ msg = if response.parsed_response
82
+ "#{response.parsed_response['code']}: #{response.parsed_response['message']}"
83
+ else
84
+ response.body
85
+ end
86
+
87
+ raise ConnectionError.new(msg)
84
88
  end
85
89
  end
86
90
  end
@@ -0,0 +1,3 @@
1
+ module ConnectWiseRest
2
+ class ConnectionError < StandardError; end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module ConnectWiseRest
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connect_wise_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Pheasey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0.13'
55
55
  description: A dead simple REST client wrapper for Connect Wise.
56
56
  email:
57
- - kevin@kpheasey.com
57
+ - kevin@kpsoftware.io
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
@@ -71,6 +71,7 @@ files:
71
71
  - lib/connect_wise_rest.rb
72
72
  - lib/connect_wise_rest/client.rb
73
73
  - lib/connect_wise_rest/configuration.rb
74
+ - lib/connect_wise_rest/error.rb
74
75
  - lib/connect_wise_rest/report.rb
75
76
  - lib/connect_wise_rest/version.rb
76
77
  homepage: https://github.com/MSPCFO/connect_wise_rest
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  version: '0'
94
95
  requirements: []
95
96
  rubyforge_project:
96
- rubygems_version: 2.6.14
97
+ rubygems_version: 2.7.8
97
98
  signing_key:
98
99
  specification_version: 4
99
100
  summary: REST client wrapper for Connect Wise.