asana 0.1.2 → 0.2.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2VlNTc3NDk5ZjRlMjQ2YzM0ZjdkMDExNDEwNGY3OWE4YmQwOGQ4ZA==
4
+ YjFiZWU3OWJjZTYxOGRkNjY1YWQ5YWQzMWYxODhjMGMyODIwNDliYg==
5
5
  data.tar.gz: !binary |-
6
- NmJjOGJiOTE1N2IzNTlhOGNlMGVkMmU4NDkyMzdmOTgxYzI4NTc3Zg==
6
+ ZmVjOWMwNTdlMzdjNGVkNmJiZDNjZjc2OTVhZDY3YWFjMjBlYTllNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2RhYzc1MWEwZWJlN2QwZTM1ZWI3MWI3NmMxMjI2YmFkZGEzMTRiMGMwZDI1
10
- NWEwZDBjM2RiODE5ZTZlZTkzZDBhNzkzMDg1NzAwYzZkNzE3YzlmMDA2NTUz
11
- YjE3YmY4ODU3YThhNDhjZThmODA4N2ZkZDNlZDFmOWJiNGIxMGU=
9
+ NTFjZTA5MWI3MDI2YjA4Zjc0YjcxODA1ZTUwZjU4M2QzMzVhZGRmNDI2Nzlh
10
+ YmRmYTUwYWM0NTY3MjM4ZTlhMzQxZGM1ODI3NTc4YTNiYjAyMWVhNThiZmU5
11
+ MTViNDNkMzkzYzZlYzcxOTJlZWI5YThiOTgyMjRmMDRiYzkyYTk=
12
12
  data.tar.gz: !binary |-
13
- YWFhOWI2ZjU2YjMxYmFmNzJmYjM3NDAxODlkNWIwYWNhYWVhNzJjYmVhM2E5
14
- YmJkZmIzNWE5ZTQzNjkzMTc0MDc5ZTExMGExOWE5OTNhNTRhMmI0NWU0ZTE5
15
- NzA0Zjc4MmE3NDM2NGJkOGNkNDM3ZDc2YTk0NmJmOWFjOTgwZTM=
13
+ OWYxNzQ3NWVjNjU4OWRmYWM5YWIxN2U2OGFjZDA5ZWQ2NzRhYTcxNjBiODli
14
+ NTQ2MTJhMmU2N2Y0MTc4YTkyNWZhNTUyMDM2ZjlmYTI1YTFiOGU0NmQ5NTEy
15
+ N2IzZTJjZTc1MGY3ZDgyNDRiNWY4ZjY0NTE2M2QyM2I3YmIzNTY=
@@ -8,4 +8,7 @@ AllCops:
8
8
  - 'spec/templates/unicorn.rb'
9
9
  - 'spec/templates/world.rb'
10
10
  - 'test.rb'
11
+
12
+ LineLength:
13
+ Max: 120
11
14
  require: rubocop-rspec
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Asana
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/asana.svg)](http://badge.fury.io/rb/asana)
3
4
  [![Build Status](https://travis-ci.org/Asana/ruby-asana.svg?branch=master)](https://travis-ci.org/Asana/ruby-asana)
4
5
  [![Code Climate](https://codeclimate.com/github/Asana/ruby-asana/badges/gpa.svg)](https://codeclimate.com/github/Asana/ruby-asana)
5
6
  [![Dependency Status](https://gemnasium.com/Asana/ruby-asana.svg)](https://gemnasium.com/Asana/ruby-asana)
@@ -39,7 +40,7 @@ The most minimal example would be as follows:
39
40
  require 'asana'
40
41
 
41
42
  client = Asana::Client.new do |c|
42
- c.authentication :api_token, 'my_api_token'
43
+ c.authentication :access_token, 'personal_access_token'
43
44
  end
44
45
 
45
46
  client.workspaces.find_all.first
@@ -76,11 +77,11 @@ the [documentation for each of them][docs].
76
77
 
77
78
  This gem supports authenticating against the Asana API with either an API token or through OAuth2.
78
79
 
79
- #### API Token
80
+ #### Personal Access Token
80
81
 
81
82
  ```ruby
82
83
  Asana::Client.new do |c|
83
- c.authentication :api_token, 'my_api_token'
84
+ c.authentication :access_token, 'personal_access_token'
84
85
  end
85
86
  ```
86
87
 
@@ -3,14 +3,14 @@ require 'bundler'
3
3
  Bundler.require
4
4
  require 'asana'
5
5
 
6
- api_token = ENV['ASANA_API_TOKEN']
7
- unless api_token
8
- abort "Run this program with the env var ASANA_API_TOKEN.\n" \
9
- "Go to http://app.asana.com/-/account_api to see your API token."
6
+ access_token = ENV['ASANA_ACCESS_TOKEN']
7
+ unless access_token
8
+ abort "Run this program with the env var ASANA_ACCESS_TOKEN.\n" \
9
+ "Go to http://app.asana.com/-/account_api to create a personal access token."
10
10
  end
11
11
 
12
12
  client = Asana::Client.new do |c|
13
- c.authentication :api_token, api_token
13
+ c.authentication :access_token, access_token
14
14
  end
15
15
 
16
16
  workspace = client.workspaces.find_all.first
@@ -2,14 +2,14 @@ require 'bundler'
2
2
  Bundler.require
3
3
  require 'asana'
4
4
 
5
- api_token = ENV['ASANA_API_TOKEN']
6
- unless api_token
7
- abort "Run this program with the env var ASANA_API_TOKEN.\n" \
8
- "Go to http://app.asana.com/-/account_api to see your API token."
5
+ access_token = ENV['ASANA_ACCESS_TOKEN']
6
+ unless access_token
7
+ abort "Run this program with the env var ASANA_ACCESS_TOKEN.\n" \
8
+ "Go to http://app.asana.com/-/account_api to create a personal access token."
9
9
  end
10
10
 
11
11
  client = Asana::Client.new do |c|
12
- c.authentication :api_token, api_token
12
+ c.authentication :access_token, access_token
13
13
  end
14
14
 
15
15
  puts "My Workspaces:"
@@ -8,9 +8,9 @@ module Asana
8
8
  #
9
9
  # Examples
10
10
  #
11
- # # Authentication with an API token
11
+ # # Authentication with a personal access token
12
12
  # Asana::Client.new do |client|
13
- # client.authentication :api_token, '...'
13
+ # client.authentication :access_token, '...'
14
14
  # end
15
15
  #
16
16
  # # OAuth2 with a plain bearer token (doesn't support auto-refresh)
@@ -5,7 +5,7 @@ module Asana
5
5
  # Examples
6
6
  #
7
7
  # config = Configuration.new
8
- # config.authentication :api_token, 'my_api_token'
8
+ # config.authentication :access_token, 'personal_access_token'
9
9
  # config.adapter :typhoeus
10
10
  # config.configure_faraday { |conn| conn.use MyMiddleware }
11
11
  # config.to_h
@@ -30,8 +30,8 @@ module Asana
30
30
  # Raises ArgumentError if the arguments are invalid.
31
31
  def authentication(type, value)
32
32
  auth = case type
33
- when :oauth2 then oauth2(value)
34
- when :api_token then api_token(value)
33
+ when :oauth2 then oauth2(value)
34
+ when :access_token then from_bearer_token(value)
35
35
  else error "unsupported authentication type #{type}"
36
36
  end
37
37
  @configuration[:authentication] = auth
@@ -99,16 +99,6 @@ module Asana
99
99
  'containing :refresh_token or :bearer_token.'
100
100
  end
101
101
  end
102
- # rubocop:enable Metrics/MethodLength
103
-
104
- # Internal: Configures a TokenAuthentication strategy.
105
- #
106
- # token - [String] the API token
107
- #
108
- # Returns a [Authentication::TokenAuthentication] strategy.
109
- def api_token(token)
110
- Authentication::TokenAuthentication.new(token)
111
- end
112
102
 
113
103
  # Internal: Configures an OAuth2 AccessTokenAuthentication strategy.
114
104
  #
@@ -77,10 +77,10 @@ module Asana
77
77
  # a fresh `sync` token in the response.
78
78
  def poll
79
79
  rate_limiting do
80
- body = @client.get('/events',
81
- params: params,
82
- options: @options).body
83
- @sync = body['sync']
80
+ body = @client.get('/events',
81
+ params: params,
82
+ options: @options).body
83
+ @sync = body['sync']
84
84
  @events += body.fetch('data', []).map do |event_data|
85
85
  Event.new(event_data, client: @client)
86
86
  end
@@ -9,7 +9,17 @@ module Asana
9
9
  class Attachment < Resource
10
10
 
11
11
 
12
- attr_reader :id
12
+ attr_reader :created_at
13
+
14
+ attr_reader :download_url
15
+
16
+ attr_reader :host
17
+
18
+ attr_reader :name
19
+
20
+ attr_reader :parent
21
+
22
+ attr_reader :view_url
13
23
 
14
24
  class << self
15
25
  # Returns the plural name of the resource.
@@ -16,7 +16,23 @@ module Asana
16
16
  include EventSubscription
17
17
 
18
18
 
19
- attr_reader :id
19
+ attr_reader :archived
20
+
21
+ attr_reader :created_at
22
+
23
+ attr_reader :followers
24
+
25
+ attr_reader :modified_at
26
+
27
+ attr_reader :name
28
+
29
+ attr_reader :color
30
+
31
+ attr_reader :notes
32
+
33
+ attr_reader :workspace
34
+
35
+ attr_reader :team
20
36
 
21
37
  class << self
22
38
  # Returns the plural name of the resource.
@@ -149,6 +165,25 @@ module Asana
149
165
  client.delete("/projects/#{id}") && true
150
166
  end
151
167
 
168
+ # Returns compact records for all sections in the specified project.
169
+ #
170
+ # per_page - [Integer] the number of records to fetch per page.
171
+ # options - [Hash] the request I/O options.
172
+ def sections(per_page: 20, options: {})
173
+ params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
174
+ Collection.new(parse(client.get("/projects/#{id}/sections", params: params, options: options)), type: Resource, client: client)
175
+ end
176
+
177
+ # Returns the compact task records for all tasks within the given project,
178
+ # ordered by their priority within the project. Tasks can exist in more than one project at a time.
179
+ #
180
+ # per_page - [Integer] the number of records to fetch per page.
181
+ # options - [Hash] the request I/O options.
182
+ def tasks(per_page: 20, options: {})
183
+ params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
184
+ Collection.new(parse(client.get("/projects/#{id}/tasks", params: params, options: options)), type: Task, client: client)
185
+ end
186
+
152
187
  end
153
188
  end
154
189
  end
@@ -13,7 +13,25 @@ module Asana
13
13
  class Story < Resource
14
14
 
15
15
 
16
- attr_reader :id
16
+ attr_reader :created_at
17
+
18
+ attr_reader :created_by
19
+
20
+ attr_reader :hearted
21
+
22
+ attr_reader :hearts
23
+
24
+ attr_reader :num_hearts
25
+
26
+ attr_reader :text
27
+
28
+ attr_reader :html_text
29
+
30
+ attr_reader :target
31
+
32
+ attr_reader :source
33
+
34
+ attr_reader :type
17
35
 
18
36
  class << self
19
37
  # Returns the plural name of the resource.
@@ -23,7 +41,7 @@ module Asana
23
41
 
24
42
  # Returns the full record for a single story.
25
43
  #
26
- # id - [Id] Globally unique identifier for the team.
44
+ # id - [Id] Globally unique identifier for the story.
27
45
  #
28
46
  # options - [Hash] the request I/O options.
29
47
  def find_by_id(client, id, options: {})
@@ -13,7 +13,17 @@ module Asana
13
13
  class Tag < Resource
14
14
 
15
15
 
16
- attr_reader :id
16
+ attr_reader :created_at
17
+
18
+ attr_reader :followers
19
+
20
+ attr_reader :name
21
+
22
+ attr_reader :color
23
+
24
+ attr_reader :notes
25
+
26
+ attr_reader :workspace
17
27
 
18
28
  class << self
19
29
  # Returns the plural name of the resource.
@@ -115,6 +125,16 @@ module Asana
115
125
  client.delete("/tags/#{id}") && true
116
126
  end
117
127
 
128
+ # Returns the compact task records for all tasks with the given tag.
129
+ # Tasks can have more than one tag at a time.
130
+ #
131
+ # per_page - [Integer] the number of records to fetch per page.
132
+ # options - [Hash] the request I/O options.
133
+ def get_tasks_with_tag(per_page: 20, options: {})
134
+ params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
135
+ Collection.new(parse(client.get("/tags/#{id}/tasks", params: params, options: options)), type: Task, client: client)
136
+ end
137
+
118
138
  end
119
139
  end
120
140
  end
@@ -18,6 +18,40 @@ module Asana
18
18
 
19
19
  attr_reader :assignee_status
20
20
 
21
+ attr_reader :created_at
22
+
23
+ attr_reader :completed
24
+
25
+ attr_reader :completed_at
26
+
27
+ attr_reader :due_on
28
+
29
+ attr_reader :due_at
30
+
31
+ attr_reader :external
32
+
33
+ attr_reader :followers
34
+
35
+ attr_reader :hearted
36
+
37
+ attr_reader :hearts
38
+
39
+ attr_reader :modified_at
40
+
41
+ attr_reader :name
42
+
43
+ attr_reader :notes
44
+
45
+ attr_reader :num_hearts
46
+
47
+ attr_reader :projects
48
+
49
+ attr_reader :parent
50
+
51
+ attr_reader :workspace
52
+
53
+ attr_reader :memberships
54
+
21
55
  class << self
22
56
  # Returns the plural name of the resource.
23
57
  def plural_name
@@ -32,11 +66,12 @@ module Asana
32
66
  # workspace cannot be changed once set. The workspace need not be set
33
67
  # explicitly if you specify a `project` or a `parent` task instead.
34
68
  #
69
+ # workspace - [Id] The workspace to create a task in.
35
70
  # options - [Hash] the request I/O options.
36
71
  # data - [Hash] the attributes to post.
37
- def create(client, options: {}, **data)
38
-
39
- self.new(parse(client.post("/tasks", body: data, options: options)).first, client: client)
72
+ def create(client, workspace: nil, options: {}, **data)
73
+ with_params = data.merge(workspace: workspace).reject { |_,v| v.nil? || Array(v).empty? }
74
+ self.new(parse(client.post("/tasks", body: with_params, options: options)).first, client: client)
40
75
  end
41
76
 
42
77
  # Creating a new task is as easy as POSTing to the `/tasks` endpoint
@@ -45,7 +80,7 @@ module Asana
45
80
  #
46
81
  # Every task is required to be created in a specific workspace, and this
47
82
  # workspace cannot be changed once set. The workspace need not be set
48
- # explicitly if you specify a project or a parent task instead.
83
+ # explicitly if you specify a `project` or a `parent` task instead.
49
84
  #
50
85
  # workspace - [Id] The workspace to create a task in.
51
86
  # options - [Hash] the request I/O options.
@@ -251,14 +286,14 @@ module Asana
251
286
  Collection.new(parse(client.get("/tasks/#{id}/subtasks", params: params, options: options)), type: self.class, client: client)
252
287
  end
253
288
 
254
- # Makes an existing task a subtask of another. Returns an empty data block.
289
+ # Creates a new subtask and adds it to the parent task. Returns the full record
290
+ # for the newly created subtask.
255
291
  #
256
- # subtask - [Id] The subtask to add to the task.
257
292
  # options - [Hash] the request I/O options.
258
293
  # data - [Hash] the attributes to post.
259
- def add_subtask(subtask: required("subtask"), options: {}, **data)
260
- with_params = data.merge(subtask: subtask).reject { |_,v| v.nil? || Array(v).empty? }
261
- client.post("/tasks/#{id}/subtasks", body: with_params, options: options) && true
294
+ def add_subtask(options: {}, **data)
295
+
296
+ self.class.new(parse(client.post("/tasks/#{id}/subtasks", body: data, options: options)).first, client: client)
262
297
  end
263
298
 
264
299
  # Changes the parent of a task. Each task may only be a subtask of a single
@@ -8,8 +8,6 @@ module Asana
8
8
  class Team < Resource
9
9
 
10
10
 
11
- attr_reader :id
12
-
13
11
  attr_reader :name
14
12
 
15
13
  class << self
@@ -12,7 +12,7 @@ module Asana
12
12
  class User < Resource
13
13
 
14
14
 
15
- attr_reader :id
15
+ attr_reader :name
16
16
 
17
17
  attr_reader :email
18
18
 
@@ -34,7 +34,7 @@ module Asana
34
34
  Resource.new(parse(client.get("/users/me", options: options)).first, client: client)
35
35
  end
36
36
 
37
- # Returns the full user record for a single user.
37
+ # Returns the full user record for the single user with the provided ID.
38
38
  #
39
39
  # id - [Id] Globally unique identifier for the user.
40
40
  #
@@ -44,8 +44,8 @@ module Asana
44
44
  self.new(parse(client.get("/users/#{id}", options: options)).first, client: client)
45
45
  end
46
46
 
47
- # Returns the user records for all users in all workspaces and organizations
48
- # accessible to the authenticated user.
47
+ # Returns the user records for all users in the specified workspace or
48
+ # organization.
49
49
  #
50
50
  # workspace - [Id] The workspace in which to get users.
51
51
  # per_page - [Integer] the number of records to fetch per page.
@@ -55,8 +55,9 @@ module Asana
55
55
  Collection.new(parse(client.get("/workspaces/#{workspace}/users", params: params, options: options)), type: self, client: client)
56
56
  end
57
57
 
58
- # Returns the user records for all users in the specified workspace or
59
- # organization.
58
+ # Returns the user records for all users in all workspaces and organizations
59
+ # accessible to the authenticated user. Accepts an optional workspace ID
60
+ # parameter.
60
61
  #
61
62
  # workspace - [Id] The workspace or organization to filter users on.
62
63
  # per_page - [Integer] the number of records to fetch per page.
@@ -20,8 +20,6 @@ module Asana
20
20
  class Workspace < Resource
21
21
 
22
22
 
23
- attr_reader :id
24
-
25
23
  attr_reader :name
26
24
 
27
25
  attr_reader :is_organization
@@ -52,7 +50,13 @@ module Asana
52
50
  end
53
51
  end
54
52
 
55
- # Update properties on a workspace. Returns the complete, updated workspace record.
53
+ # A specific, existing workspace can be updated by making a PUT request on
54
+ # the URL for that workspace. Only the fields provided in the data block
55
+ # will be updated; any unspecified fields will remain unchanged.
56
+ #
57
+ # Currently the only field that can be modified for a workspace is its `name`.
58
+ #
59
+ # Returns the complete, updated workspace record.
56
60
  #
57
61
  # options - [Hash] the request I/O options.
58
62
  # data - [Hash] the attributes to post.
@@ -1,5 +1,5 @@
1
1
  #:nodoc:
2
2
  module Asana
3
3
  # Public: Version of the gem.
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
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.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Txus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -132,10 +132,10 @@ files:
132
132
  - bin/setup
133
133
  - examples/Gemfile
134
134
  - examples/Gemfile.lock
135
- - examples/api_token.rb
136
135
  - examples/cli_app.rb
137
136
  - examples/events.rb
138
137
  - examples/omniauth_integration.rb
138
+ - examples/personal_access_token.rb
139
139
  - lib/asana.rb
140
140
  - lib/asana/authentication.rb
141
141
  - lib/asana/authentication/oauth2.rb