groupme-api 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ # TEST_ACCOUNT_ACCESS_TOKEN = ''
6
+ ACCESS_TOKEN = defined?(TEST_ACCOUNT_ACCESS_TOKEN) ? TEST_ACCOUNT_ACCESS_TOKEN : SecureRandom.base64(30).tr('+', '0')
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vcr'
4
+
5
+ VCR.configure do |config|
6
+ config.hook_into :webmock
7
+ config.allow_http_connections_when_no_cassette = true
8
+ config.cassette_library_dir = 'spec/fixtures'
9
+ config.default_cassette_options = { record: :new_episodes }
10
+ config.filter_sensitive_data('ACCESS_TOKEN') { ACCESS_TOKEN }
11
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'webmock/rspec'
4
+
5
+ WebMock.enable!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupme-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinnell Shah
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-02 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -109,33 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.15'
111
111
  - !ruby/object:Gem::Dependency
112
- name: sinatra
112
+ name: vcr
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.0'
117
+ version: '4.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.0'
125
- - !ruby/object:Gem::Dependency
126
- name: sinatra-contrib
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '2.0'
124
+ version: '4.0'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: webmock
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -163,25 +149,21 @@ files:
163
149
  - Gemfile
164
150
  - Gemfile.lock
165
151
  - Guardfile
152
+ - LICENSE
166
153
  - README.md
167
154
  - Rakefile
168
155
  - groupme-api.gemspec
156
+ - lib/groupme-api.rb
169
157
  - lib/groupme.rb
170
- - lib/groupme/configuration.rb
171
- - lib/groupme/group.rb
172
- - lib/groupme/request.rb
173
- - lib/groupme/response.rb
158
+ - lib/groupme/client.rb
174
159
  - lib/groupme/version.rb
175
- - spec/fixtures/groups/index.json
176
- - spec/fixtures/groups/new.json
177
- - spec/fixtures/groups/show.json
178
- - spec/groupme/configuration_spec.rb
179
- - spec/groupme/group_spec.rb
180
- - spec/groupme/request_spec.rb
181
- - spec/groupme/response_spec.rb
160
+ - lib/groupme_api.rb
161
+ - spec/groupme/client_spec.rb
182
162
  - spec/groupme_spec.rb
183
163
  - spec/spec_helper.rb
184
- - spec/support/fake_groupme.rb
164
+ - spec/support/groupme.rb
165
+ - spec/support/vcr.rb
166
+ - spec/support/webmock.rb
185
167
  homepage: https://github.com/kinnell/groupme-ruby-gem
186
168
  licenses: []
