talkbird 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/talkbird/entity/channel.rb +5 -10
- data/lib/talkbird/entity/message.rb +18 -1
- data/lib/talkbird/entity/user.rb +2 -2
- data/lib/talkbird/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d19f0c6015b1e3ae92ec3f845fd9b7e95ce6a50edfc19d831e4e6d1be24f8ce
|
4
|
+
data.tar.gz: 5db2f957f25ea0c3be235f8a397cfc055ed7f8ec173a90c385f6d2670a735e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b22a45c0cd569e2b156ecab22477fad98183e0c81e2e398594b647a6f75a6b172bbeaa3b2b9d388e19a407ce1fe413afa01c1ee89603e709ec345fcd607798b
|
7
|
+
data.tar.gz: 71b52c8ea2d004e4b722f2eec558580baccaef2264a8b81b13568342e6e413829f41e593855f0803f15871ba8f4fc2eacc784cd3d167a6ebb635fcb346ad5380
|
@@ -31,11 +31,12 @@ module Talkbird
|
|
31
31
|
limit: 1
|
32
32
|
}
|
33
33
|
)
|
34
|
+
channels = result.body[:channels] || []
|
34
35
|
|
35
36
|
# Since this is the result of a search, the response can be an empty
|
36
37
|
# array, in which case the result should also be false.
|
37
|
-
if result.is_a?(Result::Success) && !
|
38
|
-
Channel.build(
|
38
|
+
if result.is_a?(Result::Success) && !channels.empty?
|
39
|
+
Channel.build(channels.first)
|
39
40
|
else
|
40
41
|
false
|
41
42
|
end
|
@@ -90,21 +91,15 @@ module Talkbird
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def update(message)
|
93
|
-
body = {
|
94
|
-
user_id: message.sender.id,
|
95
|
-
message: message.body,
|
96
|
-
message_type: 'MESG',
|
97
|
-
}
|
98
|
-
|
99
94
|
Client.request(
|
100
95
|
:post,
|
101
96
|
"group_channels/#{id}/messages",
|
102
|
-
body:
|
97
|
+
body: message.to_h
|
103
98
|
)
|
104
99
|
end
|
105
100
|
|
106
101
|
def to_s
|
107
|
-
"#<Talkbird::Entity::Channel id=#{id} name
|
102
|
+
"#<Talkbird::Entity::Channel id=#{id} name=#{name} members=#{members}>"
|
108
103
|
end
|
109
104
|
|
110
105
|
end
|
@@ -9,6 +9,10 @@ module Talkbird
|
|
9
9
|
attr_reader :receiver
|
10
10
|
attr_reader :body
|
11
11
|
|
12
|
+
DEFAULTS = {
|
13
|
+
type: 'MESG'
|
14
|
+
}.freeze
|
15
|
+
|
12
16
|
class << self
|
13
17
|
|
14
18
|
def build(response)
|
@@ -17,10 +21,12 @@ module Talkbird
|
|
17
21
|
|
18
22
|
end
|
19
23
|
|
20
|
-
def initialize(from, to, body)
|
24
|
+
def initialize(from, to, body, options = {})
|
21
25
|
@sender = User.find_or_create(from)
|
22
26
|
@receiver = User.find_or_create(to)
|
23
27
|
@body = body
|
28
|
+
|
29
|
+
@options = options
|
24
30
|
end
|
25
31
|
|
26
32
|
def deliver
|
@@ -30,6 +36,17 @@ module Talkbird
|
|
30
36
|
channel.update(self)
|
31
37
|
end
|
32
38
|
|
39
|
+
def to_h
|
40
|
+
options.merge(
|
41
|
+
user_id: sender.id,
|
42
|
+
message: body
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def options
|
47
|
+
DEFAULTS.merge(@options)
|
48
|
+
end
|
49
|
+
|
33
50
|
end
|
34
51
|
end
|
35
52
|
end
|
data/lib/talkbird/entity/user.rb
CHANGED
@@ -151,8 +151,8 @@ module Talkbird
|
|
151
151
|
# @param text [String] The message body
|
152
152
|
#
|
153
153
|
# @return [Boolean]
|
154
|
-
def message(to, text)
|
155
|
-
Entity::Message.new(self, to, text).deliver
|
154
|
+
def message(to, text, opts = {})
|
155
|
+
Entity::Message.new(self, to, text, opts).deliver
|
156
156
|
end
|
157
157
|
|
158
158
|
def to_h
|
data/lib/talkbird/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talkbird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Maxim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|