stream-ruby 2.0.6 → 2.1.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/stream/client.rb +14 -4
- data/lib/stream/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38a1b1607ab0d444d3d58655a0dc2b5808a89fa4
|
4
|
+
data.tar.gz: a5e31bb866bc8f48ad01054d1f70045cf84d746b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5bfcff26cf14b563cf4017ebb6082b6c6cad08472b95b0a9c809bec15698d600a4b2727bff5a13d0e0c51d402ea2c420bd8350f296f86ea07c259261a5bdb7
|
7
|
+
data.tar.gz: 9cbfebfe0e27f2d80619eee4dcc907e6019312d6f778a6f76993224fc8d82e5ceffa53758c32d7c556b1b933e23615a029a091836c555ded0edcff95243bb128
|
data/lib/stream/client.rb
CHANGED
@@ -8,13 +8,13 @@ module Stream
|
|
8
8
|
STREAM_URL_RE = /https\:\/\/(?<key>\w+)\:(?<secret>\w+).*app_id=(?<app_id>\d+)/i
|
9
9
|
|
10
10
|
class Client
|
11
|
-
@@http_client = nil
|
12
11
|
attr_reader :api_key
|
13
12
|
attr_reader :api_secret
|
14
13
|
attr_reader :app_id
|
15
14
|
attr_reader :api_version
|
15
|
+
attr_reader :location
|
16
16
|
|
17
|
-
def initialize(api_key='', api_secret='', app_id=nil)
|
17
|
+
def initialize(api_key='', api_secret='', app_id=nil, opts={})
|
18
18
|
if ENV['STREAM_URL'] =~ Stream::STREAM_URL_RE and (api_key.nil? || api_key.empty?)
|
19
19
|
matches = Stream::STREAM_URL_RE.match(ENV['STREAM_URL'])
|
20
20
|
api_key = matches['key']
|
@@ -29,6 +29,8 @@ module Stream
|
|
29
29
|
@api_key = api_key
|
30
30
|
@api_secret = api_secret
|
31
31
|
@app_id = app_id
|
32
|
+
@location = opts[:location]
|
33
|
+
@api_version = opts.fetch(:api_version, 'v1.0')
|
32
34
|
@signer = Stream::Signer.new(api_secret)
|
33
35
|
end
|
34
36
|
|
@@ -42,7 +44,7 @@ module Stream
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def get_http_client
|
45
|
-
|
47
|
+
StreamHTTPClient.new(@api_version, @location)
|
46
48
|
end
|
47
49
|
|
48
50
|
def make_request(method, relative_url, signature, params=nil, data=nil)
|
@@ -59,9 +61,17 @@ module Stream
|
|
59
61
|
class StreamHTTPClient
|
60
62
|
|
61
63
|
include HTTParty
|
62
|
-
base_uri 'https://api.getstream.io/api/v1.0'
|
63
64
|
default_timeout 3
|
64
65
|
|
66
|
+
def initialize(api_version='v1.0', location=nil)
|
67
|
+
if location.nil?
|
68
|
+
location_name = "api"
|
69
|
+
else
|
70
|
+
location_name = "#{location}-api"
|
71
|
+
end
|
72
|
+
self.class.base_uri "https://#{location_name}.getstream.io/api/#{api_version}"
|
73
|
+
end
|
74
|
+
|
65
75
|
def make_http_request(method, relative_url, params=nil, data=nil, headers=nil)
|
66
76
|
headers['Content-Type'] = 'application/json'
|
67
77
|
headers['User-Agent'] = "stream-ruby-#{Stream::VERSION}"
|
data/lib/stream/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stream-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommaso Barbugli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|