asana 2.0.1 → 2.0.2
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 +4 -4
- data/.rubocop.yml +38 -3
- data/Appraisals +7 -6
- data/Gemfile +5 -3
- data/Gemfile.lock +22 -12
- data/Guardfile +12 -10
- data/README.md +3 -1
- data/Rakefile +14 -17
- data/VERSION +1 -1
- data/asana.gemspec +19 -17
- data/lib/asana/authentication/oauth2/access_token_authentication.rb +2 -0
- data/lib/asana/authentication/oauth2/bearer_token_authentication.rb +2 -0
- data/lib/asana/authentication/oauth2/client.rb +2 -0
- data/lib/asana/authentication/oauth2.rb +6 -4
- data/lib/asana/authentication/token_authentication.rb +2 -0
- data/lib/asana/authentication.rb +2 -0
- data/lib/asana/client/configuration.rb +6 -5
- data/lib/asana/client.rb +13 -11
- data/lib/asana/errors.rb +16 -11
- data/lib/asana/http_client/environment_info.rb +9 -8
- data/lib/asana/http_client/error_handling.rb +24 -23
- data/lib/asana/http_client/response.rb +2 -0
- data/lib/asana/http_client.rb +58 -60
- data/lib/asana/resource_includes/attachment_uploading.rb +2 -4
- data/lib/asana/resource_includes/collection.rb +4 -4
- data/lib/asana/resource_includes/event.rb +2 -0
- data/lib/asana/resource_includes/event_subscription.rb +2 -0
- data/lib/asana/resource_includes/events.rb +4 -1
- data/lib/asana/resource_includes/registry.rb +2 -0
- data/lib/asana/resource_includes/resource.rb +8 -5
- data/lib/asana/resource_includes/response_helper.rb +2 -0
- data/lib/asana/resources/audit_log_api.rb +42 -0
- data/lib/asana/resources/gen/attachments_base.rb +1 -1
- data/lib/asana/resources/gen/audit_log_api_base.rb +1 -1
- data/lib/asana/resources/gen/memberships_base.rb +71 -0
- data/lib/asana/resources/gen/tasks_base.rb +1 -1
- data/lib/asana/resources/goal.rb +54 -0
- data/lib/asana/resources/goal_relationship.rb +32 -0
- data/lib/asana/resources/membership.rb +20 -0
- data/lib/asana/resources/project_brief.rb +30 -0
- data/lib/asana/resources/project_template.rb +36 -0
- data/lib/asana/resources/status_update.rb +54 -0
- data/lib/asana/resources/time_period.rb +30 -0
- data/lib/asana/resources/typeahead.rb +1 -1
- data/lib/asana/resources.rb +4 -4
- data/lib/asana/ruby2_0_0_compatibility.rb +2 -0
- data/lib/asana/version.rb +1 -1
- data/lib/asana.rb +2 -0
- data/samples/memberships_sample.yaml +41 -0
- metadata +49 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17dd95f3708910e6ac5e5fe3c342c26e1c26a93ddc2fe7609b3798fb4650f47d
|
4
|
+
data.tar.gz: 68d454cad1b9f85e93f2ab8ed3f20ddc24f8989fafb12bbe7f19bfc30aefd9c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c04179f61fe4f7520853c24db93ab47db57de5b25a7751c982ced551613badfbd84a5408d7ff82bb6669a3057a417c6680e58a35787ec6f1fbc57f53ca788b7a
|
7
|
+
data.tar.gz: 35d8d1daa0c43915b6959735ca69b65fba2cab1936e44719082e6d52baadeb33e1770b6ba0b38d8e46cfedfd3e86864152a6591fe30f643b8e386217756bc932
|
data/.rubocop.yml
CHANGED
@@ -1,14 +1,49 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
|
3
|
-
|
4
|
+
TargetRubyVersion: 2.7
|
5
|
+
NewCops: enable
|
4
6
|
Exclude:
|
5
7
|
- 'bin/**/*'
|
6
8
|
- 'examples/**/*'
|
7
9
|
- 'lib/asana/resources/*'
|
10
|
+
- 'lib/asana/resources/gen/**/*'
|
8
11
|
- 'spec/templates/unicorn.rb'
|
9
12
|
- 'spec/templates/world.rb'
|
10
13
|
- 'test.rb'
|
11
14
|
|
12
15
|
LineLength:
|
13
16
|
Max: 120
|
14
|
-
|
17
|
+
|
18
|
+
Metrics/ParameterLists:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 20
|
26
|
+
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Max: 20
|
29
|
+
|
30
|
+
Metrics/PerceivedComplexity:
|
31
|
+
Max: 20
|
32
|
+
|
33
|
+
RSpec/ContextWording:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
RSpec/ExampleLength:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
RSpec/MultipleExpectations:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
RSpec/NestedGroups:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
RSpec/FilePath:
|
46
|
+
CustomTransform: {'OAuth2': 'oauth2'}
|
47
|
+
|
48
|
+
RSpec/MultipleMemoizedHelpers:
|
49
|
+
Enabled: false
|
data/Appraisals
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
|
3
|
-
|
4
|
-
|
3
|
+
appraise 'faraday-2.7.0' do
|
4
|
+
gem 'faraday', '2.7.0'
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
appraise 'faraday-2.6.0' do
|
8
|
+
gem 'faraday', '2.6.0'
|
9
|
+
end
|
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in asana.gemspec
|
@@ -9,8 +11,8 @@ group :tools do
|
|
9
11
|
# routinely adds new checks which can cause our build to "break" even when no
|
10
12
|
# changes have been made. In this situation it's better to intentionally
|
11
13
|
# upgrade Rubocop and fix issues at that time.
|
12
|
-
gem 'rubocop', '~>
|
13
|
-
gem 'rubocop-rspec', '~>
|
14
|
+
gem 'rubocop', '~> 1.47.0'
|
15
|
+
gem 'rubocop-rspec', '~> 2.18.1'
|
14
16
|
|
15
17
|
gem 'oauth2', '~> 2.0.3'
|
16
18
|
|
@@ -26,5 +28,5 @@ group :tools do
|
|
26
28
|
|
27
29
|
gem 'simplecov', require: false
|
28
30
|
|
29
|
-
gem
|
31
|
+
gem 'rack-protection', '1.5.5'
|
30
32
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
asana (2.0.
|
4
|
+
asana (2.0.2)
|
5
5
|
faraday (~> 2.0)
|
6
6
|
faraday-follow_redirects
|
7
7
|
faraday-multipart
|
@@ -50,6 +50,7 @@ GEM
|
|
50
50
|
guard (>= 1.1.0)
|
51
51
|
yard (>= 0.7.0)
|
52
52
|
hashie (5.0.0)
|
53
|
+
json (2.6.3)
|
53
54
|
jwt (2.7.0)
|
54
55
|
listen (3.8.0)
|
55
56
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
@@ -70,9 +71,8 @@ GEM
|
|
70
71
|
snaky_hash (~> 2.0)
|
71
72
|
version_gem (~> 1.1)
|
72
73
|
parallel (1.22.1)
|
73
|
-
parser (2.
|
74
|
+
parser (3.2.1.0)
|
74
75
|
ast (~> 2.4.1)
|
75
|
-
powerpack (0.1.3)
|
76
76
|
pry (0.14.2)
|
77
77
|
coderay (~> 1.1)
|
78
78
|
method_source (~> 1.0)
|
@@ -84,6 +84,8 @@ GEM
|
|
84
84
|
rb-fsevent (0.11.2)
|
85
85
|
rb-inotify (0.10.1)
|
86
86
|
ffi (~> 1.0)
|
87
|
+
regexp_parser (2.7.0)
|
88
|
+
rexml (3.2.5)
|
87
89
|
rspec (3.12.0)
|
88
90
|
rspec-core (~> 3.12.0)
|
89
91
|
rspec-expectations (~> 3.12.0)
|
@@ -97,15 +99,23 @@ GEM
|
|
97
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
98
100
|
rspec-support (~> 3.12.0)
|
99
101
|
rspec-support (3.12.0)
|
100
|
-
rubocop (
|
102
|
+
rubocop (1.47.0)
|
103
|
+
json (~> 2.3)
|
101
104
|
parallel (~> 1.10)
|
102
|
-
parser (>= 2.
|
103
|
-
powerpack (~> 0.1)
|
105
|
+
parser (>= 3.2.0.0)
|
104
106
|
rainbow (>= 2.2.2, < 4.0)
|
107
|
+
regexp_parser (>= 1.8, < 3.0)
|
108
|
+
rexml (>= 3.2.5, < 4.0)
|
109
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
105
110
|
ruby-progressbar (~> 1.7)
|
106
|
-
unicode-display_width (
|
107
|
-
rubocop-
|
108
|
-
|
111
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
112
|
+
rubocop-ast (1.27.0)
|
113
|
+
parser (>= 3.2.1.0)
|
114
|
+
rubocop-capybara (2.17.1)
|
115
|
+
rubocop (~> 1.41)
|
116
|
+
rubocop-rspec (2.18.1)
|
117
|
+
rubocop (~> 1.33)
|
118
|
+
rubocop-capybara (~> 2.17)
|
109
119
|
ruby-progressbar (1.13.0)
|
110
120
|
ruby2_keywords (0.0.5)
|
111
121
|
shellany (0.0.1)
|
@@ -120,7 +130,7 @@ GEM
|
|
120
130
|
version_gem (~> 1.1, >= 1.1.1)
|
121
131
|
thor (1.2.1)
|
122
132
|
tomparse (0.4.2)
|
123
|
-
unicode-display_width (
|
133
|
+
unicode-display_width (2.4.2)
|
124
134
|
version_gem (1.1.1)
|
125
135
|
webrick (1.7.0)
|
126
136
|
yard (0.9.28)
|
@@ -146,8 +156,8 @@ DEPENDENCIES
|
|
146
156
|
rack-protection (= 1.5.5)
|
147
157
|
rake (~> 13.0)
|
148
158
|
rspec (~> 3.2)
|
149
|
-
rubocop (~>
|
150
|
-
rubocop-rspec (~>
|
159
|
+
rubocop (~> 1.47.0)
|
160
|
+
rubocop-rspec (~> 2.18.1)
|
151
161
|
simplecov
|
152
162
|
yard
|
153
163
|
yard-tomdoc
|
data/Guardfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# A sample Guardfile
|
2
4
|
# More info at https://github.com/guard/guard#readme
|
3
5
|
|
@@ -23,7 +25,7 @@
|
|
23
25
|
#
|
24
26
|
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
27
|
|
26
|
-
#
|
28
|
+
# NOTE: The cmd option is now required due to the increasing number of ways
|
27
29
|
# rspec may be run, below are examples of the most common uses.
|
28
30
|
# * bundler: 'bundle exec rspec'
|
29
31
|
# * bundler binstubs: 'bin/rspec'
|
@@ -32,8 +34,8 @@
|
|
32
34
|
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
35
|
# * 'just' rspec: 'rspec'
|
34
36
|
|
35
|
-
guard :rspec, cmd:
|
36
|
-
require
|
37
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
38
|
+
require 'guard/rspec/dsl'
|
37
39
|
dsl = Guard::RSpec::Dsl.new(self)
|
38
40
|
|
39
41
|
# Feel free to open issues for suggestions and improvements
|
@@ -47,15 +49,15 @@ guard :rspec, cmd: "bundle exec rspec" do
|
|
47
49
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
48
50
|
|
49
51
|
# Rails files
|
50
|
-
rails = dsl.rails(view_extensions: %w
|
52
|
+
rails = dsl.rails(view_extensions: %w[erb haml slim])
|
51
53
|
dsl.watch_spec_files_for(rails.app_files)
|
52
54
|
dsl.watch_spec_files_for(rails.views)
|
53
55
|
|
54
56
|
watch(rails.controllers) do |m|
|
55
57
|
[
|
56
|
-
rspec.spec.("routing/#{m[1]}_routing"),
|
57
|
-
rspec.spec.("controllers/#{m[1]}_controller"),
|
58
|
-
rspec.spec.("acceptance/#{m[1]}")
|
58
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
59
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
60
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
59
61
|
]
|
60
62
|
end
|
61
63
|
|
@@ -65,17 +67,17 @@ guard :rspec, cmd: "bundle exec rspec" do
|
|
65
67
|
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
66
68
|
|
67
69
|
# Capybara features specs
|
68
|
-
watch(rails.view_dirs)
|
70
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
69
71
|
|
70
72
|
# Turnip features and steps
|
71
73
|
watch(%r{^spec/acceptance/(.+)\.feature$})
|
72
74
|
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
73
|
-
Dir[File.join("**/#{m[1]}.feature")][0] ||
|
75
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
79
|
guard :rubocop do
|
78
|
-
watch(
|
80
|
+
watch(/.+\.rb$/)
|
79
81
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
80
82
|
end
|
81
83
|
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/setup'
|
2
4
|
require 'bundler/gem_tasks'
|
3
5
|
require 'appraisal'
|
@@ -19,6 +21,7 @@ task :codegen do
|
|
19
21
|
`node spec/support/codegen.js`
|
20
22
|
end
|
21
23
|
|
24
|
+
# rubocop:disable Metrics/BlockLength
|
22
25
|
namespace :bump do
|
23
26
|
def read_version
|
24
27
|
File.readlines('./lib/asana/version.rb')
|
@@ -27,23 +30,17 @@ namespace :bump do
|
|
27
30
|
.map { |n| Integer(n) }
|
28
31
|
end
|
29
32
|
|
30
|
-
# rubocop:disable Metrics/MethodLength
|
31
33
|
def write_version(major, minor, patch)
|
34
|
+
File.write('VERSION', "#{major}.#{minor}.#{patch}")
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
VERSION = '#{major}.#{minor}.#{patch}'
|
42
|
-
end
|
43
|
-
EOS
|
44
|
-
File.open('./lib/asana/version.rb', 'w') do |f|
|
45
|
-
f.write str
|
46
|
-
end
|
36
|
+
str = <<~RUBY
|
37
|
+
#:nodoc:
|
38
|
+
module Asana
|
39
|
+
# Public: Version of the gem.
|
40
|
+
VERSION = '#{major}.#{minor}.#{patch}'
|
41
|
+
end
|
42
|
+
RUBY
|
43
|
+
File.write('./lib/asana/version.rb', str)
|
47
44
|
|
48
45
|
new_version = "#{major}.#{minor}.#{patch}"
|
49
46
|
system('bundle lock --update')
|
@@ -73,10 +70,10 @@ EOS
|
|
73
70
|
write_version major + 1, 0, 0
|
74
71
|
end
|
75
72
|
end
|
73
|
+
# rubocop:enable Metrics/BlockLength
|
76
74
|
|
77
75
|
desc 'Default: run the unit tests.'
|
78
|
-
task default: [
|
79
|
-
|
76
|
+
task default: %i[all rubocop yard]
|
80
77
|
|
81
78
|
desc 'Test the plugin under all supported Rails versions.'
|
82
79
|
task :all do |_t|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.2
|
data/asana.gemspec
CHANGED
@@ -1,32 +1,34 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'asana/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'asana'
|
8
9
|
spec.version = Asana::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Txus']
|
11
|
+
spec.email = ['me@txus.io']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
13
|
+
spec.summary = 'Official Ruby client for the Asana API'
|
14
|
+
spec.description = 'Official Ruby client for the Asana API'
|
15
|
+
spec.homepage = 'https://github.com/asana/ruby-asana'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
21
22
|
|
22
23
|
spec.required_ruby_version = '>= 2.7'
|
23
24
|
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
25
|
+
spec.add_dependency 'faraday', '~> 2.0'
|
26
|
+
spec.add_dependency 'faraday-follow_redirects'
|
27
|
+
spec.add_dependency 'faraday-multipart'
|
28
|
+
spec.add_dependency 'oauth2', '>= 1.4', '< 3'
|
28
29
|
|
29
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
-
spec.add_development_dependency "rspec", "~> 3.2"
|
31
30
|
spec.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1'
|
31
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
33
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
32
34
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'oauth2/bearer_token_authentication'
|
2
4
|
require_relative 'oauth2/access_token_authentication'
|
3
5
|
require_relative 'oauth2/client'
|
@@ -31,10 +33,10 @@ module Asana
|
|
31
33
|
client = Client.new(client_id: client_id,
|
32
34
|
client_secret: client_secret,
|
33
35
|
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
auth_code =
|
36
|
+
$stdout.puts '1. Go to the following URL to authorize the ' \
|
37
|
+
"application: #{client.authorize_url}"
|
38
|
+
$stdout.puts '2. Paste the authorization code here: '
|
39
|
+
auth_code = $stdin.gets.chomp
|
38
40
|
client.token_from_auth_code(auth_code)
|
39
41
|
end
|
40
42
|
end
|
data/lib/asana/authentication.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Asana
|
2
4
|
class Client
|
3
5
|
# Internal: Represents a configuration DSL for an Asana::Client.
|
@@ -17,7 +19,7 @@ module Asana
|
|
17
19
|
# Public: Initializes an empty configuration object.
|
18
20
|
def initialize
|
19
21
|
@configuration = {
|
20
|
-
|
22
|
+
log_asana_change_warnings: true
|
21
23
|
}
|
22
24
|
end
|
23
25
|
|
@@ -100,7 +102,6 @@ module Asana
|
|
100
102
|
#
|
101
103
|
# Raises ArgumentError if the OAuth2 configuration arguments are invalid.
|
102
104
|
#
|
103
|
-
# rubocop:disable Metrics/MethodLength
|
104
105
|
def oauth2(value)
|
105
106
|
case value
|
106
107
|
when ::OAuth2::AccessToken
|
@@ -111,8 +112,8 @@ module Asana
|
|
111
112
|
from_bearer_token(value[:bearer_token])
|
112
113
|
else
|
113
114
|
error 'Invalid OAuth2 configuration: pass in either an ' \
|
114
|
-
|
115
|
-
|
115
|
+
'::OAuth2::AccessToken object of your own or a hash ' \
|
116
|
+
'containing :refresh_token or :bearer_token.'
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
@@ -158,7 +159,7 @@ module Asana
|
|
158
159
|
end
|
159
160
|
|
160
161
|
def requiring(hash, *keys)
|
161
|
-
missing_keys = keys.
|
162
|
+
missing_keys = keys.reject { |k| hash.key?(k) }
|
162
163
|
missing_keys.any? && error("Missing keys: #{missing_keys.join(', ')}")
|
163
164
|
keys.map { |k| hash[k] }
|
164
165
|
end
|
data/lib/asana/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'authentication'
|
2
4
|
require_relative 'client/configuration'
|
3
5
|
require_relative 'resources'
|
@@ -59,12 +61,12 @@ module Asana
|
|
59
61
|
@resource = resource
|
60
62
|
end
|
61
63
|
|
62
|
-
def method_missing(
|
63
|
-
@resource.public_send(
|
64
|
+
def method_missing(method_name, *args, **kwargs, &block)
|
65
|
+
@resource.public_send(method_name, *([@client] + args), **kwargs, &block)
|
64
66
|
end
|
65
67
|
|
66
|
-
def respond_to_missing?(
|
67
|
-
@resource.respond_to?(
|
68
|
+
def respond_to_missing?(method_name, *)
|
69
|
+
@resource.respond_to?(method_name)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
@@ -72,15 +74,15 @@ module Asana
|
|
72
74
|
#
|
73
75
|
# Yields a {Asana::Client::Configuration} object as a configuration
|
74
76
|
# DSL. See {Asana::Client} for usage examples.
|
75
|
-
def initialize
|
76
|
-
config = Configuration.new.tap
|
77
|
+
def initialize(&block)
|
78
|
+
config = Configuration.new.tap(&block).to_h
|
77
79
|
@http_client =
|
78
|
-
HttpClient.new(authentication:
|
79
|
-
adapter:
|
80
|
-
user_agent:
|
81
|
-
debug_mode:
|
80
|
+
HttpClient.new(authentication: config.fetch(:authentication),
|
81
|
+
adapter: config[:faraday_adapter],
|
82
|
+
user_agent: config[:user_agent],
|
83
|
+
debug_mode: config[:debug_mode],
|
82
84
|
log_asana_change_warnings: config[:log_asana_change_warnings],
|
83
|
-
default_headers:
|
85
|
+
default_headers: config[:default_headers],
|
84
86
|
&config[:faraday_configuration])
|
85
87
|
end
|
86
88
|
|
data/lib/asana/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Asana
|
2
4
|
# Public: Defines the different errors that the Asana API may throw, which the
|
3
5
|
# client code may want to catch.
|
@@ -19,8 +21,8 @@ module Asana
|
|
19
21
|
# user could not be authenticated.
|
20
22
|
NotAuthorized = Class.new(APIError) do
|
21
23
|
def to_s
|
22
|
-
'Valid credentials were not provided with the request, so the API could '\
|
23
|
-
|
24
|
+
'Valid credentials were not provided with the request, so the API could ' \
|
25
|
+
'not associate a user with the request.'
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -28,8 +30,8 @@ module Asana
|
|
28
30
|
# that requires a premium account (Payment Required).
|
29
31
|
PremiumOnly = Class.new(APIError) do
|
30
32
|
def to_s
|
31
|
-
'The endpoint that is being requested is only available to premium '\
|
32
|
-
|
33
|
+
'The endpoint that is being requested is only available to premium ' \
|
34
|
+
'users.'
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -37,18 +39,18 @@ module Asana
|
|
37
39
|
# access the requested resource or to perform the requested action on it.
|
38
40
|
Forbidden = Class.new(APIError) do
|
39
41
|
def to_s
|
40
|
-
'The authorization and request syntax was valid but the server is refusing '\
|
41
|
-
|
42
|
-
|
42
|
+
'The authorization and request syntax was valid but the server is refusing ' \
|
43
|
+
'to complete the request. This can happen if you try to read or write ' \
|
44
|
+
'to objects or properties that the user does not have access to.'
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
48
|
# Public: A 404 error. Raised when the requested resource doesn't exist.
|
47
49
|
NotFound = Class.new(APIError) do
|
48
50
|
def to_s
|
49
|
-
'Either the request method and path supplied do not specify a known '\
|
50
|
-
|
51
|
-
|
51
|
+
'Either the request method and path supplied do not specify a known ' \
|
52
|
+
'action in the API, or the object specified by the request does not ' \
|
53
|
+
'exist.'
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -59,11 +61,12 @@ module Asana
|
|
59
61
|
attr_accessor :phrase
|
60
62
|
|
61
63
|
def initialize(phrase)
|
64
|
+
super()
|
62
65
|
@phrase = phrase
|
63
66
|
end
|
64
67
|
|
65
68
|
def to_s
|
66
|
-
"There has been an error on Asana's end. Use this unique phrase to "\
|
69
|
+
"There has been an error on Asana's end. Use this unique phrase to " \
|
67
70
|
'identify the problem when contacting support: ' + %("#{@phrase}")
|
68
71
|
end
|
69
72
|
end
|
@@ -74,6 +77,7 @@ module Asana
|
|
74
77
|
attr_accessor :errors
|
75
78
|
|
76
79
|
def initialize(errors)
|
80
|
+
super()
|
77
81
|
@errors = errors
|
78
82
|
end
|
79
83
|
|
@@ -89,6 +93,7 @@ module Asana
|
|
89
93
|
attr_accessor :retry_after_seconds
|
90
94
|
|
91
95
|
def initialize(retry_after_seconds)
|
96
|
+
super()
|
92
97
|
@retry_after_seconds = retry_after_seconds
|
93
98
|
end
|
94
99
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../version'
|
2
4
|
require 'openssl'
|
3
5
|
|
@@ -6,7 +8,7 @@ module Asana
|
|
6
8
|
# Internal: Adds environment information to a Faraday request.
|
7
9
|
class EnvironmentInfo
|
8
10
|
# Internal: The default user agent to use in all requests to the API.
|
9
|
-
USER_AGENT = "ruby-asana v#{Asana::VERSION}"
|
11
|
+
USER_AGENT = "ruby-asana v#{Asana::VERSION}"
|
10
12
|
|
11
13
|
def initialize(user_agent = nil)
|
12
14
|
@user_agent = user_agent || USER_AGENT
|
@@ -19,7 +21,7 @@ module Asana
|
|
19
21
|
# environment.
|
20
22
|
def configure(builder)
|
21
23
|
builder.headers[:user_agent] = @user_agent
|
22
|
-
builder.headers[:
|
24
|
+
builder.headers[:'X-Asana-Client-Lib'] = header
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
@@ -33,21 +35,20 @@ module Asana
|
|
33
35
|
.map { |k, v| "#{k}=#{v}" }.join('&')
|
34
36
|
end
|
35
37
|
|
36
|
-
# rubocop:disable Metrics/MethodLength
|
37
38
|
def os
|
38
|
-
|
39
|
+
case RUBY_PLATFORM
|
40
|
+
when /win32/, /mingw/
|
39
41
|
'windows'
|
40
|
-
|
42
|
+
when /linux/
|
41
43
|
'linux'
|
42
|
-
|
44
|
+
when /darwin/
|
43
45
|
'darwin'
|
44
|
-
|
46
|
+
when /freebsd/
|
45
47
|
'freebsd'
|
46
48
|
else
|
47
49
|
'unknown'
|
48
50
|
end
|
49
51
|
end
|
50
|
-
# rubocop:enable Metrics/MethodLength
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|