rbchannels 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rbchannels.rb +100 -0
- data/lib/rbchannels/version.rb +3 -0
- data/test/test_channels.rb +11 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08d0c261b21933a1d7b686c91f85add22cea52ac'
|
4
|
+
data.tar.gz: 85a1d2df27029d33a849ce76a55d61653ca8df76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bed0ca00b4238efc83e8e2a71b495e7f126cbed69d8cc49f3cb3db4d119f17161d5d4eb8e4ce1fe2c67d46d2d6d56dcc54ee78dc17db4bfef489373e446f825b
|
7
|
+
data.tar.gz: ab311b0a8451715a6cff4f65916e5d8abbe60cc272d1e7089b7a0e737999f55130ec636fce73acc664d725acb33c3dcffce6961fdedf96f1554676cd24f49bdb
|
data/lib/rbchannels.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'rbchannels/version'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
class Channels::Client
|
5
|
+
include HTTParty
|
6
|
+
default_timeout 2
|
7
|
+
format :json
|
8
|
+
|
9
|
+
def initialize(host, port=57000)
|
10
|
+
self.class.base_uri "http://#{host}:#{port}/api"
|
11
|
+
end
|
12
|
+
|
13
|
+
def status
|
14
|
+
request("GET", "/status")
|
15
|
+
end
|
16
|
+
|
17
|
+
def favorite_channels
|
18
|
+
request("GET", "/favorite_channels")
|
19
|
+
if response.is_a?(Array)
|
20
|
+
response
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def pause
|
27
|
+
command('pause')
|
28
|
+
end
|
29
|
+
|
30
|
+
def resume
|
31
|
+
command('resume')
|
32
|
+
end
|
33
|
+
|
34
|
+
def stop
|
35
|
+
command('stop')
|
36
|
+
end
|
37
|
+
|
38
|
+
def seek(seconds=0)
|
39
|
+
command("seek/#{seconds}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def seek_forward
|
43
|
+
command('seek_forward')
|
44
|
+
end
|
45
|
+
|
46
|
+
def seek_backward
|
47
|
+
command('seek_backward')
|
48
|
+
end
|
49
|
+
|
50
|
+
def skip_forward
|
51
|
+
command('skip_forward')
|
52
|
+
end
|
53
|
+
|
54
|
+
def skip_backward
|
55
|
+
command('skip_backward')
|
56
|
+
end
|
57
|
+
|
58
|
+
def toggle_mute
|
59
|
+
command('toggle_mute')
|
60
|
+
end
|
61
|
+
|
62
|
+
def play_channel(channel_number)
|
63
|
+
command("play/channel/#{channel_number}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def play_recording(recording_id)
|
67
|
+
command("play/recording/#{recording_id}")
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def request(method, path)
|
74
|
+
begin
|
75
|
+
case method
|
76
|
+
when "GET"
|
77
|
+
response = self.class.get(path)
|
78
|
+
when "POST"
|
79
|
+
response = self.class.post(path)
|
80
|
+
when "PUT"
|
81
|
+
response = self.class.put(path)
|
82
|
+
when "DELETE"
|
83
|
+
response = self.class.delete(path)
|
84
|
+
end
|
85
|
+
|
86
|
+
if response
|
87
|
+
response.parsed_response
|
88
|
+
else
|
89
|
+
{'status': 'error'}
|
90
|
+
end
|
91
|
+
rescue
|
92
|
+
{'status': 'error'}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def command(named_command)
|
97
|
+
return request('POST', '/' + named_command)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbchannels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Maddox
|
@@ -29,7 +29,10 @@ email: jon@getchannels.com
|
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
|
-
files:
|
32
|
+
files:
|
33
|
+
- lib/rbchannels.rb
|
34
|
+
- lib/rbchannels/version.rb
|
35
|
+
- test/test_channels.rb
|
33
36
|
homepage: https://github.com/fancybits/rbchannels
|
34
37
|
licenses:
|
35
38
|
- MIT
|
@@ -54,4 +57,5 @@ rubygems_version: 2.6.13
|
|
54
57
|
signing_key:
|
55
58
|
specification_version: 4
|
56
59
|
summary: API client for the Channels app - https://getchannels.com
|
57
|
-
test_files:
|
60
|
+
test_files:
|
61
|
+
- test/test_channels.rb
|