stream-ruby 2.0.6 → 2.1.0

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
  SHA1:
3
- metadata.gz: 8757c05fed372cb56e4d9dcbf069a1b66b5694e9
4
- data.tar.gz: da8df5451cfa86a3262353c4489a1d9781180bb0
3
+ metadata.gz: 38a1b1607ab0d444d3d58655a0dc2b5808a89fa4
4
+ data.tar.gz: a5e31bb866bc8f48ad01054d1f70045cf84d746b
5
5
  SHA512:
6
- metadata.gz: 4b888ce839da9e422acdf519e8f15d6f246b5b5431ea4d778de0327818300d58c9c50a3fd073c439d3524df92e83ccb83c755bc8aef5f48d0c31682fee2557f5
7
- data.tar.gz: 3e0eb7eb9f1165ba071a16fa2d941616054e5f5c7985f5356d4be0bc6af2ce63dabf571f75aacb2e3a7a0e738421907ee1f0725cda1c7108da3d48017cbea538
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
- @@http_client ||= StreamHTTPClient.new
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}"
@@ -1,3 +1,3 @@
1
1
  module Stream
2
- VERSION = "2.0.6"
2
+ VERSION = "2.1.0"
3
3
  end
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.6
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-09 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty