stream-ruby 2.5.8 → 2.5.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c574df76ea568aae6df6bc23389620694877ef1
4
- data.tar.gz: 46424a58f936da6ea646d6c8e5ce4003761cec04
3
+ metadata.gz: 1a89b73bd4cda76d4266cf20ec867a3c96428b55
4
+ data.tar.gz: c80d98f021dfb1aab797a43bcf0f1b6484d36b0d
5
5
  SHA512:
6
- metadata.gz: 4db2fa01486a78daf5ea3574bee4c9bbfdc5345bd4a352731c82c80b2fc72d47fa46c04cffa511aa4a69347eba47ae1657024318f9a791a7ac13b79ec3a097b5
7
- data.tar.gz: 183ffd03c3ad120b3c5a20850f8b63994ba18c1d56c4f688ef7527fb8db3cc464391a72618cddc400408102403c356eda8344980e0233f155d19651ad3ba000f
6
+ metadata.gz: 32099413dc479ffccb0d4c21da3c4150ca3a0af4907f0333a661cff9eed5a7efb01abf351105d5d92cabac4f7ae9e83a18c96ea2361891f510dc2a5cc0e5451f
7
+ data.tar.gz: 3f6f59e178336340c907ffb5d00f400b6905448413ab20787b128ee2e760a1fe8531ffa700e3d35ad6b6540ee26fcd3d2ad46ca43ef17bdbd4afe9a16595914b
data/README.md CHANGED
@@ -9,15 +9,16 @@ Note there is also a higher level [Ruby on Rails - Stream integration](https://g
9
9
 
10
10
  You can sign up for a Stream account at https://getstream.io/get_started.
11
11
 
12
- ### Ruby Language Support
13
-
14
- We will support the following versions of Ruby:
12
+ #### Ruby version requirements and support
15
13
 
14
+ This API Client project requires Ruby 2.2.8 at a minimum. We will support the following versions:
16
15
  - 2.2.8
17
16
  - 2.3.1
18
17
  - 2.3.5
19
18
  - 2.4.2
20
19
 
20
+ See the [Travis configuration](.travis.yml) for details of how it is built and tested.
21
+
21
22
  ### Installation
22
23
 
23
24
  ```bash
data/lib/stream.rb CHANGED
@@ -1 +1 @@
1
- require "stream/base"
1
+ require 'stream/base'
data/lib/stream/base.rb CHANGED
@@ -1,8 +1,8 @@
1
- require "json"
2
- require "stream/client"
3
- require "stream/errors"
4
- require "stream/version"
5
- require "stream/signer"
1
+ require 'json'
2
+ require 'stream/client'
3
+ require 'stream/errors'
4
+ require 'stream/version'
5
+ require 'stream/signer'
6
6
 
7
7
  module Stream
8
8
  class << self
@@ -11,7 +11,7 @@ module Stream
11
11
  end
12
12
 
13
13
  def get_feed_slug_and_id(feed_id)
14
- feed_id.sub(":", "")
14
+ feed_id.sub(':', '')
15
15
  end
16
16
  end
17
17
  end
data/lib/stream/batch.rb CHANGED
@@ -19,9 +19,9 @@ module Stream
19
19
  def follow_many(follows, activity_copy_limit = nil)
20
20
  query_params = {}
21
21
  unless activity_copy_limit.nil?
22
- query_params["activity_copy_limit"] = activity_copy_limit
22
+ query_params['activity_copy_limit'] = activity_copy_limit
23
23
  end
24
- make_signed_request(:post, "/follow_many/", query_params, follows)
24
+ make_signed_request(:post, '/follow_many/', query_params, follows)
25
25
  end
26
26
 
27
27
  #
@@ -37,7 +37,7 @@ module Stream
37
37
  :feeds => feeds,
38
38
  :activity => activity_data
39
39
  }
40
- make_signed_request(:post, "/feed/add_to_many/", {}, data)
40
+ make_signed_request(:post, '/feed/add_to_many/', {}, data)
41
41
  end
42
42
  end
43
43
  end
data/lib/stream/client.rb CHANGED
@@ -1,10 +1,11 @@
1
- require "faraday"
2
- require "stream/errors"
3
- require "stream/feed"
4
- require "stream/signer"
1
+ require 'faraday'
2
+ require 'stream/errors'
3
+ require 'stream/feed'
4
+ require 'stream/signer'
5
5
 
6
6
  module Stream
7
- STREAM_URL_RE = %r{https\:\/\/(?<key>\w+)\:(?<secret>\w+)@((api\.)|((?<location>[-\w]+)\.))?getstream\.io\/[\w=-\?%&]+app_id=(?<app_id>\d+)}i
7
+ STREAM_URL_COM_RE = %r{https\:\/\/(?<key>\w+)\:(?<secret>\w+)@((api\.)|((?<location>[-\w]+)\.))?(?<api_hostname>stream-io-api\.com)\/[\w=-\?%&]+app_id=(?<app_id>\d+)}i
8
+ STREAM_URL_IO_RE = %r{https\:\/\/(?<key>\w+)\:(?<secret>\w+)@((api\.)|((?<location>[-\w]+)\.))?(?<api_hostname>getstream\.io)\/[\w=-\?%&]+app_id=(?<app_id>\d+)}i
8
9
 
9
10
  class Client
10
11
  attr_reader :api_key
@@ -13,8 +14,8 @@ module Stream
13
14
  attr_reader :client_options
14
15
 
15
16
  if RUBY_VERSION.to_f >= 2.1
16
- require "stream/batch"
17
- require "stream/signedrequest"
17
+ require 'stream/batch'
18
+ require 'stream/signedrequest'
18
19
 
19
20
  include Stream::SignedRequest
20
21
  include Stream::Batch
@@ -31,17 +32,25 @@ module Stream
31
32
  # @example initialise the client to connect to EU-West location
32
33
  # Stream::Client.new('my_key', 'my_secret', 'my_app_id', :location => 'us-east')
33
34
  #
34
- def initialize(api_key = "", api_secret = "", app_id = nil, opts = {})
35
- if ENV["STREAM_URL"] =~ Stream::STREAM_URL_RE && (api_key.nil? || api_key.empty?)
36
- matches = Stream::STREAM_URL_RE.match(ENV["STREAM_URL"])
37
- api_key = matches["key"]
38
- api_secret = matches["secret"]
39
- app_id = matches["app_id"]
40
- opts[:location] = matches["location"]
35
+ def initialize(api_key = '', api_secret = '', app_id = nil, opts = {})
36
+ if ENV['STREAM_URL'] =~ Stream::STREAM_URL_COM_RE && (api_key.nil? || api_key.empty?)
37
+ matches = Stream::STREAM_URL_COM_RE.match(ENV['STREAM_URL'])
38
+ api_key = matches['key']
39
+ api_secret = matches['secret']
40
+ app_id = matches['app_id']
41
+ opts[:location] = matches['location']
42
+ opts[:api_hostname] = matches['api_hostname']
43
+ elsif ENV['STREAM_URL'] =~ Stream::STREAM_URL_IO_RE && (api_key.nil? || api_key.empty?)
44
+ matches = Stream::STREAM_URL_IO_RE.match(ENV['STREAM_URL'])
45
+ api_key = matches['key']
46
+ api_secret = matches['secret']
47
+ app_id = matches['app_id']
48
+ opts[:location] = matches['location']
49
+ opts[:api_hostname] = matches['api_hostname']
41
50
  end
42
51
 
43
52
  if api_key.nil? || api_key.empty?
44
- raise ArgumentError, "empty api_key parameter and missing or invalid STREAM_URL env variable"
53
+ raise ArgumentError, 'empty api_key parameter and missing or invalid STREAM_URL env variable'
45
54
  end
46
55
 
47
56
  @api_key = api_key
@@ -50,10 +59,11 @@ module Stream
50
59
  @signer = Stream::Signer.new(api_secret)
51
60
 
52
61
  @client_options = {
53
- :api_version => opts.fetch(:api_version, "v1.0"),
54
- :location => opts.fetch(:location, nil),
55
- :default_timeout => opts.fetch(:default_timeout, 3),
56
- :api_key => @api_key
62
+ api_version: opts.fetch(:api_version, 'v1.0'),
63
+ location: opts.fetch(:location, nil),
64
+ default_timeout: opts.fetch(:default_timeout, 3),
65
+ api_key: @api_key,
66
+ api_hostname: opts.fetch(:api_hostname, 'stream-io-api.com')
57
67
  }
58
68
  end
59
69
 
@@ -74,12 +84,12 @@ module Stream
74
84
  end
75
85
 
76
86
  def update_activities(activities)
77
- auth_token = Stream::Signer.create_jwt_token("activities", "*", @api_secret, "*")
78
- make_request(:post, "/activities/", auth_token, {}, "activities" => activities)
87
+ auth_token = Stream::Signer.create_jwt_token('activities', '*', @api_secret, '*')
88
+ make_request(:post, '/activities/', auth_token, {}, 'activities' => activities)
79
89
  end
80
90
 
81
91
  def get_default_params
82
- { :api_key => @api_key }
92
+ {:api_key => @api_key}
83
93
  end
84
94
 
85
95
  def get_http_client
@@ -87,19 +97,19 @@ module Stream
87
97
  end
88
98
 
89
99
  def make_query_params(params)
90
- Hash[get_default_params.merge(params).sort_by { |k, v| k.to_s }]
100
+ Hash[get_default_params.merge(params).sort_by {|k, v| k.to_s}]
91
101
  end
92
102
 
93
103
  def make_request(method, relative_url, signature, params = {}, data = {}, headers = {})
94
- headers["Authorization"] = signature
95
- headers["stream-auth-type"] = "jwt"
104
+ headers['Authorization'] = signature
105
+ headers['stream-auth-type'] = 'jwt'
96
106
 
97
107
  get_http_client.make_http_request(method, relative_url, make_query_params(params), data, headers)
98
108
  end
99
109
  end
100
110
 
101
111
  class StreamHTTPClient
102
- require "faraday"
112
+ require 'faraday'
103
113
 
104
114
  attr_reader :conn
105
115
  attr_reader :options
@@ -107,14 +117,14 @@ module Stream
107
117
 
108
118
  def initialize(client_params)
109
119
  @options = client_params
110
- location_name = "api"
120
+ location_name = 'api'
111
121
  unless client_params[:location].nil?
112
122
  location_name = "#{client_params[:location]}-api"
113
123
  end
114
124
 
115
125
  protocol = 'https'
116
126
  port = ':443'
117
- if @options[:location] == "qa" || @options[:location] == "localhost"
127
+ if @options[:location] == 'qa' || @options[:location] == 'localhost'
118
128
  protocol = 'http'
119
129
  port = ':80'
120
130
  if @options[:location] == 'localhost'
@@ -122,8 +132,13 @@ module Stream
122
132
  end
123
133
  end
124
134
 
135
+ api_hostname = 'stream-io-api.com'
136
+ if @options[:api_hostname]
137
+ api_hostname = @options[:api_hostname]
138
+ end
139
+
125
140
  @base_path = "/api/#{@options[:api_version]}"
126
- base_url = "#{protocol}://#{location_name}.getstream.io#{port}#{@base_path}"
141
+ base_url = "#{protocol}://#{location_name}.#{api_hostname}#{port}#{@base_path}"
127
142
 
128
143
  @conn = Faraday.new(:url => base_url) do |faraday|
129
144
  # faraday.request :url_encoded
@@ -136,21 +151,21 @@ module Stream
136
151
  end
137
152
 
138
153
  def make_http_request(method, relative_url, params = nil, data = nil, headers = nil)
139
- headers["Content-Type"] = "application/json"
140
- headers["X-Stream-Client"] = "stream-ruby-client-#{Stream::VERSION}"
141
- params["api_key"] = @options[:api_key]
154
+ headers['Content-Type'] = 'application/json'
155
+ headers['X-Stream-Client'] = "stream-ruby-client-#{Stream::VERSION}"
156
+ params['api_key'] = @options[:api_key]
142
157
  relative_url = "#{@base_path}#{relative_url}?#{URI.encode_www_form(params)}"
143
158
  body = data.to_json if %w(post put).include? method.to_s
144
159
  response = @conn.run_request(
145
- method,
146
- relative_url,
147
- body,
148
- headers
160
+ method,
161
+ relative_url,
162
+ body,
163
+ headers
149
164
  )
150
165
 
151
166
  case response[:status].to_i
152
- when 200..203
153
- return ::JSON.parse(response[:body])
167
+ when 200..203
168
+ return ::JSON.parse(response[:body])
154
169
  end
155
170
  end
156
171
  end
@@ -159,21 +174,20 @@ module Stream
159
174
  def call(env)
160
175
  @app.call(env).on_complete do |response|
161
176
  case response[:status].to_i
162
- when 200..203
163
- return response
164
- when 401
165
- raise StreamApiResponseException, error_message(response, "Bad feed")
166
- when 403
167
- raise StreamApiResponseException, error_message(response, "Bad auth/headers")
168
- when 404
169
- raise StreamApiResponseException, error_message(response, "url not found")
170
- when 204...600
171
- raise StreamApiResponseException, error_message(response, _build_error_message(response.body))
177
+ when 200..203
178
+ return response
179
+ when 401
180
+ raise StreamApiResponseException, error_message(response, 'Bad feed')
181
+ when 403
182
+ raise StreamApiResponseException, error_message(response, 'Bad auth/headers')
183
+ when 404
184
+ raise StreamApiResponseException, error_message(response, 'url not found')
185
+ when 204...600
186
+ raise StreamApiResponseException, error_message(response, _build_error_message(response.body))
172
187
  end
173
188
  end
174
189
  end
175
190
 
176
-
177
191
  def initialize(app)
178
192
  super app
179
193
  @parser = nil
@@ -184,8 +198,8 @@ module Stream
184
198
  def _build_error_message(response)
185
199
  response = JSON.parse(response)
186
200
  msg = "#{response['exception']} details: #{response['detail']}"
187
- if response.key?("exception_fields")
188
- response["exception_fields"].map do |field, messages|
201
+ if response.key?('exception_fields')
202
+ response['exception_fields'].map do |field, messages|
189
203
  msg << "\n#{field}: #{messages}"
190
204
  end
191
205
  end
@@ -1,2 +1,2 @@
1
1
  warn "Requiring 'stream/exceptions' is deprecated. Use 'stream/errors' instead."
2
- require "stream/errors"
2
+ require 'stream/errors'
data/lib/stream/feed.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "stream/signer"
2
- require "jwt"
1
+ require 'stream/signer'
2
+ require 'jwt'
3
3
 
4
4
  module Stream
5
5
  class Feed
@@ -10,11 +10,11 @@ module Stream
10
10
 
11
11
  def initialize(client, feed_slug, user_id, token)
12
12
  unless valid_feed_slug feed_slug
13
- raise StreamInputData, "feed_slug can only contain alphanumeric characters plus underscores"
13
+ raise StreamInputData, 'feed_slug can only contain alphanumeric characters plus underscores'
14
14
  end
15
15
 
16
16
  unless valid_user_id user_id
17
- raise StreamInputData, "user_id can only contain alphanumeric characters plus underscores and dashes"
17
+ raise StreamInputData, 'user_id can only contain alphanumeric characters plus underscores and dashes'
18
18
  end
19
19
 
20
20
  @id = "#{feed_slug}:#{user_id}"
@@ -27,7 +27,7 @@ module Stream
27
27
  end
28
28
 
29
29
  def readonly_token
30
- create_jwt_token("*", "read")
30
+ create_jwt_token('*', 'read')
31
31
  end
32
32
 
33
33
  def valid_feed_slug(feed_slug)
@@ -41,19 +41,19 @@ module Stream
41
41
  def get(params = {})
42
42
  uri = "/feed/#{@feed_url}/"
43
43
  if params[:mark_read] && params[:mark_read].is_a?(Array)
44
- params[:mark_read] = params[:mark_read].join(",")
44
+ params[:mark_read] = params[:mark_read].join(',')
45
45
  end
46
46
  if params[:mark_seen] && params[:mark_seen].is_a?(Array)
47
- params[:mark_seen] = params[:mark_seen].join(",")
47
+ params[:mark_seen] = params[:mark_seen].join(',')
48
48
  end
49
- auth_token = create_jwt_token("feed", "read")
49
+ auth_token = create_jwt_token('feed', 'read')
50
50
 
51
51
  @client.make_request(:get, uri, auth_token, params)
52
52
  end
53
53
 
54
54
  def sign_to_field(to)
55
55
  to.map do |feed_id|
56
- feed_slug, user_id = feed_id.split(":")
56
+ feed_slug, user_id = feed_id.split(':')
57
57
  feed = @client.feed(feed_slug, user_id)
58
58
  "#{feed.id} #{feed.token}"
59
59
  end
@@ -62,7 +62,7 @@ module Stream
62
62
  def add_activity(activity_data)
63
63
  uri = "/feed/#{@feed_url}/"
64
64
  activity_data[:to] &&= sign_to_field(activity_data[:to])
65
- auth_token = create_jwt_token("feed", "write")
65
+ auth_token = create_jwt_token('feed', 'write')
66
66
 
67
67
  @client.make_request(:post, uri, auth_token, {}, activity_data)
68
68
  end
@@ -72,8 +72,8 @@ module Stream
72
72
  activities.each do |activity|
73
73
  activity[:to] &&= sign_to_field(activity[:to])
74
74
  end
75
- data = { :activities => activities }
76
- auth_token = create_jwt_token("feed", "write")
75
+ data = {:activities => activities}
76
+ auth_token = create_jwt_token('feed', 'write')
77
77
 
78
78
  @client.make_request(:post, uri, auth_token, {}, data)
79
79
  end
@@ -85,8 +85,8 @@ module Stream
85
85
  def remove_activity(activity_id, foreign_id = false)
86
86
  uri = "/feed/#{@feed_url}/#{activity_id}/"
87
87
  params = {}
88
- params = { "foreign_id" => 1 } if foreign_id
89
- auth_token = create_jwt_token("feed", "delete")
88
+ params = {foreign_id: 1} if foreign_id
89
+ auth_token = create_jwt_token('feed', 'delete')
90
90
 
91
91
  @client.make_request(:delete, uri, auth_token, params)
92
92
  end
@@ -96,14 +96,14 @@ module Stream
96
96
  end
97
97
 
98
98
  def update_activities(activities)
99
- auth_token = create_jwt_token("activities", "*", "*")
99
+ auth_token = create_jwt_token('activities', '*', '*')
100
100
 
101
- @client.make_request(:post, "/activities/", auth_token, {}, "activities" => activities)
101
+ @client.make_request(:post, '/activities/', auth_token, {}, 'activities' => activities)
102
102
  end
103
103
 
104
104
  def delete
105
105
  uri = "/feed/#{@feed_url}/"
106
- auth_token = create_jwt_token("feed", "delete")
106
+ auth_token = create_jwt_token('feed', 'delete')
107
107
 
108
108
  @client.make_request(:delete, uri, auth_token)
109
109
  end
@@ -114,11 +114,11 @@ module Stream
114
114
  activity_copy_limit = 1000 if activity_copy_limit > 1000
115
115
 
116
116
  follow_data = {
117
- target: "#{target_feed_slug}:#{target_user_id}",
118
- target_token: @client.feed(target_feed_slug, target_user_id).token,
119
- activity_copy_limit: activity_copy_limit
117
+ target: "#{target_feed_slug}:#{target_user_id}",
118
+ target_token: @client.feed(target_feed_slug, target_user_id).token,
119
+ activity_copy_limit: activity_copy_limit
120
120
  }
121
- auth_token = create_jwt_token("follower", "write")
121
+ auth_token = create_jwt_token('follower', 'write')
122
122
 
123
123
  @client.make_request(:post, uri, auth_token, {}, follow_data)
124
124
  end
@@ -126,10 +126,10 @@ module Stream
126
126
  def followers(offset = 0, limit = 25)
127
127
  uri = "/feed/#{@feed_url}/followers/"
128
128
  params = {
129
- "offset" => offset,
130
- "limit" => limit
129
+ offset: offset,
130
+ limit: limit
131
131
  }
132
- auth_token = create_jwt_token("follower", "read")
132
+ auth_token = create_jwt_token('follower', 'read')
133
133
 
134
134
  @client.make_request(:get, uri, auth_token, params)
135
135
  end
@@ -137,20 +137,20 @@ module Stream
137
137
  def following(offset = 0, limit = 25, filter = [])
138
138
  uri = "/feed/#{@feed_url}/follows/"
139
139
  params = {
140
- "offset" => offset,
141
- "limit" => limit,
142
- "filter" => filter.join(",")
140
+ offset: offset,
141
+ limit: limit,
142
+ filter: filter.join(',')
143
143
  }
144
- auth_token = create_jwt_token("follower", "read")
144
+ auth_token = create_jwt_token('follower', 'read')
145
145
 
146
146
  @client.make_request(:get, uri, auth_token, params)
147
147
  end
148
148
 
149
149
  def unfollow(target_feed_slug, target_user_id, keep_history = false)
150
150
  uri = "/feed/#{@feed_url}/follows/#{target_feed_slug}:#{target_user_id}/"
151
- auth_token = create_jwt_token("follower", "delete")
151
+ auth_token = create_jwt_token('follower', 'delete')
152
152
  params = {}
153
- params["keep_history"] = true if keep_history
153
+ params['keep_history'] = true if keep_history
154
154
  @client.make_request(:delete, uri, auth_token, params)
155
155
  end
156
156
 
@@ -1,11 +1,12 @@
1
- require "http_signatures"
2
- require "net/http"
3
- require "time"
1
+ require 'http_signatures'
2
+ require 'net/http'
3
+ require 'time'
4
4
 
5
5
  module Stream
6
6
  module SignedRequest
7
7
  module ClassMethods
8
- def supports_signed_requests; end
8
+ def supports_signed_requests;
9
+ end
9
10
  end
10
11
 
11
12
  def self.included(klass)
@@ -15,26 +16,26 @@ module Stream
15
16
  def make_signed_request(method, relative_url, params = {}, data = {})
16
17
  query_params = make_query_params(params)
17
18
  context = HttpSignatures::Context.new(
18
- keys: { @api_key => @api_secret },
19
- algorithm: "hmac-sha256",
20
- headers: ["(request-target)", "Date"]
19
+ keys: {@api_key => @api_secret},
20
+ algorithm: 'hmac-sha256',
21
+ headers: %w((request-target) Date)
21
22
  )
22
23
  method_map = {
23
- :get => Net::HTTP::Get,
24
- :delete => Net::HTTP::Delete,
25
- :put => Net::HTTP::Put,
26
- :post => Net::HTTP::Post
24
+ :get => Net::HTTP::Get,
25
+ :delete => Net::HTTP::Delete,
26
+ :put => Net::HTTP::Put,
27
+ :post => Net::HTTP::Post
27
28
  }
28
29
  request_date = Time.now.rfc822
29
30
  message = method_map[method].new(
30
- "#{get_http_client.base_path}#{relative_url}?#{URI.encode_www_form(query_params)}",
31
- "Date" => request_date
31
+ "#{get_http_client.base_path}#{relative_url}?#{URI.encode_www_form(query_params)}",
32
+ 'Date' => request_date
32
33
  )
33
34
  context.signer.sign(message)
34
35
  headers = {
35
- "Authorization" => message["Signature"],
36
- "Date" => request_date,
37
- "X-Api-Key" => api_key
36
+ Authorization: message['Signature'],
37
+ Date: request_date,
38
+ 'X-Api-Key' => api_key
38
39
  }
39
40
  get_http_client.make_http_request(method, relative_url, query_params, data, headers)
40
41
  end
data/lib/stream/signer.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "openssl"
2
- require "base64"
1
+ require 'openssl'
2
+ require 'base64'
3
3
 
4
4
  module Stream
5
5
  class Signer
@@ -7,11 +7,11 @@ module Stream
7
7
 
8
8
  def initialize(key)
9
9
  @key = key.to_s
10
- @sha1 = OpenSSL::Digest.new("sha1")
10
+ @sha1 = OpenSSL::Digest.new('sha1')
11
11
  end
12
12
 
13
13
  def urlsafe_encodeb64(value)
14
- value.tr("+", "-").tr("/", "_").gsub(/^=+/, "").gsub(/=+$/, "")
14
+ value.tr('+', '-').tr('/', '_').gsub(/^=+/, '').gsub(/=+$/, '')
15
15
  end
16
16
 
17
17
  def sign_message(message)
@@ -26,13 +26,13 @@ module Stream
26
26
 
27
27
  def self.create_jwt_token(resource, action, api_secret, feed_id = nil, user_id = nil)
28
28
  payload = {
29
- "resource" => resource,
30
- "action" => action
29
+ resource: resource,
30
+ action: action
31
31
  }
32
- payload["feed_id"] = feed_id if feed_id
33
- payload["user_id"] = user_id if user_id
32
+ payload['feed_id'] = feed_id if feed_id
33
+ payload['user_id'] = user_id if user_id
34
34
 
35
- JWT.encode(payload, api_secret, "HS256")
35
+ JWT.encode(payload, api_secret, 'HS256')
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module Stream
2
- VERSION = "2.5.8".freeze
2
+ VERSION = '2.5.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.8
4
+ version: 2.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommaso Barbugli
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-21 00:00:00.000000000 Z
12
+ date: 2017-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.5.1
144
+ rubygems_version: 2.6.13
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: A gem that provides a client interface for getstream.io