groupme 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +3 -2
- data/groupme.gemspec +2 -3
- data/lib/groupme.rb +1 -1
- data/lib/groupme/bots.rb +1 -1
- data/lib/groupme/client.rb +4 -4
- data/lib/groupme/groups.rb +3 -3
- data/lib/groupme/messages.rb +33 -4
- data/lib/groupme/version.rb +1 -1
- data/spec/groupme/messages_spec.rb +3 -10
- data/spec/spec_helper.rb +1 -2
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bafcaeb016ef037170f43fda32b853bed245c110
|
4
|
+
data.tar.gz: efb6d55971014bc124440f97eebab2d2d90a0485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d449e05ae02a1cd20cff7efab595b140e10a1ed223c5b27953d9d7cab28c588e4894a606b351691b1fef31999ca903159ca2403978f9bfb404f6c8eb3a3bb29
|
7
|
+
data.tar.gz: 17a4040f1de23972ea45fcae450ea5fe6f8e39edbf9d5be750db62d0963634ff0ccd8405312a0782d2d79f143284f2d90fcc16e6faf13174c6afe81c50f20215
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/groupme.gemspec
CHANGED
@@ -20,12 +20,11 @@ Gem::Specification.new do |gem|
|
|
20
20
|
|
21
21
|
gem.add_development_dependency 'rake'
|
22
22
|
gem.add_development_dependency 'rspec', '~> 3.0'
|
23
|
-
gem.add_development_dependency 'webmock', '~> 1.
|
23
|
+
gem.add_development_dependency 'webmock', '~> 1.21.0'
|
24
24
|
gem.add_development_dependency 'yard'
|
25
25
|
gem.add_development_dependency 'pry'
|
26
26
|
gem.add_development_dependency 'json', '~> 1.7'
|
27
|
-
gem.add_development_dependency '
|
28
|
-
gem.add_development_dependency 'rubocop', '~> 0.33'
|
27
|
+
gem.add_development_dependency 'rubocop', '~> 0.36.0'
|
29
28
|
|
30
29
|
gem.add_dependency 'faraday', '~> 0.9.0'
|
31
30
|
gem.add_dependency 'faraday_middleware', '~> 0.9.0'
|
data/lib/groupme.rb
CHANGED
data/lib/groupme/bots.rb
CHANGED
data/lib/groupme/client.rb
CHANGED
@@ -22,8 +22,8 @@ module GroupMe
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def get(path)
|
26
|
-
request(:get, path)
|
25
|
+
def get(path, options = {})
|
26
|
+
request(:get, path, options)
|
27
27
|
end
|
28
28
|
|
29
29
|
def post(path, data = {})
|
@@ -33,9 +33,9 @@ module GroupMe
|
|
33
33
|
def request(method, path, data = {})
|
34
34
|
res = connection.send(method, "v3/#{path}", data)
|
35
35
|
if res.success? && !res.body.empty? && res.body != ' '
|
36
|
-
|
36
|
+
res.body.response
|
37
37
|
else
|
38
|
-
|
38
|
+
res
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
data/lib/groupme/groups.rb
CHANGED
@@ -10,7 +10,7 @@ module GroupMe
|
|
10
10
|
def groups
|
11
11
|
get '/groups'
|
12
12
|
end
|
13
|
-
|
13
|
+
alias list_groups groups
|
14
14
|
|
15
15
|
# Load a specific group.
|
16
16
|
#
|
@@ -34,7 +34,7 @@ module GroupMe
|
|
34
34
|
def former_groups
|
35
35
|
get '/groups/former'
|
36
36
|
end
|
37
|
-
|
37
|
+
alias list_former_groups former_groups
|
38
38
|
|
39
39
|
# Create a new group.
|
40
40
|
#
|
@@ -46,7 +46,7 @@ module GroupMe
|
|
46
46
|
# @option options [String] :image_url GroupMe Image Service URL
|
47
47
|
# @option options [Boolean] :share If you pass a true value, a share URL will be generated
|
48
48
|
def create_group(name, options = {})
|
49
|
-
options
|
49
|
+
options[:name] = name
|
50
50
|
post '/groups', options
|
51
51
|
end
|
52
52
|
|
data/lib/groupme/messages.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
module GroupMe
|
2
4
|
module Messages
|
3
5
|
# Create a message for a group
|
@@ -10,7 +12,7 @@ module GroupMe
|
|
10
12
|
def create_message(group_id, text, attachments = [])
|
11
13
|
data = {
|
12
14
|
:message => {
|
13
|
-
:source_guid =>
|
15
|
+
:source_guid => SecureRandom.uuid,
|
14
16
|
:text => text
|
15
17
|
}
|
16
18
|
}
|
@@ -23,8 +25,14 @@ module GroupMe
|
|
23
25
|
# @return [Array<Hashie::Mash>] Array of hashes representing the messages
|
24
26
|
# @see https://dev.groupme.com/docs/v3#messages_index
|
25
27
|
# @param group_id [String, Integer] Id of the group
|
26
|
-
|
27
|
-
|
28
|
+
# @param options [Hash] options hash that will be passed to the groupme call
|
29
|
+
# @param fetch_all [Boolean] if true, fetches all messages for the group
|
30
|
+
def messages(group_id, options = {}, fetch_all = false)
|
31
|
+
if fetch_all
|
32
|
+
get_all_messages(group_id)
|
33
|
+
else
|
34
|
+
get_messages(group_id, options)
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
38
|
# Get number of messages for a group
|
@@ -34,6 +42,27 @@ module GroupMe
|
|
34
42
|
def messages_count(group_id)
|
35
43
|
get("/groups/#{group_id}/messages")['count']
|
36
44
|
end
|
37
|
-
|
45
|
+
alias message_count messages_count
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def get_all_messages(group_id)
|
50
|
+
messages = []
|
51
|
+
last_id = ''
|
52
|
+
loop do
|
53
|
+
selection = get_messages(group_id, :before_id => last_id)
|
54
|
+
break if selection.empty?
|
55
|
+
|
56
|
+
last_id = selection.last.id
|
57
|
+
messages << selection
|
58
|
+
end
|
59
|
+
|
60
|
+
messages
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_messages(group_id, options = {})
|
64
|
+
results = get("/groups/#{group_id}/messages", options)
|
65
|
+
results.is_a?(Faraday::Response) ? [] : results.messages
|
66
|
+
end
|
38
67
|
end
|
39
68
|
end
|
data/lib/groupme/version.rb
CHANGED
@@ -6,6 +6,7 @@ describe GroupMe::Messages do
|
|
6
6
|
|
7
7
|
before do
|
8
8
|
@client = GroupMe::Client.new(:token => 'TEST')
|
9
|
+
allow(SecureRandom).to receive(:uuid).and_return('GUID')
|
9
10
|
end
|
10
11
|
|
11
12
|
describe '.message_count' do
|
@@ -29,18 +30,10 @@ describe GroupMe::Messages do
|
|
29
30
|
|
30
31
|
describe '.create_message' do
|
31
32
|
|
32
|
-
before do
|
33
|
-
Timecop.freeze(Time.new(2014, 10, 25, 22, 33, 44, 0000))
|
34
|
-
end
|
35
|
-
|
36
|
-
after do
|
37
|
-
Timecop.return
|
38
|
-
end
|
39
|
-
|
40
33
|
it 'sends a text only message to a group' do
|
41
34
|
message = {
|
42
35
|
:message => {
|
43
|
-
:source_guid => '
|
36
|
+
:source_guid => 'GUID',
|
44
37
|
:text => 'Hello world ☃☃'
|
45
38
|
}
|
46
39
|
}
|
@@ -52,7 +45,7 @@ describe GroupMe::Messages do
|
|
52
45
|
it 'sends a message with location to a group' do
|
53
46
|
message = {
|
54
47
|
:message => {
|
55
|
-
:source_guid => '
|
48
|
+
:source_guid => 'GUID',
|
56
49
|
:text => 'Hello world ☃☃',
|
57
50
|
:attachments => [
|
58
51
|
{
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'groupme'
|
2
2
|
require 'multi_json'
|
3
3
|
require 'webmock/rspec'
|
4
|
-
require 'timecop'
|
5
4
|
|
6
5
|
def stub_get(url)
|
7
6
|
stub_request(:get, "https://api.groupme.com/v3#{url}")
|
@@ -28,7 +27,7 @@ def json_response(file, status = 200)
|
|
28
27
|
:code => status,
|
29
28
|
:errors => []
|
30
29
|
}
|
31
|
-
},
|
30
|
+
}.to_json,
|
32
31
|
:headers => {
|
33
32
|
:content_type => 'application/json; charset=utf-8'
|
34
33
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Radcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.21.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
|
-
version: 1.
|
54
|
+
version: 1.21.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,34 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.7'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: timecop
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.7'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.7'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: rubocop
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
103
|
+
version: 0.36.0
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
110
|
+
version: 0.36.0
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: faraday
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
245
|
version: '0'
|
260
246
|
requirements: []
|
261
247
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.
|
248
|
+
rubygems_version: 2.5.1
|
263
249
|
signing_key:
|
264
250
|
specification_version: 4
|
265
251
|
summary: Simple wrapper for the GroupMe v3 API
|