asana 0.6.2 → 0.6.3
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 +5 -5
- data/.travis.yml +5 -1
- data/Gemfile +2 -2
- data/examples/Gemfile +1 -1
- data/examples/Gemfile.lock +11 -11
- data/lib/asana/errors.rb +9 -0
- data/lib/asana/http_client/error_handling.rb +28 -8
- data/lib/asana/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a918da44ed24274296db1a40bda628d24e48ca40ea53622ba13f4309784a3b0
|
4
|
+
data.tar.gz: 1c0b2ffaee3b5bc3dc207c60122da6dd97f97009f538163037cf8e135fad29b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d73d39ad30a783c5849a6e7d3bdb4fccf69c27837f8def2cefa3ef93b0e7b14e721eda1b4e05251887b5347837b1de03d084cc45ec3cf17c07323b3071f73017
|
7
|
+
data.tar.gz: 9bbca4c1b400bbac20484c473288aff9d867d76544b6552ee807050ac0ea4ed9f85fb2b2a33397ac848f6d7fbad3c1fd1c637fa748797cff9669aa15fd8877d6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -9,8 +9,8 @@ group :tools do
|
|
9
9
|
# routinely adds new checks which can cause our build to "break" even when no
|
10
10
|
# changes have been made. In this situation it's better to intentionally
|
11
11
|
# upgrade Rubocop and fix issues at that time.
|
12
|
-
gem 'rubocop', '~> 0.
|
13
|
-
gem 'rubocop-rspec', '~> 1.
|
12
|
+
gem 'rubocop', '~> 0.52.1'
|
13
|
+
gem 'rubocop-rspec', '~> 1.22.2'
|
14
14
|
|
15
15
|
gem 'guard'
|
16
16
|
gem 'guard-rspec'
|
data/examples/Gemfile
CHANGED
data/examples/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
|
-
remote:
|
2
|
+
remote: ..
|
3
3
|
specs:
|
4
|
-
asana (0.
|
4
|
+
asana (0.6.3)
|
5
5
|
faraday (~> 0.9)
|
6
6
|
faraday_middleware (~> 0.9)
|
7
7
|
faraday_middleware-multi_json (~> 0.0)
|
@@ -12,12 +12,12 @@ GEM
|
|
12
12
|
specs:
|
13
13
|
faraday (0.9.1)
|
14
14
|
multipart-post (>= 1.2, < 3)
|
15
|
-
faraday_middleware (0.
|
16
|
-
faraday (>= 0.7.4, < 0
|
15
|
+
faraday_middleware (0.12.2)
|
16
|
+
faraday (>= 0.7.4, < 1.0)
|
17
17
|
faraday_middleware-multi_json (0.0.6)
|
18
18
|
faraday_middleware
|
19
19
|
multi_json
|
20
|
-
hashie (3.
|
20
|
+
hashie (3.5.7)
|
21
21
|
jwt (1.5.0)
|
22
22
|
multi_json (1.11.0)
|
23
23
|
multi_xml (0.5.5)
|
@@ -28,16 +28,16 @@ GEM
|
|
28
28
|
multi_json (~> 1.3)
|
29
29
|
multi_xml (~> 0.5)
|
30
30
|
rack (~> 1.2)
|
31
|
-
omniauth (1.
|
32
|
-
hashie (>=
|
33
|
-
rack (
|
31
|
+
omniauth (1.8.1)
|
32
|
+
hashie (>= 3.4.6, < 3.6.0)
|
33
|
+
rack (>= 1.6.2, < 3)
|
34
34
|
omniauth-asana (0.0.1)
|
35
35
|
omniauth (~> 1.0)
|
36
36
|
omniauth-oauth2 (~> 1.1)
|
37
37
|
omniauth-oauth2 (1.3.0)
|
38
38
|
oauth2 (~> 1.0)
|
39
39
|
omniauth (~> 1.2)
|
40
|
-
rack (1.6.
|
40
|
+
rack (1.6.8)
|
41
41
|
rack-protection (1.5.3)
|
42
42
|
rack
|
43
43
|
sinatra (1.4.6)
|
@@ -51,9 +51,9 @@ PLATFORMS
|
|
51
51
|
|
52
52
|
DEPENDENCIES
|
53
53
|
asana!
|
54
|
-
omniauth
|
54
|
+
omniauth (~> 1.3)
|
55
55
|
omniauth-asana
|
56
56
|
sinatra
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
1.
|
59
|
+
1.16.1
|
data/lib/asana/errors.rb
CHANGED
@@ -24,6 +24,15 @@ module Asana
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# Public: A 402 error. Raised when the user is trying to access a feature
|
28
|
+
# that requires a premium account (Payment Required).
|
29
|
+
PremiumOnly = Class.new(APIError) do
|
30
|
+
def to_s
|
31
|
+
'The endpoint that is being requested is only available to premium '\
|
32
|
+
'users.'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
27
36
|
# Public: A 403 error. Raised when the user doesn't have permission to
|
28
37
|
# access the requested resource or to perform the requested action on it.
|
29
38
|
Forbidden = Class.new(APIError) do
|
@@ -11,6 +11,8 @@ module Asana
|
|
11
11
|
|
12
12
|
module_function
|
13
13
|
|
14
|
+
PREMIUM_ONLY_STR = 'not available for free'.freeze
|
15
|
+
|
14
16
|
# Public: Perform a request handling any API errors correspondingly.
|
15
17
|
#
|
16
18
|
# request - [Proc] a block that will execute the request.
|
@@ -31,14 +33,27 @@ module Asana
|
|
31
33
|
rescue Faraday::ClientError => e
|
32
34
|
raise e unless e.response
|
33
35
|
case e.response[:status]
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
when 400 then raise invalid_request(e.response)
|
37
|
+
when 401 then raise not_authorized(e.response)
|
38
|
+
when 402 then raise payment_required(e.response)
|
39
|
+
when 403
|
40
|
+
begin
|
41
|
+
body = body(e.response)
|
42
|
+
errors_str = body['errors'].collect {
|
43
|
+
|err| err['message']
|
44
|
+
}.join('; ')
|
45
|
+
if errors_str.include? PREMIUM_ONLY_STR
|
46
|
+
raise payment_required(e.response)
|
47
|
+
end
|
48
|
+
rescue
|
49
|
+
raise forbidden(e.response)
|
50
|
+
end
|
51
|
+
raise forbidden(e.response)
|
52
|
+
when 404 then raise not_found(e.response)
|
53
|
+
when 412 then recover_response(e.response)
|
54
|
+
when 429 then raise rate_limit_enforced(e.response)
|
55
|
+
when 500 then raise server_error(e.response)
|
56
|
+
else raise api_error(e.response)
|
42
57
|
end
|
43
58
|
end
|
44
59
|
# rubocop:enable all
|
@@ -57,6 +72,11 @@ module Asana
|
|
57
72
|
NotAuthorized.new.tap { |exception| exception.response = response }
|
58
73
|
end
|
59
74
|
|
75
|
+
# Internal: Returns a PremiumOnly exception.
|
76
|
+
def payment_required(response)
|
77
|
+
PremiumOnly.new.tap { |exception| exception.response = response }
|
78
|
+
end
|
79
|
+
|
60
80
|
# Internal: Returns a Forbidden exception.
|
61
81
|
def forbidden(response)
|
62
82
|
Forbidden.new.tap { |exception| exception.response = response }
|
data/lib/asana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Txus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
218
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
219
|
+
rubygems_version: 2.7.5
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
222
|
summary: Official Ruby client for the Asana API
|