xstreamly 0.6.2 → 0.6.3

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.
Files changed (2) hide show
  1. data/lib/xstreamly.rb +26 -23
  2. metadata +3 -3
data/lib/xstreamly.rb CHANGED
@@ -7,27 +7,27 @@ require 'net/http'
7
7
 
8
8
  module XStreamly
9
9
  class Client
10
- def initialize(appKey,email,password)
11
- @appKey = appKey
12
- @email = email
13
- @password = password
14
- @http = Net::HTTP.new('secure.x-stream.ly', 443)
15
- @http.use_ssl = true
16
-
17
- end
10
+ def initialize(appKey,email,password)
11
+ @appKey = appKey
12
+ @email = email
13
+ @password = password
14
+ @http = Net::HTTP.new('secure.x-stream.ly', 443)
15
+ @http.use_ssl = true
16
+ end
18
17
 
19
- def send(channel, eventName, data)
20
- req = Net::HTTP::Post.new(URI.encode('/api/v1.0/'+@appKey+'/channels/'+channel+'/events/'+eventName), initheader = {'Content-Type' =>'application/json'})
21
- req.basic_auth @email, @password
18
+ def send(channel, eventName, data)
19
+ req = Net::HTTP::Post.new(URI.encode('/api/v1.0/'+@appKey+'/channels/'+channel+'/events/'+eventName), initheader = {'Content-Type' =>'application/json'})
20
+ req.basic_auth @email, @password
22
21
 
23
- req.body = data
24
- response = @http.request(req)
25
- case response.code.to_i
26
- when 202
22
+ req.body = data
23
+ response = @http.request(req)
24
+ result = response.code.to_i
25
+ case result
26
+ when 200..299
27
27
  return true
28
28
  else
29
- raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
30
- end
29
+ raise RuntimeError, "Unknown error (status code #{result}): #{response.body}"
30
+ end
31
31
  end
32
32
 
33
33
  def setCallback(channel,endPoint,secret,eventName)
@@ -38,7 +38,7 @@ module XStreamly
38
38
  response = @http.request(req)
39
39
 
40
40
  case response.code.to_i
41
- when 200
41
+ when 200..299
42
42
  return true
43
43
  else
44
44
  raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
@@ -51,7 +51,7 @@ module XStreamly
51
51
  response = @http.request(req)
52
52
 
53
53
  case response.code.to_i
54
- when 202
54
+ when 200..299
55
55
  return true
56
56
  else
57
57
  raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
@@ -64,7 +64,7 @@ module XStreamly
64
64
  response = @http.request(req)
65
65
 
66
66
  case response.code.to_i
67
- when 200
67
+ when 200..299
68
68
  return (JSON(response.body))['items']
69
69
  else
70
70
  raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
@@ -79,7 +79,7 @@ module XStreamly
79
79
  response = @http.request(req)
80
80
 
81
81
  case response.code.to_i
82
- when 202
82
+ when 200..299
83
83
  return true
84
84
  else
85
85
  raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
@@ -122,7 +122,7 @@ module XStreamly
122
122
  response = @http.request(req)
123
123
 
124
124
  case response.code.to_i
125
- when 202
125
+ when 200..299
126
126
  return true
127
127
  else
128
128
  raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
@@ -135,7 +135,7 @@ module XStreamly
135
135
  response = @http.request(req)
136
136
 
137
137
  case response.code.to_i
138
- when 200
138
+ when 200..299
139
139
  return (JSON(response.body))['items']
140
140
  else
141
141
  raise RuntimeError, "Unknown error (status code #{response.code} ): #{response.body}"
@@ -144,3 +144,6 @@ module XStreamly
144
144
 
145
145
  end
146
146
  end
147
+
148
+ client = XStreamly::Client.new('10bc1643-c9f5-4210-9814-cae3203af316','bwillard@x-stream.ly','dcba4321');
149
+ client.setCallback('frank','http://127.0.0.1:3002','secret','event');
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xstreamly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Willard