talkbird 0.0.2 → 0.0.3

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: 978edc8d5c34ca0fe0fd8ff76d1777784d374ac57c06042c9fdafc57696acdfd
4
- data.tar.gz: c9689d6c654bbe36cc8b9c58185dbaf72657853c0bbbbdb51efab40677eac5d6
3
+ metadata.gz: d93a43e42aa41cd106662b712006e9414180f4473c11355f392455d9fd5a602e
4
+ data.tar.gz: 819e32e30b8d6dee811b991780bc6c72442f38c9e50404caae79e97bf5eccddc
5
5
  SHA512:
6
- metadata.gz: 84a9813b6be54f37fe91f8286d76682ae88371b0ca6ab583a975c4eb9a33d8f94fba91769abc4a4a4875475879fa467a9b297c89120e8048c40a38942caff949
7
- data.tar.gz: f93e25ae58c4616c8f6ba5a47683f72e85ac9d4cb5ccff389589ceac5f7ef4929d3b80ed7e6a9eb4ea5ec69cee8844f0ec8f880f5200c5cdba22423f6eee639c
6
+ metadata.gz: a895ad43282042215bab64affaed6f67fbc510b835cbd985a9fc79248020471e3034552ba0a293e78bd1ba9cfb664e0b9bcc3100cc40600e0229e1bd1cb51937
7
+ data.tar.gz: 54d51f59a3f22e5ed97f75a1b04472ca22be264aab0ea44010ccf7d6fc303705759f1f19a89efc2c294eb5f3c5cf02d9aed52d811fea5d24bce2c4b2c49c32b9
@@ -27,12 +27,19 @@ module Talkbird
27
27
  )
28
28
 
29
29
  if result.is_a?(Result::Success)
30
- Channel.new(result.body[:channels].first)
30
+ Channel.build(result.body[:channels].first)
31
31
  else
32
32
  false
33
33
  end
34
34
  end
35
35
 
36
+ # Build a channel based on the current payload.
37
+ #
38
+ # @return [Channel, Boolean]
39
+ def build(payload)
40
+ !payload.empty? && Channel.new(payload)
41
+ end
42
+
36
43
  def create(from, to, opts = {})
37
44
  body = DEFAULTS.merge(opts)
38
45
 
@@ -66,6 +73,14 @@ module Talkbird
66
73
  @data[:channel_url]
67
74
  end
68
75
 
76
+ def name
77
+ @data[:name]
78
+ end
79
+
80
+ def members
81
+ @data[:members].map { |hsh| Entity::User.new(hsh) }
82
+ end
83
+
69
84
  def update(message)
70
85
  body = {
71
86
  user_id: message.sender.id,
@@ -73,17 +88,15 @@ module Talkbird
73
88
  message_type: 'MESG',
74
89
  }
75
90
 
76
- result = Client.request(
91
+ Client.request(
77
92
  :post,
78
93
  "group_channels/#{id}/messages",
79
94
  body: body
80
95
  )
96
+ end
81
97
 
82
- if result.is_a?(Result::Success)
83
- Entity::Message.build(result.body)
84
- else
85
- false
86
- end
98
+ def to_s
99
+ "#<Talkbird::Entity::Channel id=#{id}>"
87
100
  end
88
101
 
89
102
  end
@@ -27,7 +27,6 @@ module Talkbird
27
27
  return false if !sender || !receiver
28
28
 
29
29
  channel = Entity::Channel.find_or_create(sender.id, receiver.id)
30
- puts channel.inspect
31
30
  channel.update(self)
32
31
  end
33
32
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Talkbird
4
4
 
5
- VERSION = '0.0.2'
5
+ VERSION = '0.0.3'
6
6
 
7
7
  end
data/talkbird.gemspec CHANGED
@@ -26,9 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ['lib']
28
28
 
29
- spec.add_dependency 'activesupport', '>= 5.0'
30
- spec.add_dependency 'multi_json', '~> 1.14'
31
- spec.add_dependency 'http', '~> 4.2'
29
+ spec.add_dependency 'activesupport'
30
+ spec.add_dependency 'multi_json'
31
+ spec.add_dependency 'http'
32
32
 
33
33
  spec.add_development_dependency 'bundler', '~> 1.17'
34
34
  spec.add_development_dependency 'pry', '~> 0.12.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talkbird
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Maxim
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: http
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.2'
47
+ version: '0'
48
48
  type: :runtime
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: '4.2'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement