asana 0.4.0 → 0.5.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 +8 -8
- data/lib/asana/client/configuration.rb +2 -2
- data/lib/asana/resources/webhook.rb +139 -0
- data/lib/asana/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGY2NmI1NmY2YzM2ZmIzOWMzYzMxMmUwZDBiNTVkOTU4ODNlNTUwOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mjk2OTM4ZWRmYzVjMzAwMzc5OGIxNDk5Mjg1NWI3MGZmYjExNTZjMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWE2YjgxNGU2ZmNhOGRkNGE1ODY3N2FkNTE5NjNlZDQzOTQ2YzFiM2JiYzY3
|
10
|
+
NzVkMDI3YTk0MzUxYjFmMmRhMTQxNzZkNmZjMjAwZDkxOThkOGE1ZWQ1YTJk
|
11
|
+
ZTY3YTdmYzYyZjllNGM0Y2Y4ZjEzYTQ4MTk0Y2IzZGRiN2E2Zjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGJkODcyZGZmMzljZGQ5NTY5MmMyYjkxZGQ0ZTJmYzhkMzIyYmY0MDZkMDVj
|
14
|
+
ZjI2MzdkODU1OGM5NDdiNTkwOTE2OWJlZjZhZWQzZGViYWY4ZWQxYzliZjgz
|
15
|
+
NDM5MjUxYmQwMTNhM2MyNWEzYTQyMjhiMWFiYmZlZjE0YWVlY2Q=
|
@@ -89,9 +89,9 @@ module Asana
|
|
89
89
|
case value
|
90
90
|
when ::OAuth2::AccessToken
|
91
91
|
from_access_token(value)
|
92
|
-
when ->
|
92
|
+
when ->(v) { v.is_a?(Hash) && v[:refresh_token] }
|
93
93
|
from_refresh_token(value)
|
94
|
-
when ->
|
94
|
+
when ->(v) { v.is_a?(Hash) && v[:bearer_token] }
|
95
95
|
from_bearer_token(value[:bearer_token])
|
96
96
|
else
|
97
97
|
error 'Invalid OAuth2 configuration: pass in either an ' \
|
@@ -0,0 +1,139 @@
|
|
1
|
+
### WARNING: This file is auto-generated by the asana-api-meta repo. Do not
|
2
|
+
### edit it manually.
|
3
|
+
|
4
|
+
module Asana
|
5
|
+
module Resources
|
6
|
+
# **Webhooks are currently in BETA - The information here may change.**
|
7
|
+
#
|
8
|
+
# Webhooks allow an application to be notified of changes. This is in addition
|
9
|
+
# to the ability to fetch those changes directly as
|
10
|
+
# [Events](/developers/api-reference/events) - in fact, Webhooks are just a way
|
11
|
+
# to receive Events via HTTP POST at the time they occur instead of polling for
|
12
|
+
# them. For services accessible via HTTP this is often vastly more convenient,
|
13
|
+
# and if events are not too frequent can be significantly more efficient.
|
14
|
+
#
|
15
|
+
# In both cases, however, changes are represented as Event objects - refer to
|
16
|
+
# the [Events documentation](/developers/api-reference/events) for more
|
17
|
+
# information on what data these events contain.
|
18
|
+
#
|
19
|
+
# **NOTE:** While Webhooks send arrays of Event objects to their target, the
|
20
|
+
# Event objects themselves contain *only IDs*, rather than the actual resource
|
21
|
+
# they are referencing. So while a normal event you receive via GET /events
|
22
|
+
# would look like this:
|
23
|
+
#
|
24
|
+
# {\
|
25
|
+
# "resource": {\
|
26
|
+
# "id": 1337,\
|
27
|
+
# "name": "My Task"\
|
28
|
+
# },\
|
29
|
+
# "parent": null,\
|
30
|
+
# "created_at": "2013-08-21T18:20:37.972Z",\
|
31
|
+
# "user": {\
|
32
|
+
# "id": 1123,\
|
33
|
+
# "name": "Tom Bizarro"\
|
34
|
+
# },\
|
35
|
+
# "action": "changed",\
|
36
|
+
# "type": "task"\
|
37
|
+
# }
|
38
|
+
#
|
39
|
+
# In a Webhook payload you would instead receive this:
|
40
|
+
#
|
41
|
+
# {\
|
42
|
+
# "resource": 1337,\
|
43
|
+
# "parent": null,\
|
44
|
+
# "created_at": "2013-08-21T18:20:37.972Z",\
|
45
|
+
# "user": 1123,\
|
46
|
+
# "action": "changed",\
|
47
|
+
# "type": "task"\
|
48
|
+
# }
|
49
|
+
#
|
50
|
+
# Webhooks themselves contain only the information necessary to deliver the
|
51
|
+
# events to the desired target as they are generated.
|
52
|
+
class Webhook < Resource
|
53
|
+
|
54
|
+
|
55
|
+
attr_reader :id
|
56
|
+
|
57
|
+
attr_reader :resource
|
58
|
+
|
59
|
+
attr_reader :target
|
60
|
+
|
61
|
+
attr_reader :active
|
62
|
+
|
63
|
+
attr_reader :created_at
|
64
|
+
|
65
|
+
attr_reader :last_success_at
|
66
|
+
|
67
|
+
attr_reader :last_failure_at
|
68
|
+
|
69
|
+
attr_reader :last_failure_content
|
70
|
+
|
71
|
+
class << self
|
72
|
+
# Returns the plural name of the resource.
|
73
|
+
def plural_name
|
74
|
+
'webhooks'
|
75
|
+
end
|
76
|
+
|
77
|
+
# Establishing a webhook is a two-part process. First, a simple HTTP POST
|
78
|
+
# similar to any other resource creation. Since you could have multiple
|
79
|
+
# webhooks we recommend specifying a unique local id for each target.
|
80
|
+
#
|
81
|
+
# Next comes the confirmation handshake. When a webhook is created, we will
|
82
|
+
# send a test POST to the `target` with an `X-Hook-Secret` header as
|
83
|
+
# described in the
|
84
|
+
# [Resthooks Security documentation](http://resthooks.org/docs/security/).
|
85
|
+
# The target must respond with a `200 OK` and a matching `X-Hook-Secret`
|
86
|
+
# header to confirm that this webhook subscription is indeed expected.
|
87
|
+
#
|
88
|
+
# If you do not acknowledge the webhook's confirmation handshake it will
|
89
|
+
# fail to setup, and you will receive an error in response to your attempt
|
90
|
+
# to create it. This means you need to be able to receive and complete the
|
91
|
+
# webhook *while* the POST request is in-flight.
|
92
|
+
#
|
93
|
+
# resource - [Id] A resource ID to subscribe to. The resource can be a task or project.
|
94
|
+
#
|
95
|
+
# target - [String] The URL to receive the HTTP POST.
|
96
|
+
#
|
97
|
+
# options - [Hash] the request I/O options.
|
98
|
+
# data - [Hash] the attributes to post.
|
99
|
+
def create(client, resource: required("resource"), target: required("target"), options: {}, **data)
|
100
|
+
with_params = data.merge(resource: resource, target: target).reject { |_,v| v.nil? || Array(v).empty? }
|
101
|
+
self.new(parse(client.post("/webhooks", body: with_params, options: options)).first, client: client)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the compact representation of all webhooks your app has
|
105
|
+
# registered for the authenticated user in the given workspace.
|
106
|
+
#
|
107
|
+
# workspace - [Id] The workspace to query for webhooks in.
|
108
|
+
#
|
109
|
+
# resource - [Id] Only return webhooks for the given resource.
|
110
|
+
#
|
111
|
+
# per_page - [Integer] the number of records to fetch per page.
|
112
|
+
# options - [Hash] the request I/O options.
|
113
|
+
def get_all(client, workspace: required("workspace"), resource: nil, per_page: 20, options: {})
|
114
|
+
params = { workspace: workspace, resource: resource, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
115
|
+
Collection.new(parse(client.get("/webhooks", params: params, options: options)), type: self, client: client)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Returns the full record for the given webhook.
|
119
|
+
#
|
120
|
+
# id - [Id] The webhook to get.
|
121
|
+
#
|
122
|
+
# options - [Hash] the request I/O options.
|
123
|
+
def get_by_id(client, id, options: {})
|
124
|
+
|
125
|
+
self.new(parse(client.get("/webhooks/#{id}", options: options)).first, client: client)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# This method permanently removes a webhook. Note that it may be possible
|
130
|
+
# to receive a request that was already in flight after deleting the
|
131
|
+
# webhook, but no further requests will be issued.
|
132
|
+
def delete_by_id()
|
133
|
+
|
134
|
+
self.class.new(parse(client.delete("/webhooks/#{id}")).first, client: client)
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
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.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/asana/resources/task.rb
|
167
167
|
- lib/asana/resources/team.rb
|
168
168
|
- lib/asana/resources/user.rb
|
169
|
+
- lib/asana/resources/webhook.rb
|
169
170
|
- lib/asana/resources/workspace.rb
|
170
171
|
- lib/asana/ruby2_0_0_compatibility.rb
|
171
172
|
- lib/asana/version.rb
|