slack_chatter 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGRlNTY1N2FiMGM2Yzg1ZTk2OTEwZmEwNjZhNjNlMzZkNmVmNjYzZQ==
5
- data.tar.gz: !binary |-
6
- ODVjNWYzMTNhMGM3NTM5MmRhZGYxNzRkNzc0NDk1ODRjNWQxZjA3MA==
2
+ SHA1:
3
+ metadata.gz: cbdeb6731b5e1f50eb9efe9bc7df788107008ed6
4
+ data.tar.gz: 302bc64aff8bb9403edea5f360ac3c626bc4ff42
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MTQ0MzczYWY1NzRmM2FmZDlkMDk3Yzc2ZTkzYjE5MjVkNjdjYmE1NDBkYzcz
10
- ZWU2OGQ3NGUzZTM4ZmJmNGNjMjYzYThhMmQ2NTYxYzI5NmNiYTZjMjk2MWM0
11
- ZjAxZDY0ZTYwZmY5ZWIyZjRlZjc3MjZmM2JmNTk3MmE3MjI2Mjc=
12
- data.tar.gz: !binary |-
13
- NDM3MTY1NTNiOTgyY2VmNjE1YjliMWY5OGZlMzBkNDEzNzYxNGYyYmM0MGUx
14
- ZTk3NTY5ZGEyYjQ4ZThjYWI0MmI0NjhmNDM5MTc3MzkwNjBiZGFlZWQyNDIw
15
- NzRmODA0MDVlNzhiNTZkNTBhYjc2MDkzMTIzNDNhMDM4N2E5MGY=
6
+ metadata.gz: d10f464eb8d22c77b64968518b536878b8af5d88d6b9e141cfbe2ac9b13803f6d521acee316a5e0ae49e9cbb58f7554af095a1d4f3bf69862bb2f36d9e1ccc2b
7
+ data.tar.gz: aae2560b0e2356d619e3cddaef096a88079215aea16c214289d0d4ccb69db1a8aea5d110f0cf03103dd476d59a161c583a2fe8d8e5aa3d1c5d3745ba7add7919
data/README.md CHANGED
@@ -21,23 +21,478 @@ Or install it yourself as:
21
21
 
22
22
  $ gem install slack_chatter
23
23
 
24
- ## Usage
24
+ ## Basic Configuration
25
25
 
26
- Create a new client instance
26
+ #### Create a new client instance
27
27
  ```ruby
28
- client = SlackChatter::Client.new("some-slack-token")
28
+ client = SlackChatter::Client.new("slack-api-token")
29
29
  ```
30
30
 
31
- Use methods namespaced as they are in the API reference ie, to list channels:
31
+ #### Specifiy a custom icon to be used when posting:
32
32
  ```ruby
33
- client.channels.list
33
+ opts = {:icon_url => "http://www.example.com/slack-bot-profile-picture.jpg"}
34
+ client = SlackChatter::Client.new("slack-api-token", opts)
34
35
  ```
35
36
 
36
- Each of these methods requires you to provide the required attributes as explicit arguments and then add any optional arguments in an options hash with the keys and values as those expected in the Slack API doc
37
+ #### Specify a custom username to be used when posting:
37
38
  ```ruby
39
+ opts = {:username => "slack_chatter"}
40
+ client = SlackChatter::Client.new("slack-api-token", opts)
41
+ ```
42
+
43
+ #### Test your Connection
44
+ ```ruby
45
+ client.api.test
46
+ => #<SlackChatter::Response ok=true, args={"token"=>"xoxp-4114452838-4114452844-6031365557-2cc510"}, response=#<HTTParty::Response:0x7fed152c6c08 ...>, code=200>
47
+ ```
48
+
49
+ #### Test your Auth Token
50
+ ```ruby
51
+ client.auth.test
52
+ => #<SlackChatter::Response ok=true, args={"token"=>"xoxp-4114452838-4114452844-6031365557-2cc510"}, response=#<HTTParty::Response:0x7fed152c6c08 ...>, code=200>
53
+ ```
54
+
55
+ ## Web API
56
+
57
+ ### Basic Usage
58
+ The apit methods follow the following format
59
+ ```ruby
60
+ client.method_namespace.action(required, arguments, {optional: arguments})
61
+ # Example:
38
62
  client.chat.post_message("some-channel-id", "some message to post", {option_param: })
39
63
  ```
