stream-ruby 2.4.3 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -1
- data/lib/stream/batch.rb +2 -2
- data/lib/stream/client.rb +18 -10
- data/lib/stream/feed.rb +5 -10
- data/lib/stream/signer.rb +3 -3
- data/lib/stream/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 939aad0b2c91ed84c1bc6ebd4996941cb48df05f
|
4
|
+
data.tar.gz: f4924439a962af89b8fd9a7ef5ceba2128c40f5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 122eabcf8c9cd6df6bf4ee3cd8075d2538c1632b5ddb652ec695574b0ce90c10a95fc74ccd218c54d97edd5935c2b17ffb284d230e30b9c073ceee9143060880
|
7
|
+
data.tar.gz: 03c846a89658e57eaf2230c2285a00d57aaae6a0e0e2d999caec24146936813941f1118d4ec5045e94838f75f1cb44d9d70b9548c8780694fcf019c087d7a12f
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,8 @@ stream-ruby
|
|
4
4
|
[![Build Status](https://travis-ci.org/GetStream/stream-ruby.svg?branch=master)](https://travis-ci.org/GetStream/stream-ruby) [![Gem Version](https://badge.fury.io/rb/stream-ruby.svg)](http://badge.fury.io/rb/stream-ruby)
|
5
5
|
|
6
6
|
stream-ruby is the official Ruby client for [Stream](https://getstream.io/), a web service for building scalable newsfeeds and activity streams.
|
7
|
-
The full documentation is available on [GetStream.io/docs](http://getstream.io/docs
|
7
|
+
The full documentation is available on [GetStream.io/docs/?language=ruby](http://getstream.io/docs/?language=ruby).
|
8
|
+
There is also a [higher level Rails integration](https://github.com/getstream/stream-rails) library which hooks into your ORM.
|
8
9
|
|
9
10
|
### Installation
|
10
11
|
|
data/lib/stream/batch.rb
CHANGED
@@ -16,10 +16,10 @@ module Stream
|
|
16
16
|
# ]
|
17
17
|
# @client.follow_many(follows)
|
18
18
|
#
|
19
|
-
def follow_many(follows, activity_copy_limit=nil)
|
19
|
+
def follow_many(follows, activity_copy_limit = nil)
|
20
20
|
query_params = {}
|
21
21
|
unless activity_copy_limit.nil?
|
22
|
-
query_params[
|
22
|
+
query_params["activity_copy_limit"] = activity_copy_limit
|
23
23
|
end
|
24
24
|
make_signed_request(:post, "/follow_many/", query_params, follows)
|
25
25
|
end
|
data/lib/stream/client.rb
CHANGED
@@ -2,6 +2,7 @@ require "httparty"
|
|
2
2
|
require "stream/errors"
|
3
3
|
require "stream/feed"
|
4
4
|
require "stream/signer"
|
5
|
+
require "persistent_httparty"
|
5
6
|
|
6
7
|
module Stream
|
7
8
|
STREAM_URL_RE = %r{https\:\/\/(?<key>\w+)\:(?<secret>\w+)@((api\.)|((?<location>[-\w]+)\.))?getstream\.io\/[\w=-\?%&]+app_id=(?<app_id>\d+)}i
|
@@ -74,7 +75,7 @@ module Stream
|
|
74
75
|
|
75
76
|
def update_activities(activities)
|
76
77
|
auth_token = Stream::Signer.create_jwt_token("activities", "*", @api_secret, "*")
|
77
|
-
|
78
|
+
make_request(:post, "/activities/", auth_token, {}, "activities" => activities)
|
78
79
|
end
|
79
80
|
|
80
81
|
def get_default_params
|
@@ -82,7 +83,7 @@ module Stream
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def get_http_client
|
85
|
-
StreamHTTPClient.new(@api_version, @location, @default_timeout)
|
86
|
+
@http_client ||= StreamHTTPClient.new(@api_version, @location, @default_timeout)
|
86
87
|
end
|
87
88
|
|
88
89
|
def make_query_params(params)
|
@@ -91,7 +92,7 @@ module Stream
|
|
91
92
|
|
92
93
|
def make_request(method, relative_url, signature, params = {}, data = {}, headers = {})
|
93
94
|
headers["Authorization"] = signature
|
94
|
-
headers["stream-auth-type"] =
|
95
|
+
headers["stream-auth-type"] = "jwt"
|
95
96
|
|
96
97
|
get_http_client.make_http_request(method, relative_url, make_query_params(params), data, headers)
|
97
98
|
end
|
@@ -99,27 +100,34 @@ module Stream
|
|
99
100
|
|
100
101
|
class StreamHTTPClient
|
101
102
|
include HTTParty
|
103
|
+
persistent_connection_adapter
|
104
|
+
|
102
105
|
attr_reader :base_path
|
103
106
|
|
104
107
|
def initialize(api_version = "v1.0", location = nil, default_timeout = 3)
|
105
|
-
|
106
|
-
|
107
|
-
else
|
108
|
+
location_name = "api"
|
109
|
+
unless location.nil?
|
108
110
|
location_name = "#{location}-api"
|
109
111
|
end
|
110
112
|
@base_path = "/api/#{api_version}"
|
111
|
-
|
113
|
+
|
114
|
+
protocol = "https"
|
115
|
+
if location == "qa"
|
116
|
+
protocol = "http"
|
117
|
+
end
|
118
|
+
|
119
|
+
self.class.base_uri "#{protocol}://#{location_name}.getstream.io#{@base_path}"
|
112
120
|
self.class.default_timeout default_timeout
|
113
121
|
end
|
114
122
|
|
115
123
|
def _build_error_message(response)
|
116
124
|
msg = "#{response['exception']} details: #{response['detail']}"
|
117
125
|
|
118
|
-
response[
|
126
|
+
response["exception_fields"].map do |field, messages|
|
119
127
|
msg << "\n#{field}: #{messages}"
|
120
|
-
end if response.
|
128
|
+
end if response.key?("exception_fields")
|
121
129
|
|
122
|
-
|
130
|
+
msg
|
123
131
|
end
|
124
132
|
|
125
133
|
def make_http_request(method, relative_url, params = nil, data = nil, headers = nil)
|
data/lib/stream/feed.rb
CHANGED
@@ -98,7 +98,7 @@ module Stream
|
|
98
98
|
def update_activities(activities)
|
99
99
|
auth_token = create_jwt_token("activities", "*", "*")
|
100
100
|
|
101
|
-
@client.make_request(:post, "/activities/", auth_token, {},
|
101
|
+
@client.make_request(:post, "/activities/", auth_token, {}, "activities" => activities)
|
102
102
|
end
|
103
103
|
|
104
104
|
def delete
|
@@ -149,20 +149,15 @@ module Stream
|
|
149
149
|
uri = "/feed/#{@feed_url}/follows/#{target_feed_slug}:#{target_user_id}/"
|
150
150
|
auth_token = create_jwt_token("follower", "delete")
|
151
151
|
params = {}
|
152
|
-
if keep_history
|
153
|
-
params["keep_history"] = true
|
154
|
-
end
|
152
|
+
params["keep_history"] = true if keep_history
|
155
153
|
@client.make_request(:delete, uri, auth_token, params)
|
156
154
|
end
|
157
155
|
|
158
156
|
private
|
159
157
|
|
160
|
-
def create_jwt_token(resource, action, feed_id=nil, user_id=nil)
|
161
|
-
if feed_id.nil?
|
162
|
-
|
163
|
-
end
|
164
|
-
return Stream::Signer.create_jwt_token(resource, action, @client.api_secret, feed_id, user_id)
|
158
|
+
def create_jwt_token(resource, action, feed_id = nil, user_id = nil)
|
159
|
+
feed_id = @feed_name if feed_id.nil?
|
160
|
+
Stream::Signer.create_jwt_token(resource, action, @client.api_secret, feed_id, user_id)
|
165
161
|
end
|
166
|
-
|
167
162
|
end
|
168
163
|
end
|
data/lib/stream/signer.rb
CHANGED
@@ -24,15 +24,15 @@ module Stream
|
|
24
24
|
sign_message("#{feed_slug}#{user_id}")
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.create_jwt_token(resource, action, api_secret, feed_id=nil, user_id=nil)
|
27
|
+
def self.create_jwt_token(resource, action, api_secret, feed_id = nil, user_id = nil)
|
28
28
|
payload = {
|
29
29
|
"resource" => resource,
|
30
30
|
"action" => action
|
31
31
|
}
|
32
32
|
payload["feed_id"] = feed_id if feed_id
|
33
33
|
payload["user_id"] = user_id if user_id
|
34
|
-
return JWT.encode(payload, api_secret, 'HS256')
|
35
|
-
end
|
36
34
|
|
35
|
+
JWT.encode(payload, api_secret, "HS256")
|
36
|
+
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/stream/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stream-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommaso Barbugli
|
8
|
+
- Ian Douglas
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: httparty
|
@@ -52,6 +53,20 @@ dependencies:
|
|
52
53
|
- - '='
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: 1.5.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: persistent_httparty
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.1.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.1.2
|
55
70
|
- !ruby/object:Gem::Dependency
|
56
71
|
name: rake
|
57
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,7 +110,7 @@ dependencies:
|
|
95
110
|
- !ruby/object:Gem::Version
|
96
111
|
version: '0.7'
|
97
112
|
description: Ruby client for getstream.io service
|
98
|
-
email:
|
113
|
+
email: support@getstream.io
|
99
114
|
executables: []
|
100
115
|
extensions: []
|
101
116
|
extra_rdoc_files:
|
@@ -116,7 +131,7 @@ files:
|
|
116
131
|
- lib/stream/version.rb
|
117
132
|
homepage: http://github.com/GetStream/stream-ruby
|
118
133
|
licenses:
|
119
|
-
-
|
134
|
+
- BSD-3-Clause
|
120
135
|
metadata: {}
|
121
136
|
post_install_message:
|
122
137
|
rdoc_options: []
|
@@ -134,9 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
149
|
version: '0'
|
135
150
|
requirements: []
|
136
151
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.6.6
|
138
153
|
signing_key:
|
139
154
|
specification_version: 4
|
140
155
|
summary: A gem that provides a client interface for getstream.io
|
141
156
|
test_files: []
|
142
|
-
has_rdoc: true
|