contextio 0.3.0 → 0.4.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.
- data/README.md +4 -4
- data/Rakefile +3 -3
- data/lib/contextio.rb +510 -47
- metadata +22 -44
data/README.md
CHANGED
@@ -7,7 +7,7 @@ If all you want is to use the gem can install it with the following command:
|
|
7
7
|
|
8
8
|
gem install contextio
|
9
9
|
|
10
|
-
You can get more information at [http://context.io](http://context.io). Complete API documentation is available at [http://context.io/docs/
|
10
|
+
You can get more information at [http://context.io](http://context.io). Complete API documentation is available at [http://context.io/docs/2.0/](http://context.io/docs/2.0/).
|
11
11
|
|
12
12
|
An example
|
13
13
|
----------
|
@@ -17,11 +17,11 @@ An example
|
|
17
17
|
|
18
18
|
key = 'the key you get in your developer console'
|
19
19
|
secret = ' the secret you get in your developer console'
|
20
|
-
account = 'your account
|
20
|
+
account = 'your account id'
|
21
21
|
|
22
22
|
connection = ContextIO::Connection.new(key, secret)
|
23
|
-
messages = connection.
|
24
|
-
puts JSON.parse(messages)
|
23
|
+
messages = connection.list_messages(:account => account, :since => (Time.now - 24 * 60 * 60 * 5))
|
24
|
+
puts JSON.parse(messages.body).first['subject']
|
25
25
|
|
26
26
|
LICENSE
|
27
27
|
-------
|
data/Rakefile
CHANGED
@@ -4,10 +4,10 @@ require 'rake'
|
|
4
4
|
require 'rake/gempackagetask'
|
5
5
|
|
6
6
|
GEM = "contextio"
|
7
|
-
GEM_VERSION = "0.
|
7
|
+
GEM_VERSION = "0.4.0"
|
8
8
|
SUMMARY = "Provides interface for Context.IO email"
|
9
|
-
AUTHOR = "
|
10
|
-
EMAIL = "
|
9
|
+
AUTHOR = "Dominik Gehl"
|
10
|
+
EMAIL = "dominik@context.io"
|
11
11
|
HOMEPAGE = "http://context.io/"
|
12
12
|
|
13
13
|
task :default => [:test]
|
data/lib/contextio.rb
CHANGED
@@ -2,7 +2,7 @@ require 'oauth'
|
|
2
2
|
require 'net/http'
|
3
3
|
|
4
4
|
module ContextIO
|
5
|
-
VERSION = "
|
5
|
+
VERSION = "2.0"
|
6
6
|
|
7
7
|
class ContextIO::Connection
|
8
8
|
def initialize(key='', secret='', server='https://api.context.io')
|
@@ -10,113 +10,576 @@ module ContextIO
|
|
10
10
|
@token = OAuth::AccessToken.new @consumer
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
get '
|
13
|
+
def discovery(options)
|
14
|
+
get 'discovery', {:source_type => 'imap'}.merge(options)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
get '
|
17
|
+
def list_connect_tokens()
|
18
|
+
get 'connect_tokens'
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def get_connect_token(options)
|
22
|
+
if ! options.has_key?(:token) then
|
23
|
+
raise ArgumentError, "missing required argument token", caller
|
24
|
+
end
|
25
|
+
get "connect_tokens/#{options[:token]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_connect_token(options)
|
29
|
+
if ! options.has_key?(:callback_url) then
|
30
|
+
raise ArgumentError, "missing required argument callback_url", caller
|
31
|
+
end
|
32
|
+
post "connect_tokens", options
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_connect_token(options)
|
36
|
+
if ! options.has_key?(:token) then
|
37
|
+
raise ArgumentError, "missing required argument token", caller
|
38
|
+
end
|
39
|
+
delete "connect_tokens/#{options[:token]}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def list_oauth_providers
|
43
|
+
get 'oauth_providers'
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_oauth_provider(options)
|
47
|
+
if ! options.has_key?(:provider_consumer_key) then
|
48
|
+
raise ArgumentError, "missing required argument provider_consumer_key", caller
|
49
|
+
end
|
50
|
+
get "oauth_providers/#{options[:provider_consumer_key]}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_oauth_provider(options)
|
54
|
+
if ! options.has_key?(:provider_consumer_key) then
|
55
|
+
raise ArgumentError, "missing required argument provider_consumer_key", caller
|
56
|
+
end
|
57
|
+
if ! options.has_key?(:type) then
|
58
|
+
raise ArgumentError, "missing required argument type", caller
|
59
|
+
end
|
60
|
+
if ! options.has_key?(:provider_consumer_secret) then
|
61
|
+
raise ArgumentError, "missing required argument provider_consumer_secret", caller
|
62
|
+
end
|
63
|
+
post "oauth_providers/", options
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete_oauth_provider(options)
|
67
|
+
if ! options.has_key?(:provider_consumer_key) then
|
68
|
+
raise ArgumentError, "missing required argument provider_consumer_key", caller
|
69
|
+
end
|
70
|
+
delete "oauth_providers/#{options[:provider_consumer_key]}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def list_contacts(options)
|
74
|
+
if ! options.has_key?(:account) then
|
75
|
+
raise ArgumentError, "missing required argument account", caller
|
76
|
+
end
|
77
|
+
account = options.delete(:account)
|
78
|
+
get "accounts/#{account}/contacts", options
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_contact(options)
|
82
|
+
if ! options.has_key?(:account) then
|
83
|
+
raise ArgumentError, "missing required argument account", caller
|
84
|
+
end
|
85
|
+
if ! options.has_key?(:email) then
|
86
|
+
raise ArgumentError, "missing required argument email", caller
|
87
|
+
end
|
88
|
+
get "accounts/#{options[:account]}/contacts/#{URI.escape options[:email]}"
|
89
|
+
end
|
90
|
+
|
91
|
+
def list_contact_files(options)
|
92
|
+
if ! options.has_key?(:account) then
|
93
|
+
raise ArgumentError, "missing required argument account", caller
|
94
|
+
end
|
95
|
+
if ! options.has_key?(:email) then
|
96
|
+
raise ArgumentError, "missing required argument email", caller
|
97
|
+
end
|
98
|
+
account = options.delete(:account)
|
99
|
+
email = URI.escape(options.delete(:email))
|
100
|
+
get "accounts/#{account}/contacts/#{email}/files", options
|
101
|
+
end
|
102
|
+
|
103
|
+
def list_contact_messages(options)
|
104
|
+
if ! options.has_key?(:account) then
|
105
|
+
raise ArgumentError, "missing required argument account", caller
|
106
|
+
end
|
107
|
+
if ! options.has_key?(:email) then
|
108
|
+
raise ArgumentError, "missing required argument email", caller
|
109
|
+
end
|
110
|
+
account = options.delete(:account)
|
111
|
+
email = URI.escape(options.delete(:email))
|
112
|
+
get "accounts/#{account}/contacts/#{email}/messages", options
|
113
|
+
end
|
114
|
+
|
115
|
+
def list_contact_threads(options)
|
116
|
+
if ! options.has_key?(:account) then
|
117
|
+
raise ArgumentError, "missing required argument account", caller
|
118
|
+
end
|
119
|
+
if ! options.has_key?(:email) then
|
120
|
+
raise ArgumentError, "missing required argument email", caller
|
121
|
+
end
|
122
|
+
account = options.delete(:account)
|
123
|
+
email = URI.escape(options.delete(:email))
|
124
|
+
get "accounts/#{account}/contacts/#{email}/threads", options
|
23
125
|
end
|
24
126
|
|
25
|
-
def
|
26
|
-
|
127
|
+
def list_files(options)
|
128
|
+
if ! options.has_key?(:account) then
|
129
|
+
raise ArgumentError, "missing required argument account", caller
|
130
|
+
end
|
131
|
+
account = options.delete(:account)
|
132
|
+
get "accounts/#{account}/files", options
|
27
133
|
end
|
28
134
|
|
29
|
-
def
|
30
|
-
|
135
|
+
def get_file(options)
|
136
|
+
if ! options.has_key?(:account) then
|
137
|
+
raise ArgumentError, "missing required argument account", caller
|
138
|
+
end
|
139
|
+
if ! options.has_key?(:file_id) then
|
140
|
+
raise ArgumentError, "missing required argument file_id", caller
|
141
|
+
end
|
142
|
+
get "accounts/#{options[:account]}/files/#{options[:file_id]}"
|
31
143
|
end
|
32
144
|
|
33
|
-
def
|
34
|
-
|
145
|
+
def get_file_content(options)
|
146
|
+
if ! options.has_key?(:account) then
|
147
|
+
raise ArgumentError, "missing required argument account", caller
|
148
|
+
end
|
149
|
+
if ! options.has_key?(:file_id) then
|
150
|
+
raise ArgumentError, "missing required argument file_id", caller
|
151
|
+
end
|
152
|
+
if ! options.has_key?(:as_link) then
|
153
|
+
get "accounts/#{options[:account]}/files/#{options[:file_id]}/content"
|
154
|
+
else
|
155
|
+
get "accounts/#{options[:account]}/files/#{options[:file_id]}/content?as_link=#{options[:as_link]}"
|
156
|
+
end
|
35
157
|
end
|
36
158
|
|
37
|
-
def
|
38
|
-
|
159
|
+
def get_file_changes(options)
|
160
|
+
if ! options.has_key?(:account) then
|
161
|
+
raise ArgumentError, "missing required argument account", caller
|
162
|
+
end
|
163
|
+
if ! options.has_key?(:file_id) then
|
164
|
+
raise ArgumentError, "missing required argument file_id", caller
|
165
|
+
end
|
166
|
+
account = options.delete(:account)
|
167
|
+
file_id = options.delete(:file_id)
|
168
|
+
get "accounts/#{account}/files/#{file_id}/changes", options
|
39
169
|
end
|
40
170
|
|
41
|
-
def
|
42
|
-
|
171
|
+
def list_file_revisions(options)
|
172
|
+
if ! options.has_key?(:account) then
|
173
|
+
raise ArgumentError, "missing required argument account", caller
|
174
|
+
end
|
175
|
+
if ! options.has_key?(:file_id) then
|
176
|
+
raise ArgumentError, "missing required argument file_id", caller
|
177
|
+
end
|
178
|
+
account = options.delete(:account)
|
179
|
+
file_id = options.delete(:file_id)
|
180
|
+
get "accounts/#{account}/files/#{file_id}/revisions", options
|
43
181
|
end
|
44
182
|
|
45
|
-
def
|
46
|
-
|
183
|
+
def list_file_related(options)
|
184
|
+
if ! options.has_key?(:account) then
|
185
|
+
raise ArgumentError, "missing required argument account", caller
|
186
|
+
end
|
187
|
+
if ! options.has_key?(:file_id) then
|
188
|
+
raise ArgumentError, "missing required argument file_id", caller
|
189
|
+
end
|
190
|
+
account = options.delete(:account)
|
191
|
+
file_id = options.delete(:file_id)
|
192
|
+
get "accounts/#{account}/files/#{file_id}/related", options
|
47
193
|
end
|
48
194
|
|
49
|
-
def
|
50
|
-
|
195
|
+
def list_messages(options)
|
196
|
+
if ! options.has_key?(:account) then
|
197
|
+
raise ArgumentError, "missing required argument account", caller
|
198
|
+
end
|
199
|
+
account = options.delete(:account)
|
200
|
+
get "accounts/#{account}/messages", options
|
201
|
+
end
|
202
|
+
|
203
|
+
def get_message(options)
|
204
|
+
if ! options.has_key?(:account) then
|
205
|
+
raise ArgumentError, "missing required argument account", caller
|
206
|
+
end
|
207
|
+
|
208
|
+
account = options.delete(:account)
|
209
|
+
if options.has_key?(:email_message_id) then
|
210
|
+
email_message_id = URI.escape(options.delete(:email_message_id))
|
211
|
+
get "accounts/#{account}/messages/#{email_message_id}"
|
212
|
+
elsif options.has_key?(:message_id) then
|
213
|
+
message_id = options.delete(:message_id)
|
214
|
+
get "accounts/#{account}/messages/#{message_id}"
|
215
|
+
elsif options.has_key?(:gmail_message_id) then
|
216
|
+
gmail_message_id = options.delete(:gmail_message_id)
|
217
|
+
if options[:gmail_message_id].start_with?('gm-') then
|
218
|
+
get "accounts/#{account}/messages/#{gmail_message_id}"
|
219
|
+
else
|
220
|
+
get "accounts/#{account}/messages/gm-#{gmail_message_id}"
|
221
|
+
end
|
222
|
+
end
|
51
223
|
end
|
52
224
|
|
53
|
-
def
|
54
|
-
|
225
|
+
def get_message_headers(options)
|
226
|
+
if ! options.has_key?(:account) then
|
227
|
+
raise ArgumentError, "missing required argument account", caller
|
228
|
+
end
|
229
|
+
|
230
|
+
account = options.delete(:account)
|
231
|
+
if options.has_key?(:email_message_id) then
|
232
|
+
email_message_id = URI.escape(options.delete(:email_message_id))
|
233
|
+
get "accounts/#{account}/messages/#{email_message_id}/headers"
|
234
|
+
elsif options.has_key?(:message_id) then
|
235
|
+
message_id = options.delete(:message_id)
|
236
|
+
get "accounts/#{account}/messages/#{message_id}/headers"
|
237
|
+
elsif options.has_key?(:gmail_message_id) then
|
238
|
+
gmail_message_id = options.delete(:gmail_message_id)
|
239
|
+
if options[:gmail_message_id].start_with?('gm-') then
|
240
|
+
get "accounts/#{account}/messages/#{gmail_message_id}/headers"
|
241
|
+
else
|
242
|
+
get "accounts/#{account}/messages/gm-#{gmail_message_id}/headers"
|
243
|
+
end
|
244
|
+
end
|
55
245
|
end
|
56
246
|
|
57
|
-
def
|
58
|
-
|
247
|
+
def get_message_flags(options)
|
248
|
+
if ! options.has_key?(:account) then
|
249
|
+
raise ArgumentError, "missing required argument account", caller
|
250
|
+
end
|
251
|
+
|
252
|
+
account = options.delete(:account)
|
253
|
+
if options.has_key?(:email_message_id) then
|
254
|
+
email_message_id = URI.escape(options.delete(:email_message_id))
|
255
|
+
get "accounts/#{account}/messages/#{email_message_id}/flags"
|
256
|
+
elsif options.has_key?(:message_id) then
|
257
|
+
message_id = options.delete(:message_id)
|
258
|
+
get "accounts/#{account}/messages/#{message_id}/flags"
|
259
|
+
elsif options.has_key?(:gmail_message_id) then
|
260
|
+
gmail_message_id = options.delete(:gmail_message_id)
|
261
|
+
if options[:gmail_message_id].start_with?('gm-') then
|
262
|
+
get "accounts/#{account}/messages/#{gmail_message_id}/flags"
|
263
|
+
else
|
264
|
+
get "accounts/#{account}/messages/gm-#{gmail_message_id}/flags"
|
265
|
+
end
|
266
|
+
end
|
59
267
|
end
|
60
268
|
|
61
|
-
def
|
62
|
-
|
269
|
+
def get_message_body(options)
|
270
|
+
if ! options.has_key?(:account) then
|
271
|
+
raise ArgumentError, "missing required argument account", caller
|
272
|
+
end
|
273
|
+
|
274
|
+
account = options.delete(:account)
|
275
|
+
if options.has_key?(:email_message_id) then
|
276
|
+
email_message_id = URI.escape(options.delete(:email_message_id))
|
277
|
+
get "accounts/#{account}/messages/#{email_message_id}/body"
|
278
|
+
elsif options.has_key?(:message_id) then
|
279
|
+
message_id = options.delete(:message_id)
|
280
|
+
get "accounts/#{account}/messages/#{message_id}/body"
|
281
|
+
elsif options.has_key?(:gmail_message_id) then
|
282
|
+
gmail_message_id = options.delete(:gmail_message_id)
|
283
|
+
if options[:gmail_message_id].start_with?('gm-') then
|
284
|
+
get "accounts/#{account}/messages/#{gmail_message_id}/body"
|
285
|
+
else
|
286
|
+
get "accounts/#{account}/messages/gm-#{gmail_message_id}/body"
|
287
|
+
end
|
288
|
+
end
|
63
289
|
end
|
64
290
|
|
65
|
-
def
|
66
|
-
|
291
|
+
def get_message_thread(options)
|
292
|
+
if ! options.has_key?(:account) then
|
293
|
+
raise ArgumentError, "missing required argument account", caller
|
294
|
+
end
|
295
|
+
|
296
|
+
if options.has_key?(:email_message_id) then
|
297
|
+
get "accounts/#{options[:account]}/messages/#{URI.escape options[:email_message_id]}/thread"
|
298
|
+
elsif options.has_key?(:message_id) then
|
299
|
+
get "accounts/#{options[:account]}/messages/#{options[:message_id]}/thread"
|
300
|
+
elsif options.has_key?(:gmail_message_id) then
|
301
|
+
if options[:gmail_message_id].start_with?('gm-') then
|
302
|
+
get "accounts/#{options[:account]}/messages/#{options[:gmail_message_id]}/thread"
|
303
|
+
else
|
304
|
+
get "accounts/#{options[:account]}/messages/gm-#{options[:gmail_message_id]}/thread"
|
305
|
+
end
|
306
|
+
end
|
67
307
|
end
|
68
308
|
|
69
|
-
def
|
70
|
-
|
309
|
+
def list_threads(options)
|
310
|
+
if ! options.has_key?(:account) then
|
311
|
+
raise ArgumentError, "missing required argument account", caller
|
312
|
+
end
|
313
|
+
account = options.delete(:account)
|
314
|
+
get "accounts/#{account}/threads", options
|
71
315
|
end
|
72
316
|
|
73
|
-
def
|
74
|
-
|
317
|
+
def get_thread(options)
|
318
|
+
if ! options.has_key?(:account) then
|
319
|
+
raise ArgumentError, "missing required argument account", caller
|
320
|
+
end
|
321
|
+
|
322
|
+
if options.has_key?(:email_message_id) then
|
323
|
+
get "accounts/#{options[:account]}/messages/#{URI.escape options[:email_message_id]}/thread"
|
324
|
+
elsif options.has_key?(:message_id) then
|
325
|
+
get "accounts/#{options[:account]}/messages/#{options[:message_id]}/thread"
|
326
|
+
elsif options.has_key?(:gmail_message_id) then
|
327
|
+
if options[:gmail_message_id].start_with?('gm-') then
|
328
|
+
get "accounts/#{options[:account]}/messages/#{options[:gmail_message_id]}/thread"
|
329
|
+
else
|
330
|
+
get "accounts/#{options[:account]}/messages/gm-#{options[:gmail_message_id]}/thread"
|
331
|
+
end
|
332
|
+
elsif options.has_key?(:gmail_thread_id) then
|
333
|
+
if options[:gmail_thread_id].start_with?('gm-') then
|
334
|
+
get "accounts/#{options[:account]}/threads/#{options[:gmail_thread_id]}"
|
335
|
+
else
|
336
|
+
get "accounts/#{options[:account]}/threads/gm-#{options[:gmail_thread_id]}"
|
337
|
+
end
|
338
|
+
end
|
75
339
|
end
|
76
340
|
|
77
341
|
def add_account(options)
|
78
|
-
|
342
|
+
if ! options.has_key?(:email) then
|
343
|
+
raise ArgumentError, "missing required argument email", caller
|
344
|
+
end
|
345
|
+
post "accounts", options
|
79
346
|
end
|
80
347
|
|
81
348
|
def modify_account(options)
|
82
|
-
|
349
|
+
if ! options.has_key?(:account) then
|
350
|
+
raise ArgumentError, "missing required argument account", caller
|
351
|
+
end
|
352
|
+
account = options.delete(:account)
|
353
|
+
post "accounts/#{account}", options
|
83
354
|
end
|
84
355
|
|
85
|
-
def
|
86
|
-
|
356
|
+
def get_account(options)
|
357
|
+
if ! options.has_key?(:account) then
|
358
|
+
raise ArgumentError, "missing required argument account", caller
|
359
|
+
end
|
360
|
+
account = options.delete(:account)
|
361
|
+
get "accounts/#{account}"
|
362
|
+
end
|
363
|
+
|
364
|
+
def delete_account(options)
|
365
|
+
if ! options.has_key?(:account) then
|
366
|
+
raise ArgumentError, "missing required argument account", caller
|
367
|
+
end
|
368
|
+
account = options.delete(:account)
|
369
|
+
delete "accounts/#{account}"
|
370
|
+
end
|
371
|
+
|
372
|
+
def list_account_email_addresses(options)
|
373
|
+
if ! options.has_key?(:account) then
|
374
|
+
raise ArgumentError, "missing required argument account", caller
|
375
|
+
end
|
376
|
+
get "accounts/#{options[:account]}/email_addresses"
|
377
|
+
end
|
378
|
+
|
379
|
+
def delete_email_address_from_account(options)
|
380
|
+
if ! options.has_key?(:account) then
|
381
|
+
raise ArgumentError, "missing required argument account", caller
|
382
|
+
end
|
383
|
+
if ! options.has_key?(:email_address) then
|
384
|
+
raise ArgumentError, "missing required argument account", caller
|
385
|
+
end
|
386
|
+
delete "accounts/#{account}/email_addresses/#{options[:email_address]}"
|
387
|
+
end
|
388
|
+
|
389
|
+
def set_primary_email_address_for_account(options)
|
390
|
+
if ! options.has_key?(:account) then
|
391
|
+
raise ArgumentError, "missing required argument account", caller
|
392
|
+
end
|
393
|
+
if ! options.has_key?(:email_address) then
|
394
|
+
raise ArgumentError, "missing required argument account", caller
|
395
|
+
end
|
396
|
+
post "accounts/#{account}/email_addresses/#{options[:email_address]}", {:primary => 1}
|
397
|
+
end
|
398
|
+
|
399
|
+
def add_email_address_to_account(options)
|
400
|
+
if ! options.has_key?(:account) then
|
401
|
+
raise ArgumentError, "missing required argument account", caller
|
402
|
+
end
|
403
|
+
if ! options.has_key?(:email_address) then
|
404
|
+
raise ArgumentError, "missing required argument account", caller
|
405
|
+
end
|
406
|
+
account = options.delete(:account)
|
407
|
+
post "accounts/#{account}/email_addresses", options
|
408
|
+
end
|
409
|
+
|
410
|
+
def list_accounts(options)
|
411
|
+
get "accounts", options
|
412
|
+
end
|
413
|
+
|
414
|
+
def modify_source(options)
|
415
|
+
if ! options.has_key?(:account) then
|
416
|
+
raise ArgumentError, "missing required argument account", caller
|
417
|
+
end
|
418
|
+
if ! options.has_key?(:label) then
|
419
|
+
raise ArgumentError, "missing required argument label", caller
|
420
|
+
end
|
421
|
+
account = options.delete(:account)
|
422
|
+
label = URI.escape(options.delete(:label))
|
423
|
+
post "accounts/#{account}/sources/#{label}", options
|
424
|
+
end
|
425
|
+
|
426
|
+
def reset_source_status(options)
|
427
|
+
if ! options.has_key?(:account) then
|
428
|
+
raise ArgumentError, "missing required argument account", caller
|
429
|
+
end
|
430
|
+
if ! options.has_key?(:label) then
|
431
|
+
raise ArgumentError, "missing required argument label", caller
|
432
|
+
end
|
433
|
+
post "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}", { :status => 1 }
|
434
|
+
end
|
435
|
+
|
436
|
+
def list_sources(options)
|
437
|
+
if ! options.has_key?(:account) then
|
438
|
+
raise ArgumentError, "missing required argument account", caller
|
439
|
+
end
|
440
|
+
get "accounts/#{options[:account]}/sources"
|
441
|
+
end
|
442
|
+
|
443
|
+
def get_source(options)
|
444
|
+
if ! options.has_key?(:account) then
|
445
|
+
raise ArgumentError, "missing required argument account", caller
|
446
|
+
end
|
447
|
+
if ! options.has_key?(:label) then
|
448
|
+
raise ArgumentError, "missing required argument label", caller
|
449
|
+
end
|
450
|
+
get "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}"
|
451
|
+
end
|
452
|
+
|
453
|
+
def add_source(options)
|
454
|
+
if ! options.has_key?(:account) then
|
455
|
+
raise ArgumentError, "missing required argument account", caller
|
456
|
+
end
|
457
|
+
if ! options.has_key?(:type) then
|
458
|
+
options[:type] = 'imap'
|
459
|
+
end
|
460
|
+
account = options.delete(:account)
|
461
|
+
post "accounts/#{account}/sources", options
|
462
|
+
end
|
463
|
+
|
464
|
+
def delete_source(options)
|
465
|
+
if ! options.has_key?(:account) then
|
466
|
+
raise ArgumentError, "missing required argument account", caller
|
467
|
+
end
|
468
|
+
if ! options.has_key?(:label) then
|
469
|
+
raise ArgumentError, "missing required argument label", caller
|
470
|
+
end
|
471
|
+
delete "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}"
|
472
|
+
end
|
473
|
+
|
474
|
+
def sync_source(options)
|
475
|
+
if ! options.has_key?(:account) then
|
476
|
+
raise ArgumentError, "missing required argument account", caller
|
477
|
+
end
|
478
|
+
if ! options.has_key?(:label) then
|
479
|
+
post "accounts/#{options[:account]}/sync"
|
480
|
+
else
|
481
|
+
post "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}/sync"
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
def get_sync(options)
|
486
|
+
if ! options.has_key?(:account) then
|
487
|
+
raise ArgumentError, "missing required argument account", caller
|
488
|
+
end
|
489
|
+
if ! options.has_key?(:label) then
|
490
|
+
get "accounts/#{options[:account]}/sync"
|
491
|
+
else
|
492
|
+
get "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}/sync"
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
def add_folder_to_source(options)
|
497
|
+
if ! options.has_key?(:account) then
|
498
|
+
raise ArgumentError, "missing required argument account", caller
|
499
|
+
end
|
500
|
+
if ! options.has_key?(:label) then
|
501
|
+
raise ArgumentError, "missing required argument label", caller
|
502
|
+
end
|
503
|
+
put "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}/folders/#{URI.escape options[:folder]}"
|
504
|
+
end
|
505
|
+
|
506
|
+
def list_source_folders(options)
|
507
|
+
if ! options.has_key?(:account) then
|
508
|
+
raise ArgumentError, "missing required argument account", caller
|
509
|
+
end
|
510
|
+
if ! options.has_key?(:label) then
|
511
|
+
raise ArgumentError, "missing required argument label", caller
|
512
|
+
end
|
513
|
+
get "accounts/#{options[:account]}/sources/#{URI.escape options[:label]}/folders"
|
87
514
|
end
|
88
515
|
|
89
|
-
def
|
90
|
-
|
516
|
+
def list_webhooks(options)
|
517
|
+
if ! options.has_key?(:account) then
|
518
|
+
raise ArgumentError, "missing required argument account", caller
|
519
|
+
end
|
520
|
+
get "accounts/#{options[:account]}/webhooks"
|
91
521
|
end
|
92
522
|
|
93
|
-
def
|
94
|
-
|
523
|
+
def get_webhook(options)
|
524
|
+
if ! options.has_key?(:account) then
|
525
|
+
raise ArgumentError, "missing required argument account", caller
|
526
|
+
end
|
527
|
+
if ! options.has_key?(:webhook_id) then
|
528
|
+
raise ArgumentError, "missing required argument webhook_id", caller
|
529
|
+
end
|
530
|
+
get "accounts/#{options[:account]}/webhooks/#{options[:webhook_id]}"
|
95
531
|
end
|
96
532
|
|
97
|
-
def
|
98
|
-
|
533
|
+
def add_webhook(options)
|
534
|
+
if ! options.has_key?(:account) then
|
535
|
+
raise ArgumentError, "missing required argument account", caller
|
536
|
+
end
|
537
|
+
account = options.delete(:account)
|
538
|
+
post "accounts/#{account}/webhooks", options
|
539
|
+
end
|
540
|
+
|
541
|
+
def delete_webhook(options)
|
542
|
+
if ! options.has_key?(:account) then
|
543
|
+
raise ArgumentError, "missing required argument account", caller
|
544
|
+
end
|
545
|
+
if ! options.has_key?(:webhook_id) then
|
546
|
+
raise ArgumentError, "missing required argument webhook_id", caller
|
547
|
+
end
|
548
|
+
delete "accounts/#{options[:account]}/webhooks/#{options[:webhook_id]}"
|
99
549
|
end
|
100
550
|
|
101
551
|
private
|
102
552
|
|
103
553
|
def url(*args)
|
104
554
|
if args.length == 1
|
105
|
-
"/#{ContextIO::VERSION}/#{args[0]}
|
555
|
+
"/#{ContextIO::VERSION}/#{args[0]}"
|
106
556
|
else
|
107
|
-
"/#{ContextIO::VERSION}/#{args.shift.to_s}
|
557
|
+
"/#{ContextIO::VERSION}/#{args.shift.to_s}?#{parametrize args.last}"
|
108
558
|
end
|
109
559
|
end
|
110
560
|
|
111
561
|
def get(*args)
|
112
|
-
@token.get(url(*args),
|
562
|
+
@token.get(url(*args), { 'Accept' => 'application/json' })
|
563
|
+
end
|
564
|
+
|
565
|
+
def delete(*args)
|
566
|
+
@token.delete(url(*args), { 'Accept' => 'application/json' })
|
567
|
+
end
|
568
|
+
|
569
|
+
def put(action, args=nil)
|
570
|
+
@token.put(url(action), args, { 'Accept' => 'application/json' })
|
571
|
+
end
|
572
|
+
|
573
|
+
def post(action, args=nil)
|
574
|
+
@token.post(url(action), args, { 'Accept' => 'application/json' })
|
113
575
|
end
|
114
576
|
|
115
577
|
def parametrize(options)
|
116
578
|
URI.escape(options.collect do |k,v|
|
117
579
|
v = v.to_i if k == :since
|
118
580
|
v = v.join(',') if v.instance_of?(Array)
|
119
|
-
k = k.to_s
|
581
|
+
k = k.to_s
|
582
|
+
#k = k.to_s.gsub('_', '')
|
120
583
|
"#{k}=#{v}"
|
121
584
|
end.join('&'))
|
122
585
|
end
|
metadata
CHANGED
@@ -1,71 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: contextio
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Gary Haran
|
14
9
|
- Dominik Gehl
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
date: 2011-07-08 00:00:00 -04:00
|
20
|
-
default_executable:
|
13
|
+
date: 2012-08-10 00:00:00.000000000 Z
|
21
14
|
dependencies: []
|
22
|
-
|
23
|
-
|
24
|
-
email: gary.haran@gmail.com
|
15
|
+
description: Provides Ruby interface to Context.IO
|
16
|
+
email: dominik@context.io
|
25
17
|
executables: []
|
26
|
-
|
27
18
|
extensions: []
|
28
|
-
|
29
19
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
20
|
+
files:
|
32
21
|
- lib/contextio.rb
|
33
22
|
- Rakefile
|
34
23
|
- README.md
|
35
24
|
- README.textile
|
36
|
-
has_rdoc: true
|
37
25
|
homepage: http://context.io/
|
38
26
|
licenses: []
|
39
|
-
|
40
27
|
post_install_message:
|
41
28
|
rdoc_options: []
|
42
|
-
|
43
|
-
require_paths:
|
29
|
+
require_paths:
|
44
30
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
32
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
52
|
-
- 0
|
53
|
-
version: "0"
|
54
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
38
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
63
43
|
requirements: []
|
64
|
-
|
65
44
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.
|
45
|
+
rubygems_version: 1.8.24
|
67
46
|
signing_key:
|
68
47
|
specification_version: 3
|
69
|
-
summary: Provides interface
|
48
|
+
summary: Provides interface to Context.IO
|
70
49
|
test_files: []
|
71
|
-
|