64
+ These methods directly correspond to those found in the [Slack API Docs](https://api.slack.com/methods)
65
+
66
+ NOTE: Not all methods accept an options hash. However, all methods with optional parameters do accept one.
67
+
68
+ ### Channels
69
+
70
+ #### Get a list of Channels
71
+ ```ruby
72
+ response = client.channels.list
73
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, channels=[...], code=200>
74
+ response.success?
75
+ => true
76
+ response.code
77
+ => 200
78
+ response.channels
79
+ => channels [
80
+ {
81
+ "id"=>"C043CDARC",
82
+ "name"=>"general",
83
+ "is_channel"=>true,
84
+ "created"=>1426800248,
85
+ "creator"=>"U043CDAQU",
86
+ "is_archived"=>false,
87
+ "is_general"=>true,
88
+ "is_member"=>true,
89
+ "members"=>["U043CDAQU"],
90
+ "topic"=>{
91
+ "value"=>"",
92
+ "creator"=>"",
93
+ "last_set"=>0
94
+ },
95
+ "purpose"=>{
96
+ "value"=>"This channel is for team-wide communication and announcements. All team members are in this channel.",
97
+ "creator"=>"",
98
+ "last_set"=>0
99
+ },
100
+ "num_members"=>1
101
+ },
102
+ {...},
103
+ ...
104
+ ]
105
+ ```
106
+
107
+ #### Find a Channel by Name
108
+ ```ruby
109
+ response = client.channels.find_by_name("wiggle-room")
110
+ => {
111
+ "id"=>"C06817EC8",
112
+ "name"=>"wiggle-room",
113
+ "is_channel"=>true,
114
+ "created"=>1434045083,
115
+ "creator"=>"U043CDAQU",
116
+ "is_archived"=>false,
117
+ "is_general"=>false,
118
+ "is_member"=>true,
119
+ "members"=>["U043CDAQU"],
120
+ "topic"=>{
121
+ "value"=>"",
122
+ "creator"=>"",
123
+ "last_set"=>0
124
+ },
125
+ "purpose"=>{
126
+ "value"=>"",
127
+ "creator"=>"",
128
+ "last_set"=>0
129
+ },
130
+ "num_members"=>1
131
+ }
132
+ channel_id = response["id"]
133
+ => "C06817EC8"
134
+ ```
135
+
136
+ #### Create a Channel
137
+ ```ruby
138
+ response = client.channels.create("new channel name")
139
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, channel={"id"=>"C0680SVU2", ...}, code=200>
140
+ channel_id = response.channel["id"]
141
+ => "C0680SVU2"
142
+ ```
143
+
144
+ #### Join a Channel
145
+ ```ruby
146
+ response = client.channels.join("wiggle-room")
147
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, channel={"id"=>"C06817EC8", "name"=>"wiggle-room", "is_channel"=>true, "created"=>1434045083, "creator"=>"U043CDAQU", "is_archived"=>false, "is_general"=>false, "is_member"=>true, "last_read"=>"1434045087.000003", "latest"=>{"user"=>"U043CDAQU", "type"=>"message", "subtype"=>"channel_leave", "text"=>"<@U043CDAQU|sly_fox> has left the channel", "ts"=>"1434045087.000003"}, "unread_count"=>0, "unread_count_display"=>0, "members"=>["U043CDAQU"], "topic"=>{"value"=>"", "creator"=>"", "last_set"=>0}, "purpose"=>{"value"=>"", "creator"=>"", "last_set"=>0}}, code=200>
148
+ ```
149
+
150
+ #### Get Channel History
151
+ ```ruby
152
+ response = client.channels.history(channel_id)
153
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, latest="1434027718", messages=[...], has_more=false, code=200, success?=true>
154
+ ```
155
+ Options:
156
+ - latest: End of time range of messages to include in results
157
+ - oldest: Start of time range of messages to include in results
158
+ - inclusive: Include messages with latest or oldest timestamp in results (use 0 or 1 for boolean values)
159
+ - count: Number of messages to return, between 1 and 1000
160
+
161
+ Note: For all timestamps you must use epoch time, so for any Date, Time, or DateTime object you want to use as an argument use #to_i on it
162
+ ```ruby
163
+ (Time.now() - 5.hours).to_i
164
+ => 1434027718 # epoch
165
+ ```
166
+
167
+ #### Invite a User to Channel
168
+ ```ruby
169
+ response = client.channels.invite(channel_id, user_id)
170
+ ```
171
+
172
+ #### Kick a User from a Channel
173
+ ```ruby
174
+ response = client.channels.kick(channel_id, user_id)
175
+ ```
176
+
177
+ #### Leave a Channel
178
+ ```ruby
179
+ response = client.channels.leave(channel_id)
180
+ ```
181
+
182
+ #### Mark a Time in a Channel
183
+ Used for tracking read position
184
+ ```ruby
185
+ response = client.channels.mark(channel_id)
186
+ ```
187
+
188
+ #### Rename a Channel
189
+ ```ruby
190
+ response = client.channels.rename(channel_id, "new_name")
191
+ ```
192
+
193
+ #### Set a Channel's Topic
194
+ ```ruby
195
+ response = client.channels.leave(channel_id, "Dogs acting like cats")
196
+ ```
197
+
198
+ #### Set a Channel's Purpose
199
+ ```ruby
200
+ response = client.channels.leave(channel_id, "Post adorable videos")
201
+ ```
202
+
203
+ #### Archive a Channel
204
+ ```ruby
205
+ response = client.channels.archive(channel_id)
206
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
207
+ ```
208
+
209
+ #### Unarchive a Channel
210
+ ```ruby
211
+ response = client.channels.unarchive(channel_id)
212
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
213
+ ```
214
+
215
+ ### Chat
216
+
217
+ #### Post to a Message
218
+ ```ruby
219
+ response = client.chat.post_message(channel_id, "I am a robot: beep boop boop beep")
220
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, channel="C0680SVU2", ts="1434044883.000003", message={"text"=>"I am a robot: beep boop boop beep", "username"=>"bot", "type"=>"message", "subtype"=>"bot_message", "ts"=>"1434044883.000003"}, code=200>
221
+ message = response.message
222
+ => {
223
+ "text"=>"I am a robot: beep boop boop beep",
224
+ "username"=>"bot",
225
+ "type"=>"message",
226
+ "subtype"=>"bot_message",
227
+ "ts"=>"1434044883.000003"
228
+ }
229
+ ```
230
+
231
+ #### Update a Message
232
+ ```ruby
233
+ response = client.chat.update(message["ts"], channel_id, "Just kidding, not a robot")
234
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
235
+ ```
236
+
237
+ #### Delete a Message
238
+ ```ruby
239
+ response = client.chat.delete(message["ts"], channel_id)
240
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
241
+ ```
242
+
243
+ ### Groups
244
+ Groups has the same methods that Channels has, with the exception that you cannot join a group (you must be invited) and it has the following additional methods:
245
+
246
+ #### Open a Group
247
+ ```ruby
248
+ client.groups.open(group_id)
249
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
250
+ ```
251
+
252
+ #### Close a Group
253
+ ```ruby
254
+ client.groups.close(group_id)
255
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
256
+ ```
257
+
258
+ #### Create a Child Group
259
+ This method takes an existing private group and performs the following steps:
260
+
261
+ - Renames the existing group (from "example" to "example-archived").
262
+ - Archives the existing group.
263
+ - Creates a new group with the name of the existing group.
264
+ - Adds all members of the existing group to the new group.
265
+ - This is useful when inviting a new member to an existing group while hiding all previous chat history from them. In this scenario you can call groups.createChild followed by groups.invite.
40
266
 
267
+ The new group will have a special parent_group property pointing to the original archived group. This will only be returned for members of both groups, so will not be visible to any newly invited members.
268
+
269
+ ```ruby
270
+ client.groups.create_child(group_id)
271
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
272
+ ```
273
+
274
+ ### Im (or Direct Messages)
275
+
276
+ #### Open a Direct Message Channel
277
+ This method opens a direct message channel with another member of your Slack team.
278
+ ```ruby
279
+ client.im.open(user_id)
280
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
281
+ ```
282
+
283
+ #### Get the History of a Direct Message Channel
284
+ ```ruby
285
+ response = client.im.history(user_id, opts_hash)
286
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, latest="1434027718", messages=[...], has_more=false, code=200>
287
+ ```
288
+ Options:
289
+ - latest: epoch_timestamp - End of time range of messages to include in results
290
+ - oldest: epoch_timestamp Start of time range of messages to include in results
291
+ - inclusive: 0 or 1 - Include messages with latest or oldest timestamp in results (use 0 or 1 for all boolean values)
292
+ - count: integer - Number of messages to return, between 1 and 1000
293
+
294
+ Note: For all timestamps you must use epoch time, so for any Date, Time, or DateTime object you want to use as an argument use #to_i on it
295
+ ```ruby
296
+ (Time.now() - 5.hours).to_i
297
+ => 1434027718 # epoch
298
+ ```
299
+
300
+ #### List all Direct Message Channels
301
+ ```ruby
302
+ response = client.im.list
303
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, latest="1434027718", channels=[...], has_more=false, code=200>
304
+ ```
305
+
306
+ #### Close a Direct Message Channel
307
+ This method closes a direct message channel with another member of your Slack team.
308
+ ```ruby
309
+ client.im.close(user_id)
310
+ => #<SlackChatter::Response ok=true, response=#<HTTPARTY::RESPONSE:0x7fed1528eba0 ...>, code=200>
311
+ ```
312
+
313
+ #### Mark a Time in a Direct Message Channel
314
+ Used for tracking read position
315
+ ```ruby
316
+ response = client.im.mark(channel_id)
317
+ ```
318
+
319
+ ### Files
320
+
321
+ #### Delete a File
322
+ ```ruby
323
+ response = client.files.delete(file_id)
324
+ ```
325
+
326
+ #### Get File Info
327
+ ```ruby
328
+ response = client.files.info(file_id, options)
329
+ ```
330
+ Options:
331
+ - count: integer - Number of items to return
332
+ - page: integer - Page number of results to return
333
+
334
+ The file object contains information about the uploaded file.
335
+
336
+ Each comment object in the comments array contains details about a single comment. Comments are returned oldest first.
337
+
338
+ The paging information contains the count of comments returned, the total number of comments, the page of results returned in this response and the total number of pages available.
339
+
340
+ #### List all Files
341
+ ```ruby
342
+ response = client.files.list(options)
343
+ ```
344
+ Options:
345
+ - user: user_id - Filter files created by a single user
346
+ - ts_from: epoch_timestamp - Filter files created after this timestamp (inclusive)
347
+ - ts_to: epoch_timestamp - Filter files created before this timestamp (inclusive)
348
+ - types: Filter files by type, one or more of the following values ie, ["images", "zips"] or "gdocs"
349
+ - all - All files
350
+ - posts - Posts
351
+ - snippets - Snippets
352
+ - images - Image files
353
+ - gdocs - Google docs
354
+ - zips - Zip files
355
+ - pdfs - PDF files
356
+ - count: integer - Number of items to return per page
357
+ - page: integer - Page number of results to return
358
+
359
+ #### Upload a File
360
+ **Not Currently Supported**
361
+
362
+ ### Search
363
+ #### Search Everything
364
+ ```ruby
365
+ response = client.search.all("robot")
366
+ => #<SlackChatter::Response ok=true, query="robot", messages={...}, "files"=>{...}}, response=#<HTTParty::Response:0x7fed152b9148 ...>, code=200>
367
+ response["messages"]
368
+ => {
369
+ "total"=>1,
370
+ "pagination"=>{
371
+ "total_count"=>1,
372
+ "page"=>1,
373
+ "per_page"=>20,
374
+ "page_count"=>1,
375
+ "first"=>1,
376
+ "last"=>1
377
+ },
378
+ "paging"=>{
379
+ "count"=>20,
380
+ "total"=>1,
381
+ "page"=>1,
382
+ "pages"=>1
383
+ },
384
+ "matches"=>[
385
+ {
386
+ "type"=>"message",
387
+ "user"=>"",
388
+ "username"=>"bot",
389
+ "ts"=>"1434044883.000003",
390
+ "text"=>"I am a robot: beep boop boop beep", "channel"=>{
391
+ "id"=>"C0680SVU2",
392
+ "name"=>"new-channel-name"
393
+ },
394
+ "permalink"=>"https://myteam.slack.com/archives/new-channel-name/p1434044883000003"
395
+ },
396
+ {...},
397
+ ...
398
+ ]
399
+ }
400
+ ```
401
+ Options:
402
+ - sort: "score" or "timestamp" - Return matches sorted by either score or timestamp.
403
+ - sort_dir: "asc" or "desc" - Sort direction
404
+ - highlight: 1 - Pass a value of 1 to enable query highlight markers more info [here](https://api.slack.com/methods/search.all).
405
+ - count: integer - Number of results to return per page
406
+ - page: integer - Page number of results to return
407
+
408
+ #### Search Files
409
+ ```ruby
410
+ response = client.search.files("robot")
411
+ => #<SlackChatter::Response ok=true, query="robot", messages={...}, "files"=>{...}}, response=#<HTTParty::Response:0x7fed152b9148 ...>, code=200>
412
+ ```
413
+ Options:
414
+ - sort: "score" or "timestamp" - Return matches sorted by either score or timestamp.
415
+ - sort_dir: "asc" or "desc" - Sort direction
416
+ - highlight: 1 - Pass a value of 1 to enable query highlight markers more info [here](https://api.slack.com/methods/search.all).
417
+ - count: integer - Number of results to return per page
418
+ - page: integer - Page number of results to return
419
+
420
+ #### Search Messages
421
+ ```ruby
422
+ response = client.search.messages("robot")
423
+ => #<SlackChatter::Response ok=true, query="robot", messages={...}, "files"=>{...}}, response=#<HTTParty::Response:0x7fed152b9148 ...>, code=200>
424
+ ```
425
+ Options:
426
+ - sort: "score" or "timestamp" - Return matches sorted by either score or timestamp.
427
+ - sort_dir: "asc" or "desc" - Sort direction
428
+ - highlight: 1 - Pass a value of 1 to enable query highlight markers more info [here](https://api.slack.com/methods/search.all).
429
+ - count: integer - Number of results to return per page
430
+ - page: integer - Page number of results to return
431
+
432
+ ### Stars
433
+ #### List all Stars
434
+ ```ruby
435
+ response = client.stars.list(options)
436
+ ```
437
+ Options:
438
+ - user: user_id
439
+ - count: integer - number of items to return per page
440
+ - page: integer - page number of results to return
441
+
442
+ ### Team
443
+ #### Get Access Logs
444
+ ```ruby
445
+ response = client.team.access_logs(options)
446
+ ```
447
+ Options:
448
+ - count: integer - number of items to return per page
449
+ - page: integer - page number of results to return
450
+
451
+ #### Get Team Info
452
+ ```ruby
453
+ response = client.team.info
454
+ ```
455
+
456
+ ### Users
457
+ #### Get the Presence of a User
458
+ ```ruby
459
+ response = client.users.get_presence(user_id)
460
+ ```
461
+
462
+ #### Get a User's Info
463
+ ```ruby
464
+ response = client.users.info(user_id)
465
+ ```
466
+
467
+ #### List all Users
468
+ ```ruby
469
+ response = client.users.list
470
+ ```
471
+
472
+ #### Set your User to active
473
+ ```ruby
474
+ response = client.users.set_active
475
+ ```
476
+
477
+ #### Set your Presence
478
+ ```ruby
479
+ response = client.users.set_presence("away") # Either "auto" or "away"
480
+ ```
481
+
482
+ ### Emoji
483
+ #### List all Emoji's
484
+ ```ruby
485
+ response = client.emoji.list
486
+ ```
487
+
488
+ ### Oauth
489
+ #### Get Access Token
490
+ This method allows you to exchange a temporary OAuth code for an API access token. This is used as part of the [OAuth authentication flow](https://api.slack.com/docs/oauth).
491
+ ```ruby
492
+ respone = client.oauth.access(client_id, client_secret, code, options)
493
+ ```
494
+ Options:
495
+ - redirect_uri: url - This must match the originally submitted URI (if one was sent).
41
496
 
42
497
  ## Contributing
43
498
 
@@ -228,11 +228,11 @@ im:
228
228
  close:
229
229
  args:
230
230
  token: token
231
- channel: id
231
+ user: id
232
232
  history:
233
233
  args:
234
234
  token: token
235
- channel: id
235
+ user: id
236
236
  options:
237
237
  latest: epoch # End of time range of messages to include in results
238
238
  oldest: epoch # Start of time range of messages to include in results
@@ -244,12 +244,12 @@ im:
244
244
  mark:
245
245
  args:
246
246
  token: token
247
- channel: id
247
+ user: id
248
248
  ts: epoch
249
249
  open:
250
250
  args:
251
251
  token: token
252
- channel: id
252
+ user: id
253
253
 
254
254
  oauth:
255
255
  access:
@@ -271,7 +271,7 @@ search:
271
271
  token: token
272
272
  query: string
273
273
  options:
274
- sort: {choice: ["choice", "timestamp"]}
274
+ sort: {choice: ["score", "timestamp"]}
275
275
  sort_dir: {choice: ["asc", "desc"]}
276
276
  highlight: {choice: ["1"]}
277
277
  count: integer
@@ -281,7 +281,7 @@ search:
281
281
  token: token
282
282
  query: string
283
283
  options:
284
- sort: {choice: ["choice", "timestamp"]}
284
+ sort: {choice: ["score", "timestamp"]}
285
285
  sort_dir: {choice: ["asc", "desc"]}
286
286
  highlight: {choice: ["1"]}
287
287
  count: integer
@@ -291,7 +291,7 @@ search:
291
291
  token: token
292
292
  query: string
293
293
  options:
294
- sort: {choice: ["choice", "timestamp"]}
294
+ sort: {choice: ["score", "timestamp"]}
295
295
  sort_dir: {choice: ["asc", "desc"]}
296
296
  highlight: {choice: ["1"]}
297
297
  count: integer
@@ -4,11 +4,11 @@ module SlackChatter
4
4
  class Im < SlackChatter::Api::Base
5
5
 
6
6
 
7
- def close channel_id
8
- call_method("im", "close", {"channel" => channel_id})
7
+ def close user_id
8
+ call_method("im", "close", {"user" => channel_id})
9
9
  end
10
10
 
11
- def history channel_id, opts={}
11
+ def history user_id, opts={}
12
12
  # latest - End of time range of messages to include in results
13
13
  # oldest - Start of time range of messages to include in results
14
14
  # inclusive - Include messages with latest or oldest timestamp in results (send 0/1)
@@ -21,13 +21,13 @@ module SlackChatter
21
21
  call_method("im", "list", {})
22
22
  end
23
23
 
24
- def mark channel_id, epoch_time_stamp
24
+ def mark user_id, epoch_time_stamp
25
25
  # ts - Timestamp of the most recently seen message
26
26
  call_method("im", "mark", {"channel" => channel_id, "ts" => epoch_time_stamp})
27
27
  end
28
28
 
29
- def open channel_id
30
- call_method("im", "open", {"channel" => channel_id})
29
+ def open user_id
30
+ call_method("im", "open", {"user" => channel_id})
31
31
  end
32
32
  end
33
33
  end
@@ -8,21 +8,17 @@ require 'slack_chatter/response'
8
8
  module SlackChatter
9
9
  class Client
10
10
 
11
- def self.test_client
12
- self.new("xoxp-4114452838-4114452844-6031365557-2cc510")
13
- end
14
-
15
11
  include SlackChatter::Api::Namespaces
16
12
 
17
13
  attr_reader :access_token, :username, :icon_url, :namespaces
18
- # https://slack.com/api/METHOD
19
- def initialize(access_token, username=nil, icon_url=nil, *args)
20
- opts = (args.last.is_a?(Hash) ? args.last : {}).with_indifferent_access.reject{|_,v| v.nil?}
14
+
15
+ def initialize(access_token, opts={})
16
+ opts = opts.with_indifferent_access.reject{|_,v| v.nil?}
21
17
  opts.reverse_merge!(default_slack_configuration)
22
18
 
23
19
  @access_token = access_token
24
- @username = username || opts[:username]
25
- @icon_url = icon_url
20
+ @username = opts[:username]
21
+ @icon_url = opts[:icon_url]
26
22
  @uri_scheme = opts[:uri_scheme]
27
23
  @uri_host = opts[:uri_host]
28
24
  @uri_base_path = opts[:uri_base_path]
@@ -33,8 +29,7 @@ module SlackChatter
33
29
  {
34
30
  uri_scheme: "https",
35
31
  uri_host: "slack.com",
36
- uri_base_path: "/api",
37
- username: "RubySlackBot"
32
+ uri_base_path: "/api"
38
33
  }
39
34
  end
40
35
 
@@ -7,8 +7,8 @@ module SlackChatter
7
7
  def initialize response
8
8
  parsed_res = JSON.parse(response.body)
9
9
  super(parsed_res)
10
+ self.response = response
10
11
  self.code = response.code
11
- self.send("success?=", (parsed_res["ok"] == true))
12
12
  end
13
13
 
14
14
  def to_h
@@ -19,5 +19,13 @@ module SlackChatter
19
19
  JSON.dump(to_h)
20
20
  end
21
21
 
22
+ def success?
23
+ parsed_res["ok"]
24
+ end
25
+
26
+ def failed?
27
+ !parsed_res["ok"]
28
+ end
29
+
22
30
  end
23
31
  end
@@ -1,3 +1,3 @@
1
1
  module SlackChatter
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_chatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant
@@ -14,160 +14,160 @@ dependencies:
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: webmock
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-encoding-matchers
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: json
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 1.7.7
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.7.7
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: httparty
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.13.3
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.13.3
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: httmultiparty
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: activesupport
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: 3.2.11
160
- - - <=
160
+ - - "<="
161
161
  - !ruby/object:Gem::Version
162
162
  version: 4.1.7
163
163
  type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
- - - ! '>='
167
+ - - ">="
168
168
  - !ruby/object:Gem::Version
169
169
  version: 3.2.11
170
- - - <=
170
+ - - "<="
171
171
  - !ruby/object:Gem::Version
172
172
  version: 4.1.7
173
173
  description: Simple to use Slack API wrapper which makes it easy to access and use
@@ -178,9 +178,9 @@ executables: []
178
178
  extensions: []
179
179
  extra_rdoc_files: []
180
180
  files:
181
- - .gitignore
182
- - .rspec
183
- - .travis.yml
181
+ - ".gitignore"
182
+ - ".rspec"
183
+ - ".travis.yml"
184
184
  - Gemfile
185
185
  - README.md
186
186
  - Rakefile
@@ -217,17 +217,17 @@ require_paths:
217
217
  - lib
218
218
  required_ruby_version: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ! '>='
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  requirements:
225
- - - ! '>='
225
+ - - ">="
226
226
  - !ruby/object:Gem::Version
227
227
  version: '0'
228
228
  requirements: []
229
229
  rubyforge_project:
230
- rubygems_version: 2.4.6
230
+ rubygems_version: 2.2.2
231
231
  signing_key:
232
232
  specification_version: 4
233
233
  summary: Simple to use SlackChatter wrapper