stream-ruby 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stream/activities.rb +107 -42
- data/lib/stream/batch.rb +10 -14
- data/lib/stream/client.rb +0 -1
- data/lib/stream/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05ce0c71f39cd30007d6dcd0672a1155c6ac917b5a37d851ee20d50eba9f08c0
|
4
|
+
data.tar.gz: 509f5e5c59cce2bfd309552defaa39b9ed69b6407c9a0e537f1c6fb1a01fe882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0edd4f3150ba8b8f3bb25b62f18bfa55e9a7a90eee73641518a7cb134bc4b14639db033e5f70afb005d93e7dbfa1ad183f2a1676115af279022be0aa764bcaec
|
7
|
+
data.tar.gz: ef0007cfe4c1017f4e1cdd054b277fb51287cba6fc6a67fa5ec60fa06dfd0fd3c6f40f84ebee6d737a7eb603ae9528995bbcfe81ece28aadcd4becc86f4e339e
|
data/lib/stream/activities.rb
CHANGED
@@ -8,22 +8,21 @@ module Stream
|
|
8
8
|
#
|
9
9
|
# @return the found activities, if any.
|
10
10
|
#
|
11
|
-
# @example
|
11
|
+
# @example Retrieve by activity IDs
|
12
|
+
# @client.get_activities(
|
13
|
+
# ids: [
|
14
|
+
# '4b39fda2-d6e2-42c9-9abf-5301ef071b12',
|
15
|
+
# '89b910d3-1ef5-44f8-914e-e7735d79e817'
|
16
|
+
# ]
|
17
|
+
# )
|
12
18
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# @client.get_activities(
|
22
|
-
# foreign_id_times: [
|
23
|
-
# { foreign_id: 'post:1000', time: '2016-11-10T13:20:00.000000' },
|
24
|
-
# { foreign_id: 'like:2000', time: '2018-01-07T09:15:59.123456' }
|
25
|
-
# ]
|
26
|
-
# )
|
19
|
+
# @example Retrieve by Foreign IDs + timestamps
|
20
|
+
# @client.get_activities(
|
21
|
+
# foreign_id_times: [
|
22
|
+
# { foreign_id: 'post:1000', time: '2016-11-10T13:20:00.000000' },
|
23
|
+
# { foreign_id: 'like:2000', time: '2018-01-07T09:15:59.123456' }
|
24
|
+
# ]
|
25
|
+
# )
|
27
26
|
#
|
28
27
|
def get_activities(params = {})
|
29
28
|
if params[:foreign_id_times]
|
@@ -43,42 +42,108 @@ module Stream
|
|
43
42
|
end
|
44
43
|
|
45
44
|
#
|
46
|
-
# Partial update activity, via
|
45
|
+
# Partial update activity, via activity ID or Foreign ID + timestamp
|
47
46
|
#
|
48
47
|
# @param [Hash<:id, :foreign_id, :time, :set, :unset>] data the request params (id and foreign_id+timestamp mutually exclusive)
|
49
48
|
#
|
50
49
|
# @return the updated activity.
|
51
50
|
#
|
52
|
-
# @example
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
51
|
+
# @example Identify using activity ID
|
52
|
+
# @client.activity_partial_update(
|
53
|
+
# id: "4b39fda2-d6e2-42c9-9abf-5301ef071b12",
|
54
|
+
# set: {
|
55
|
+
# "product.price.eur": 12.99,
|
56
|
+
# "colors": {
|
57
|
+
# "blue": "#0000ff",
|
58
|
+
# "green": "#00ff00",
|
59
|
+
# }
|
60
|
+
# },
|
61
|
+
# unset: [ "popularity", "size.xl" ]
|
62
|
+
# )
|
63
|
+
#
|
64
|
+
# @example Identify using Foreign ID + timestamp
|
65
|
+
# @client.activity_partial_update(
|
66
|
+
# foreign_id: 'product:123',
|
67
|
+
# time: '2016-11-10T13:20:00.000000',
|
68
|
+
# set: {
|
69
|
+
# "product.price.eur": 12.99,
|
70
|
+
# "colors": {
|
71
|
+
# "blue": "#0000ff",
|
72
|
+
# "green": "#00ff00",
|
73
|
+
# }
|
74
|
+
# },
|
75
|
+
# unset: [ "popularity", "size.xl" ]
|
76
|
+
# )
|
77
|
+
#
|
78
78
|
def activity_partial_update(data = {})
|
79
79
|
signature = Stream::Signer.create_jwt_token('activities', '*', @api_secret, '*')
|
80
80
|
make_request(:post, '/activity/', signature, {}, data)
|
81
81
|
end
|
82
82
|
|
83
|
+
#
|
84
|
+
# Batch partial activity update
|
85
|
+
#
|
86
|
+
# @param [Array< Hash<:id, :foreign_id, :time, :set, :unset> >] changes the list of changes to be applied
|
87
|
+
#
|
88
|
+
# @return the updated activities
|
89
|
+
#
|
90
|
+
# @example Identify using activity IDs
|
91
|
+
# @client.batch_activity_partial_update([
|
92
|
+
# {
|
93
|
+
# id: "4b39fda2-d6e2-42c9-9abf-5301ef071b12",
|
94
|
+
# set: {
|
95
|
+
# "product.price.eur": 12.99,
|
96
|
+
# "colors": {
|
97
|
+
# "blue": "#0000ff",
|
98
|
+
# "green": "#00ff00",
|
99
|
+
# }
|
100
|
+
# },
|
101
|
+
# unset: [ "popularity", "size.x2" ]
|
102
|
+
# },
|
103
|
+
# {
|
104
|
+
# id: "8d2dcad8-1e34-11e9-8b10-9cb6d0925edd",
|
105
|
+
# set: {
|
106
|
+
# "product.price.eur": 17.99,
|
107
|
+
# "colors": {
|
108
|
+
# "red": "#ff0000",
|
109
|
+
# "green": "#00ff00",
|
110
|
+
# }
|
111
|
+
# },
|
112
|
+
# unset: [ "rating" ]
|
113
|
+
# }
|
114
|
+
# ])
|
115
|
+
#
|
116
|
+
# @example Identify using Foreign IDs + timestamps
|
117
|
+
# @client.batch_activity_partial_update([
|
118
|
+
# {
|
119
|
+
# foreign_id: "product:123",
|
120
|
+
# time: '2016-11-10T13:20:00.000000',
|
121
|
+
# set: {
|
122
|
+
# "product.price.eur": 22.99,
|
123
|
+
# "colors": {
|
124
|
+
# "blue": "#0000ff",
|
125
|
+
# "green": "#00ff00",
|
126
|
+
# }
|
127
|
+
# },
|
128
|
+
# unset: [ "popularity", "size.x2" ]
|
129
|
+
# },
|
130
|
+
# {
|
131
|
+
# foreign_id: "product:1234",
|
132
|
+
# time: '2017-11-10T13:20:00.000000',
|
133
|
+
# set: {
|
134
|
+
# "product.price.eur": 37.99,
|
135
|
+
# "colors": {
|
136
|
+
# "black": "#000000",
|
137
|
+
# "white": "#ffffff",
|
138
|
+
# }
|
139
|
+
# },
|
140
|
+
# unset: [ "rating" ]
|
141
|
+
# }
|
142
|
+
# ])
|
143
|
+
#
|
144
|
+
def batch_activity_partial_update(changes = [])
|
145
|
+
signature = Stream::Signer.create_jwt_token('activities', '*', @api_secret, '*')
|
146
|
+
make_request(:post, '/activity/', signature, {}, {:changes => changes})
|
147
|
+
end
|
83
148
|
end
|
84
149
|
end
|
data/lib/stream/batch.rb
CHANGED
@@ -8,13 +8,11 @@ module Stream
|
|
8
8
|
# @return [nil]
|
9
9
|
#
|
10
10
|
# @example
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# ]
|
17
|
-
# @client.follow_many(follows)
|
11
|
+
# follows = [
|
12
|
+
# {:source => 'flat:1', :target => 'user:1'},
|
13
|
+
# {:source => 'flat:1', :target => 'user:3'}
|
14
|
+
# ]
|
15
|
+
# @client.follow_many(follows)
|
18
16
|
#
|
19
17
|
def follow_many(follows, activity_copy_limit = nil)
|
20
18
|
query_params = {}
|
@@ -33,13 +31,11 @@ module Stream
|
|
33
31
|
# return [nil]
|
34
32
|
#
|
35
33
|
# @example
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
# ]
|
42
|
-
# @client.unfollow_many(unfollows)
|
34
|
+
# unfollows = [
|
35
|
+
# {source: 'user:1', target: 'timeline:1'},
|
36
|
+
# {source: 'user:2', target: 'timeline:2', keep_history: false}
|
37
|
+
# ]
|
38
|
+
# @client.unfollow_many(unfollows)
|
43
39
|
#
|
44
40
|
def unfollow_many(unfollows)
|
45
41
|
signature = Stream::Signer.create_jwt_token('follower', '*', @api_secret, '*')
|
data/lib/stream/client.rb
CHANGED
@@ -143,7 +143,6 @@ module Stream
|
|
143
143
|
def make_request(method, relative_url, signature, params = {}, data = {}, headers = {})
|
144
144
|
headers['Authorization'] = signature
|
145
145
|
headers['stream-auth-type'] = 'jwt'
|
146
|
-
|
147
146
|
get_http_client.make_http_request(method, relative_url, make_query_params(params), data, headers)
|
148
147
|
end
|
149
148
|
|
data/lib/stream/version.rb
CHANGED
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: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommaso Barbugli
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|