187
169
  metadata: {}
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GroupMe
4
- class Configuration
5
- attr_accessor :access_token
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GroupMe
4
- class Group
5
- def self.all
6
- end
7
- end
8
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GroupMe
4
- class Request
5
- API_BASE_URI = 'https://api.groupme.com/v3'
6
- ACCEPTABLE_METHODS = %i[get post delete].freeze
7
-
8
- attr_reader :method, :path, :opts
9
-
10
- def initialize(method = :get, path = '', opts = {})
11
- raise UnacceptableRequestMethodError unless ACCEPTABLE_METHODS.include?(method)
12
-
13
- @method = method
14
- @path = path
15
- @opts = opts
16
- @client = HTTPClient.new(base_url: API_BASE_URI, default_header: { 'Content-Type': 'application/json' })
17
- end
18
-
19
- def send
20
- response = @client.request(@method, full_uri, query: full_opts)
21
- Response.new(response)
22
- end
23
-
24
- def full_uri
25
- "#{API_BASE_URI}/#{@path}"
26
- end
27
-
28
- def full_opts
29
- { token: token }.merge(@opts)
30
- end
31
-
32
- def token
33
- @token = @opts[:token] || GroupMe.configuration.access_token
34
- end
35
- end
36
-
37
- class UnacceptableRequestMethodError < StandardError; end
38
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GroupMe
4
- class Response
5
- def initialize(response)
6
- @response = response
7
- end
8
-
9
- def raw
10
- @response
11
- end
12
-
13
- def code
14
- @response.code
15
- end
16
-
17
- def body
18
- JSON.parse(@response.body, symbolize_names: true).fetch(:response)
19
- end
20
- end
21
- end
@@ -1,674 +0,0 @@
1
- [
2
- {
3
- "id": "44835935",
4
- "group_id": "44835935",
5
- "name": "Gaming Group",
6
- "phone_number": "+1 3363554142",
7
- "type": "private",
8
- "description": "",
9
- "image_url": null,
10
- "creator_user_id": "3193012",
11
- "created_at": 1538722180,
12
- "updated_at": 1538722180,
13
- "office_mode": false,
14
- "share_url": null,
15
- "share_qr_code_url": null,
16
- "members": [
17
- {
18
- "user_id": "3193012",
19
- "nickname": "Test Account",
20
- "image_url": null,
21
- "id": "384076097",
22
- "muted": false,
23
- "autokicked": false,
24
- "roles": [
25
- "admin",
26
- "owner"
27
- ],
28
- "name": "Test Account"
29
- }
30
- ],
31
- "messages": {
32
- "count": 0,
33
- "last_message_id": "",
34
- "last_message_created_at": 0,
35
- "preview": {
36
- "nickname": null,
37
- "text": null,
38
- "image_url": null,
39
- "attachments": []
40
- }
41
- },
42
- "max_members": 500
43
- },
44
- {
45
- "id": "44835934",
46
- "group_id": "44835934",
47
- "name": "MCU Discussion Group",
48
- "phone_number": "+1 5307275175",
49
- "type": "private",
50
- "description": "",
51
- "image_url": null,
52
- "creator_user_id": "3193012",
53
- "created_at": 1538722180,
54
- "updated_at": 1538722180,
55
- "office_mode": false,
56
- "share_url": null,
57
- "share_qr_code_url": null,
58
- "members": [
59
- {
60
- "user_id": "3193012",
61
- "nickname": "Test Account",
62
- "image_url": null,
63
- "id": "384076096",
64
- "muted": false,
65
- "autokicked": false,
66
- "roles": [
67
- "admin",
68
- "owner"
69
- ],
70
- "name": "Test Account"
71
- }
72
- ],
73
- "messages": {
74
- "count": 0,
75
- "last_message_id": "",
76
- "last_message_created_at": 0,
77
- "preview": {
78
- "nickname": null,
79
- "text": null,
80
- "image_url": null,
81
- "attachments": []
82
- }
83
- },
84
- "max_members": 500
85
- },
86
- {
87
- "id": "44835933",
88
- "group_id": "44835933",
89
- "name": "Game of Thrones Discussion Group",
90
- "phone_number": "+1 3163134571",
91
- "type": "private",
92
- "description": "",
93
- "image_url": null,
94
- "creator_user_id": "3193012",
95
- "created_at": 1538722180,
96
- "updated_at": 1538722180,
97
- "office_mode": false,
98
- "share_url": null,
99
- "share_qr_code_url": null,
100
- "members": [
101
- {
102
- "user_id": "3193012",
103
- "nickname": "Test Account",
104
- "image_url": null,
105
- "id": "384076095",
106
- "muted": false,
107
- "autokicked": false,
108
- "roles": [
109
- "admin",
110
- "owner"
111
- ],
112
- "name": "Test Account"
113
- }
114
- ],
115
- "messages": {
116
- "count": 0,
117
- "last_message_id": "",
118
- "last_message_created_at": 0,
119
- "preview": {
120
- "nickname": null,
121
- "text": null,
122
- "image_url": null,
123
- "attachments": []
124
- }
125
- },
126
- "max_members": 500
127
- },
128
- {
129
- "id": "44835932",
130
- "group_id": "44835932",
131
- "name": "Investing Friends",
132
- "phone_number": "+1 8189004848",
133
- "type": "private",
134
- "description": "",
135
- "image_url": null,
136
- "creator_user_id": "3193012",
137
- "created_at": 1538722180,
138
- "updated_at": 1538722180,
139
- "office_mode": false,
140
- "share_url": null,
141
- "share_qr_code_url": null,
142
- "members": [
143
- {
144
- "user_id": "3193012",
145
- "nickname": "Test Account",
146
- "image_url": null,
147
- "id": "384076094",
148
- "muted": false,
149
- "autokicked": false,
150
- "roles": [
151
- "admin",
152
- "owner"
153
- ],
154
- "name": "Test Account"
155
- }
156
- ],
157
- "messages": {
158
- "count": 0,
159
- "last_message_id": "",
160
- "last_message_created_at": 0,
161
- "preview": {
162
- "nickname": null,
163
- "text": null,
164
- "image_url": null,
165
- "attachments": []
166
- }
167
- },
168
- "max_members": 500
169
- },
170
- {
171
- "id": "44835928",
172
- "group_id": "44835928",
173
- "name": "Old Work Friends",
174
- "phone_number": "+1 3479791179",
175
- "type": "private",
176
- "description": "",
177
- "image_url": null,
178
- "creator_user_id": "3193012",
179
- "created_at": 1538722107,
180
- "updated_at": 1538722107,
181
- "office_mode": false,
182
- "share_url": null,
183
- "share_qr_code_url": null,
184
- "members": [
185
- {
186
- "user_id": "3193012",
187
- "nickname": "Test Account",
188
- "image_url": null,
189
- "id": "384076023",
190
- "muted": false,
191
- "autokicked": false,
192
- "roles": [
193
- "admin",
194
- "owner"
195
- ],
196
- "name": "Test Account"
197
- }
198
- ],
199
- "messages": {
200
- "count": 0,
201
- "last_message_id": "",
202
- "last_message_created_at": 0,
203
- "preview": {
204
- "nickname": null,
205
- "text": null,
206
- "image_url": null,
207
- "attachments": []
208
- }
209
- },
210
- "max_members": 500
211
- },
212
- {
213
- "id": "44835927",
214
- "group_id": "44835927",
215
- "name": "Co-Workers",
216
- "phone_number": "+1 6097362013",
217
- "type": "private",
218
- "description": "",
219
- "image_url": null,
220
- "creator_user_id": "3193012",
221
- "created_at": 1538722106,
222
- "updated_at": 1538722106,
223
- "office_mode": false,
224
- "share_url": null,
225
- "share_qr_code_url": null,
226
- "members": [
227
- {
228
- "user_id": "3193012",
229
- "nickname": "Test Account",
230
- "image_url": null,
231
- "id": "384076022",
232
- "muted": false,
233
- "autokicked": false,
234
- "roles": [
235
- "admin",
236
- "owner"
237
- ],
238
- "name": "Test Account"
239
- }
240
- ],
241
- "messages": {
242
- "count": 0,
243
- "last_message_id": "",
244
- "last_message_created_at": 0,
245
- "preview": {
246
- "nickname": null,
247
- "text": null,
248
- "image_url": null,
249
- "attachments": []
250
- }
251
- },
252
- "max_members": 500
253
- },
254
- {
255
- "id": "44835926",
256
- "group_id": "44835926",
257
- "name": "Vacation Trip Planning",
258
- "phone_number": "+1 6787458749",
259
- "type": "private",
260
- "description": "",
261
- "image_url": null,
262
- "creator_user_id": "3193012",
263
- "created_at": 1538722106,
264
- "updated_at": 1538722106,
265
- "office_mode": false,
266
- "share_url": null,
267
- "share_qr_code_url": null,
268
- "members": [
269
- {
270
- "user_id": "3193012",
271
- "nickname": "Test Account",
272
- "image_url": null,
273
- "id": "384076021",
274
- "muted": false,
275
- "autokicked": false,
276
- "roles": [
277
- "admin",
278
- "owner"
279
- ],
280
- "name": "Test Account"
281
- }
282
- ],
283
- "messages": {
284
- "count": 0,
285
- "last_message_id": "",
286
- "last_message_created_at": 0,
287
- "preview": {
288
- "nickname": null,
289
- "text": null,
290
- "image_url": null,
291
- "attachments": []
292
- }
293
- },
294
- "max_members": 500
295
- },
296
- {
297
- "id": "44835925",
298
- "group_id": "44835925",
299
- "name": "Siblings",
300
- "phone_number": "+1 2406000247",
301
- "type": "private",
302
- "description": "",
303
- "image_url": null,
304
- "creator_user_id": "3193012",
305
- "created_at": 1538722106,
306
- "updated_at": 1538722106,
307
- "office_mode": false,
308
- "share_url": null,
309
- "share_qr_code_url": null,
310
- "members": [
311
- {
312
- "user_id": "3193012",
313
- "nickname": "Test Account",
314
- "image_url": null,
315
- "id": "384076020",
316
- "muted": false,
317
- "autokicked": false,
318
- "roles": [
319
- "admin",
320
- "owner"
321
- ],
322
- "name": "Test Account"
323
- }
324
- ],
325
- "messages": {
326
- "count": 0,
327
- "last_message_id": "",
328
- "last_message_created_at": 0,
329
- "preview": {
330
- "nickname": null,
331
- "text": null,
332
- "image_url": null,
333
- "attachments": []
334
- }
335
- },
336
- "max_members": 500
337
- },
338
- {
339
- "id": "44835924",
340
- "group_id": "44835924",
341
- "name": "Extended Family",
342
- "phone_number": "+1 6624506524",
343
- "type": "private",
344
- "description": "",
345
- "image_url": null,
346
- "creator_user_id": "3193012",
347
- "created_at": 1538722106,
348
- "updated_at": 1538722106,
349
- "office_mode": false,
350
- "share_url": null,
351
- "share_qr_code_url": null,
352
- "members": [
353
- {
354
- "user_id": "3193012",
355
- "nickname": "Test Account",
356
- "image_url": null,
357
- "id": "384076019",
358
- "muted": false,
359
- "autokicked": false,
360
- "roles": [
361
- "admin",
362
- "owner"
363
- ],
364
- "name": "Test Account"
365
- }
366
- ],
367
- "messages": {
368
- "count": 0,
369
- "last_message_id": "",
370
- "last_message_created_at": 0,
371
- "preview": {
372
- "nickname": null,
373
- "text": null,
374
- "image_url": null,
375
- "attachments": []
376
- }
377
- },
378
- "max_members": 500
379
- },
380
- {
381
- "id": "44835923",
382
- "group_id": "44835923",
383
- "name": "Family",
384
- "phone_number": "+1 6789207432",
385
- "type": "private",
386
- "description": "",
387
- "image_url": null,
388
- "creator_user_id": "3193012",
389
- "created_at": 1538722106,
390
- "updated_at": 1538722106,
391
- "office_mode": false,
392
- "share_url": null,
393
- "share_qr_code_url": null,
394
- "members": [
395
- {
396
- "user_id": "3193012",
397
- "nickname": "Test Account",
398
- "image_url": null,
399
- "id": "384076018",
400
- "muted": false,
401
- "autokicked": false,
402
- "roles": [
403
- "admin",
404
- "owner"
405
- ],
406
- "name": "Test Account"
407
- }
408
- ],
409
- "messages": {
410
- "count": 0,
411
- "last_message_id": "",
412
- "last_message_created_at": 0,
413
- "preview": {
414
- "nickname": null,
415
- "text": null,
416
- "image_url": null,
417
- "attachments": []
418
- }
419
- },
420
- "max_members": 500
421
- },
422
- {
423
- "id": "44835922",
424
- "group_id": "44835922",
425
- "name": "Ski Team",
426
- "phone_number": "+1 5617679511",
427
- "type": "private",
428
- "description": "",
429
- "image_url": null,
430
- "creator_user_id": "3193012",
431
- "created_at": 1538722106,
432
- "updated_at": 1538722106,
433
- "office_mode": false,
434
- "share_url": null,
435
- "share_qr_code_url": null,
436
- "members": [
437
- {
438
- "user_id": "3193012",
439
- "nickname": "Test Account",
440
- "image_url": null,
441
- "id": "384076017",
442
- "muted": false,
443
- "autokicked": false,
444
- "roles": [
445
- "admin",
446
- "owner"
447
- ],
448
- "name": "Test Account"
449
- }
450
- ],
451
- "messages": {
452
- "count": 0,
453
- "last_message_id": "",
454
- "last_message_created_at": 0,
455
- "preview": {
456
- "nickname": null,
457
- "text": null,
458
- "image_url": null,
459
- "attachments": []
460
- }
461
- },
462
- "max_members": 500
463
- },
464
- {
465
- "id": "44835921",
466
- "group_id": "44835921",
467
- "name": "Dance Team",
468
- "phone_number": "+1 3142005157",
469
- "type": "private",
470
- "description": "",
471
- "image_url": null,
472
- "creator_user_id": "3193012",
473
- "created_at": 1538722106,
474
- "updated_at": 1538722106,
475
- "office_mode": false,
476
- "share_url": null,
477
- "share_qr_code_url": null,
478
- "members": [
479
- {
480
- "user_id": "3193012",
481
- "nickname": "Test Account",
482
- "image_url": null,
483
- "id": "384076015",
484
- "muted": false,
485
- "autokicked": false,
486
- "roles": [
487
- "admin",
488
- "owner"
489
- ],
490
- "name": "Test Account"
491
- }
492
- ],
493
- "messages": {
494
- "count": 0,
495
- "last_message_id": "",
496
- "last_message_created_at": 0,
497
- "preview": {
498
- "nickname": null,
499
- "text": null,
500
- "image_url": null,
501
- "attachments": []
502
- }
503
- },
504
- "max_members": 500
505
- },
506
- {
507
- "id": "44835920",
508
- "group_id": "44835920",
509
- "name": "College Friends",
510
- "phone_number": "+1 8593635201",
511
- "type": "private",
512
- "description": "",
513
- "image_url": null,
514
- "creator_user_id": "3193012",
515
- "created_at": 1538722105,
516
- "updated_at": 1538722105,
517
- "office_mode": false,
518
- "share_url": null,
519
- "share_qr_code_url": null,
520
- "members": [
521
- {
522
- "user_id": "3193012",
523
- "nickname": "Test Account",
524
- "image_url": null,
525
- "id": "384076014",
526
- "muted": false,
527
- "autokicked": false,
528
- "roles": [
529
- "admin",
530
- "owner"
531
- ],
532
- "name": "Test Account"
533
- }
534
- ],
535
- "messages": {
536
- "count": 0,
537
- "last_message_id": "",
538
- "last_message_created_at": 0,
539
- "preview": {
540
- "nickname": null,
541
- "text": null,
542
- "image_url": null,
543
- "attachments": []
544
- }
545
- },
546
- "max_members": 500
547
- },
548
- {
549
- "id": "44835902",
550
- "group_id": "44835902",
551
- "name": "High School Friends",
552
- "phone_number": "+1 6193780416",
553
- "type": "private",
554
- "description": "",
555
- "image_url": null,
556
- "creator_user_id": "3193012",
557
- "created_at": 1538721837,
558
- "updated_at": 1538721967,
559
- "office_mode": false,
560
- "share_url": null,
561
- "share_qr_code_url": null,
562
- "members": [
563
- {
564
- "user_id": "3193012",
565
- "nickname": "Test Account",
566
- "image_url": null,
567
- "id": "384075821",
568
- "muted": false,
569
- "autokicked": false,
570
- "roles": [
571
- "admin",
572
- "owner"
573
- ],
574
- "name": "Test Account"
575
- }
576
- ],
577
- "messages": {
578
- "count": 1,
579
- "last_message_id": "153872196794737967",
580
- "last_message_created_at": 0,
581
- "preview": {
582
- "nickname": null,
583
- "text": null,
584
- "image_url": null,
585
- "attachments": []
586
- }
587
- },
588
- "max_members": 500
589
- },
590
- {
591
- "id": "44656909",
592
- "group_id": "44656909",
593
- "name": "Middle School Friends",
594
- "phone_number": "+1 6466993313",
595
- "type": "private",
596
- "description": "",
597
- "image_url": null,
598
- "creator_user_id": "3193012",
599
- "created_at": 1538345615,
600
- "updated_at": 1538721948,
601
- "office_mode": false,
602
- "share_url": null,
603
- "share_qr_code_url": null,
604
- "members": [
605
- {
606
- "user_id": "3193012",
607
- "nickname": "Test Account",
608
- "image_url": null,
609
- "id": "382143186",
610
- "muted": false,
611
- "autokicked": false,
612
- "roles": [
613
- "admin",
614
- "owner"
615
- ],
616
- "name": "Test Account"
617
- }
618
- ],
619
- "messages": {
620
- "count": 1,
621
- "last_message_id": "153872194802356734",
622
- "last_message_created_at": 0,
623
- "preview": {
624
- "nickname": null,
625
- "text": null,
626
- "image_url": null,
627
- "attachments": []
628
- }
629
- },
630
- "max_members": 500
631
- },
632
- {
633
- "id": "44009567",
634
- "group_id": "44009567",
635
- "name": "Elementary School Friends",
636
- "phone_number": "+1 2253699141",
637
- "type": "private",
638
- "description": "",
639
- "image_url": null,
640
- "creator_user_id": "3193012",
641
- "created_at": 1536824233,
642
- "updated_at": 1538721957,
643
- "office_mode": false,
644
- "share_url": null,
645
- "share_qr_code_url": null,
646
- "members": [
647
- {
648
- "user_id": "3193012",
649
- "nickname": "Test Account",
650
- "image_url": null,
651
- "id": "375093397",
652
- "muted": false,
653
- "autokicked": false,
654
- "roles": [
655
- "admin",
656
- "owner"
657
- ],
658
- "name": "Test Account"
659
- }
660
- ],
661
- "messages": {
662
- "count": 2,
663
- "last_message_id": "153872195719533320",
664
- "last_message_created_at": 0,
665
- "preview": {
666
- "nickname": null,
667
- "text": null,
668
- "image_url": null,
669
- "attachments": []
670
- }
671
- },
672
- "max_members": 500
673
- }
674
- ]