closeio 2.4.14 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/closeio/client.rb +8 -5
- data/lib/closeio/error.rb +25 -0
- data/lib/closeio/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d38f5c1d4dae42fe9127f9aba765f4a627e2ece
|
4
|
+
data.tar.gz: 3753475417144d5da196868b5bf79b04fcf6927d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2f110db0912312701a22dc8d8e41c1fe2769254f697fa910fc043fd1a70876f33a642d5daf756203950c645e98607b996c52afd32998f824f78db0ff366aa04
|
7
|
+
data.tar.gz: 1cc336990cb42688b4cdef3278136b2111107da7748b2bc0769a483490edb63ae1b2eb6f676a20e25772e973e6e78078b91c3e132c11fde49479359f13dac56d
|
data/CHANGELOG.md
CHANGED
data/lib/closeio/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'faraday_middleware'
|
3
|
+
require_relative "error"
|
3
4
|
|
4
5
|
Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
|
5
6
|
|
@@ -21,12 +22,13 @@ module Closeio
|
|
21
22
|
include Closeio::Client::Task
|
22
23
|
include Closeio::Client::User
|
23
24
|
|
24
|
-
attr_reader :api_key, :logger, :ca_file
|
25
|
+
attr_reader :api_key, :logger, :ca_file, :errors
|
25
26
|
|
26
|
-
def initialize(api_key, logger = true, ca_file = nil)
|
27
|
-
@api_key
|
28
|
-
@logger
|
29
|
-
@ca_file
|
27
|
+
def initialize(api_key, logger = true, ca_file = nil, errors = false)
|
28
|
+
@api_key = api_key
|
29
|
+
@logger = logger
|
30
|
+
@ca_file = ca_file
|
31
|
+
@errors = errors
|
30
32
|
end
|
31
33
|
|
32
34
|
def get(path, options={})
|
@@ -83,6 +85,7 @@ module Closeio
|
|
83
85
|
conn.response :logger if logger
|
84
86
|
conn.use FaradayMiddleware::Mashify
|
85
87
|
conn.response :json
|
88
|
+
conn.use FaradayMiddleware::CloseioErrorHandler if errors
|
86
89
|
conn.adapter Faraday.default_adapter
|
87
90
|
end
|
88
91
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Closeio
|
2
|
+
class Error < StandardError; end
|
3
|
+
class NotAuthorized < Error; end
|
4
|
+
class NotFound < Error; end
|
5
|
+
class GatewayTimeout < Error; end
|
6
|
+
end
|
7
|
+
|
8
|
+
require "faraday"
|
9
|
+
module FaradayMiddleware
|
10
|
+
class CloseioErrorHandler < Faraday::Response::Middleware
|
11
|
+
ERROR_STATUSES = 400..600
|
12
|
+
def on_complete(env)
|
13
|
+
case env[:status]
|
14
|
+
when 401
|
15
|
+
raise Closeio::NotAuthorized, env.body
|
16
|
+
when 404
|
17
|
+
raise Closeio::NotFound, env.body
|
18
|
+
when 504
|
19
|
+
raise Closeio::GatewayTimeout, env.body
|
20
|
+
when ERROR_STATUSES
|
21
|
+
raise Closeio::Error, "#{env.status}: #{env.body}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/closeio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closeio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Brooks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- closeio.gemspec
|
155
155
|
- lib/closeio.rb
|
156
156
|
- lib/closeio/client.rb
|
157
|
+
- lib/closeio/error.rb
|
157
158
|
- lib/closeio/resources/activity.rb
|
158
159
|
- lib/closeio/resources/bulk_action.rb
|
159
160
|
- lib/closeio/resources/contact.rb
|