asana 0.6.2 → 0.6.3

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: 145003ef16856b51b561cd5235c2f91295a57dc9
4
- data.tar.gz: 10ebb67b4d0be9a80a94f46ba7fbdb073a6888bf
2
+ SHA256:
3
+ metadata.gz: 3a918da44ed24274296db1a40bda628d24e48ca40ea53622ba13f4309784a3b0
4
+ data.tar.gz: 1c0b2ffaee3b5bc3dc207c60122da6dd97f97009f538163037cf8e135fad29b8
5
5
  SHA512:
6
- metadata.gz: 698b02ebc64a3b44db3dcb448973c97bf1798d2edae1e8e12b5500c8214056a91c0617f1059194e0ad375101ca124fcf888b1b6f9a66272359e255873d7ca6eb
7
- data.tar.gz: bd4ed6bdb09e50085d12481ae0430154b07289cbcc923f3deba6d0c0f69d9601d5322e91a2cd9576b4494907266184211337ead0545c7678c6a9331ba162d704
6
+ metadata.gz: d73d39ad30a783c5849a6e7d3bdb4fccf69c27837f8def2cefa3ef93b0e7b14e721eda1b4e05251887b5347837b1de03d084cc45ec3cf17c07323b3071f73017
7
+ data.tar.gz: 9bbca4c1b400bbac20484c473288aff9d867d76544b6552ee807050ac0ea4ed9f85fb2b2a33397ac848f6d7fbad3c1fd1c637fa748797cff9669aa15fd8877d6
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.5
3
+ - 2.2.9
4
+ - 2.3.6
5
+ - 2.4.3
6
+ - 2.5.0
4
7
  deploy:
5
8
  provider: rubygems
6
9
  api_key:
@@ -9,3 +12,4 @@ deploy:
9
12
  on:
10
13
  tags: true
11
14
  repo: Asana/ruby-asana
15
+ ruby: '2.5.0'
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.37.2'
13
- gem 'rubocop-rspec', '~> 1.4.0'
12
+ gem 'rubocop', '~> 0.52.1'
13
+ gem 'rubocop-rspec', '~> 1.22.2'
14
14
 
15
15
  gem 'guard'
16
16
  gem 'guard-rspec'
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'omniauth'
3
+ gem 'omniauth', '~> 1.3'
4
4
  gem 'omniauth-asana'
5
5
  gem 'sinatra'
6
6
  gem 'asana', path: '../'
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- asana (0.1.1)
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.9.1)
16
- faraday (>= 0.7.4, < 0.10)
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.4.1)
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.2.2)
32
- hashie (>= 1.2, < 4)
33
- rack (~> 1.0)
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.1)
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.10.3
59
+ 1.16.1
@@ -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
- when 400 then raise invalid_request(e.response)
35
- when 401 then raise not_authorized(e.response)
36
- when 403 then raise forbidden(e.response)
37
- when 404 then raise not_found(e.response)
38
- when 412 then recover_response(e.response)
39
- when 429 then raise rate_limit_enforced(e.response)
40
- when 500 then raise server_error(e.response)
41
- else raise api_error(e.response)
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 }
@@ -1,5 +1,5 @@
1
1
  #:nodoc:
2
2
  module Asana
3
3
  # Public: Version of the gem.
4
- VERSION = '0.6.2'.freeze
4
+ VERSION = '0.6.3'.freeze
5
5
  end
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.2
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: 2017-09-27 00:00:00.000000000 Z
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.6.13
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