talkbird 0.0.3 → 0.0.4
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 +10 -2
- data/lib/talkbird/result/exception.rb +7 -2
- data/lib/talkbird/result/failure.rb +4 -1
- 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: af5f49ac85bfdd9a94c8f8777524c3e159d35ee8be41d2671ef1f52144e61285
|
4
|
+
data.tar.gz: 7c13764379479a00cf063db817f13d6e1d9c0f737aee1cbe8aa7c2d986084ddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd87f26adaad2bcf56033bc85bbcdea36a5e0dc11e996bfe82afa0da5c37f2de36e991c5abd208cdbe566b2d3e40de6992409d5293beba17ed5ef6d6bb2c5a6f
|
7
|
+
data.tar.gz: aa142f491722c132186fe04a8bd30934558e62533722898ce3541e55fbd0934b03af5fd59f2b5e0e93683d6faa1f96ca435c4fe4813359611577fdcf44c16c80
|
@@ -13,6 +13,12 @@ module Talkbird
|
|
13
13
|
class << self
|
14
14
|
|
15
15
|
def find(from, to)
|
16
|
+
# The only way to find a conversation with another person is to search
|
17
|
+
# through all the conversations with some rather strict parameters
|
18
|
+
# and pick the best match.
|
19
|
+
#
|
20
|
+
# In this case, the order is based on the latest last message as it
|
21
|
+
# makes more sense to have the
|
16
22
|
result = Client.request(
|
17
23
|
:get,
|
18
24
|
"users/#{from}/my_group_channels",
|
@@ -26,7 +32,9 @@ module Talkbird
|
|
26
32
|
}
|
27
33
|
)
|
28
34
|
|
29
|
-
|
35
|
+
# Since this is the result of a search, the response can be an empty
|
36
|
+
# array, in which case the result should also be false.
|
37
|
+
if result.is_a?(Result::Success) && !result.body[:channels].empty?
|
30
38
|
Channel.build(result.body[:channels].first)
|
31
39
|
else
|
32
40
|
false
|
@@ -96,7 +104,7 @@ module Talkbird
|
|
96
104
|
end
|
97
105
|
|
98
106
|
def to_s
|
99
|
-
"#<Talkbird::Entity::Channel id=#{id}
|
107
|
+
"#<Talkbird::Entity::Channel id=#{id} name=#>"
|
100
108
|
end
|
101
109
|
|
102
110
|
end
|
@@ -3,11 +3,16 @@
|
|
3
3
|
module Talkbird
|
4
4
|
module Result
|
5
5
|
# Class representing a result as an exception.
|
6
|
-
class Exception
|
6
|
+
class Exception
|
7
|
+
|
8
|
+
attr_reader :body
|
9
|
+
attr_reader :result
|
10
|
+
attr_reader :exception
|
7
11
|
|
8
12
|
def initialize(exception, result)
|
9
|
-
@exception = exception
|
10
13
|
@result = result
|
14
|
+
@exception = exception
|
15
|
+
@body = { error: exception.message }
|
11
16
|
end
|
12
17
|
|
13
18
|
end
|
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.4
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|