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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d93a43e42aa41cd106662b712006e9414180f4473c11355f392455d9fd5a602e
4
- data.tar.gz: 819e32e30b8d6dee811b991780bc6c72442f38c9e50404caae79e97bf5eccddc
3
+ metadata.gz: af5f49ac85bfdd9a94c8f8777524c3e159d35ee8be41d2671ef1f52144e61285
4
+ data.tar.gz: 7c13764379479a00cf063db817f13d6e1d9c0f737aee1cbe8aa7c2d986084ddf
5
5
  SHA512:
6
- metadata.gz: a895ad43282042215bab64affaed6f67fbc510b835cbd985a9fc79248020471e3034552ba0a293e78bd1ba9cfb664e0b9bcc3100cc40600e0229e1bd1cb51937
7
- data.tar.gz: 54d51f59a3f22e5ed97f75a1b04472ca22be264aab0ea44010ccf7d6fc303705759f1f19a89efc2c294eb5f3c5cf02d9aed52d811fea5d24bce2c4b2c49c32b9
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
- if result.is_a?(Result::Success)
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 < Basic
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
@@ -2,8 +2,11 @@
2
2
 
3
3
  module Talkbird
4
4
  module Result
5
- class Failure < Basic
5
+ # Encapsulates a response from the API which should be considered a failed
6
+ # request.
7
+ class Failure
6
8
 
9
+ attr_reader :body
7
10
  attr_reader :result
8
11
 
9
12
  def initialize(result)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Talkbird
4
4
 
5
- VERSION = '0.0.3'
5
+ VERSION = '0.0.4'
6
6
 
7
7
  end
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.3
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-04 00:00:00.000000000 Z
11
+ date: 2019-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport