lenddo 2.0.0 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 603cfccd052d8658a46e83938799ae942fa48980
4
- data.tar.gz: 71c60182b2cc54af3c10583a61dbf9caadad69b0
3
+ metadata.gz: 6aa3fed76f4f20198170dca13691b8ba450f2855
4
+ data.tar.gz: 763602a7c3599d9cfc693a95488c3cbecfda1904
5
5
  SHA512:
6
- metadata.gz: 8dc3ba9ee5422458f5beb11f76c87f77779015433d3611c43d5a9933991d87f59a0606347f00acf01b6cefd19e71504f5c9d342a128e9f6271b401b2477501d5
7
- data.tar.gz: 1a696ba8287a6a8e8c1f54aa9faa26a8c07c2431f6ea94c7be324a6075294254d1d44ee8a586d4c4a83fcbc4cb0dca1e0ed62895525e25be9aac97a510ae043d
6
+ metadata.gz: 4b64d8df5540f921156bdfa875020dba304b35627a335ab80122452ca085401fb37f1033c3a871e447c6a46aff774b36fe24c87b2fb1fd28abf4ff13e3bc414e
7
+ data.tar.gz: 13a5d2cc4c962120537814487387dd5de514092bd7ba0aee843385fb59d9ec1f8cdd3a39a1658e27df8e8919710824d26f2c30f3d6d8ca95e3f0749e0bebcd4d
@@ -2,6 +2,7 @@ require 'base64'
2
2
  require 'curb'
3
3
  require 'json'
4
4
  require 'openssl'
5
+ require 'lenddo/errors/exceptions'
5
6
 
6
7
  module Lenddo
7
8
  module Authentication
@@ -18,16 +19,26 @@ module Lenddo
18
19
  end
19
20
 
20
21
  uri = URI.parse(host + path)
21
- Curl.send(method.to_s, uri.to_s, params) do |http|
22
- headers = sign(method.upcase, path, body)
23
- headers.each do |key, value|
24
- http.headers[key] = value.chomp
25
- end
22
+ begin
23
+ response = Curl.send(method.to_s, uri.to_s, params) do |http|
24
+ headers = sign(method.upcase, path, body)
25
+ headers.each do |key, value|
26
+ http.headers[key] = value.chomp
27
+ end
26
28
 
27
- http.use_ssl = 3
28
- http.ssl_verify_host = OpenSSL::SSL::VERIFY_PEER
29
- http.cacert = File.absolute_path("./cacert.pem") if RbConfig::CONFIG['host_os'] == 'mingw32'
29
+ http.use_ssl = 3
30
+ http.ssl_verify_host = OpenSSL::SSL::VERIFY_PEER
31
+ http.cacert = File.absolute_path("./cacert.pem") if RbConfig::CONFIG['host_os'] == 'mingw32'
32
+ end
33
+ rescue Curl::Err::TimeoutError => e
34
+ raise Lenddo::Errors::TimeoutException.new(e.message)
35
+ rescue Curl::Err::HostResolutionError => e
36
+ raise Lenddo::Errors::HostResolutionError.new(e.message)
37
+ rescue => e
38
+ raise Lenddo::Errors::UnknownException.new(e.message)
30
39
  end
40
+
41
+ response
31
42
  end
32
43
 
33
44
  private
@@ -53,4 +64,4 @@ module Lenddo
53
64
  OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), key, value)
54
65
  end
55
66
  end
56
- end
67
+ end
@@ -21,4 +21,4 @@ module Lenddo
21
21
  @secret_key
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -2,4 +2,4 @@ module Lenddo
2
2
  module Errors
3
3
  class Configuration < StandardError; end
4
4
  end
5
- end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Lenddo
2
+ module Errors
3
+ class TimeoutException < StandardError; end
4
+ class UnknownException < StandardError; end
5
+ class HostResolutionError < StandardError; end
6
+ class InternalErrorException < StandardError; end
7
+ end
8
+ end
@@ -1,7 +1,16 @@
1
+ require 'lenddo/errors/exceptions'
2
+
1
3
  module Lenddo
2
4
  class Response
3
5
  def initialize(http_response)
4
6
  @http_response = http_response
7
+
8
+ http_code = http_response.response_code
9
+ if http_code == 500
10
+ raise Lenddo::Errors::InternalErrorException
11
+ elsif http_code > 500
12
+ raise Lenddo::Errors::UnknownException.new(http_response.status)
13
+ end
5
14
  end
6
15
 
7
16
  def status
@@ -13,7 +22,11 @@ module Lenddo
13
22
  end
14
23
 
15
24
  def body
16
- JSON.parse(@http_response.body)
25
+ begin
26
+ JSON.parse(@http_response.body)
27
+ rescue => e
28
+ raise Lenddo::Errors::UnknownException.new(e.message)
29
+ end
17
30
  end
18
31
  end
19
- end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Lenddo
2
2
  def self.version
3
- "2.0.0"
3
+ "2.1.0"
4
4
  end
5
- end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lenddo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arjay salvadora
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,6 +102,7 @@ files:
102
102
  - lib/lenddo/authentication.rb
103
103
  - lib/lenddo/configuration.rb
104
104
  - lib/lenddo/errors/configuration.rb
105
+ - lib/lenddo/errors/exceptions.rb
105
106
  - lib/lenddo/network_service/self.rb
106
107
  - lib/lenddo/response.rb
107
108
  - lib/lenddo/score_service/self.rb