koko-ai-ruby 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +6 -1
- data/README.md +14 -15
- data/lib/koko/tracker/client.rb +4 -14
- data/lib/koko/tracker/version.rb +1 -1
- data/spec/koko/tracking/client_spec.rb +3 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6c9f7847f52c86060024c1a7bec1db9f8b39a49
|
4
|
+
data.tar.gz: fad4787b80d50b0f36732fd71a71b4f7d4cc2f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e286ac11ca9a577d53ad7db99993449208e49e3a6829b6a80f8f8a899fc71e5fb2e70e8f33795e0123c563d47d7a923e412be6f8e886e75842afad5a8be089
|
7
|
+
data.tar.gz: 6ec716712c6c44c5699fe89b867529d909bfb9a320ddf9ee766c5200c54b45e03b2d958416a24ca2498cf5d02b2847ab39a89b5c0c2493c12518f8497b7d1877
|
data/History.md
CHANGED
@@ -14,7 +14,12 @@
|
|
14
14
|
|
15
15
|
* Remove unnecessary dependency
|
16
16
|
|
17
|
-
0.0.4 / 2017-
|
17
|
+
0.0.4 / 2017-07-10
|
18
18
|
==================
|
19
19
|
|
20
20
|
* Use Json default serialization for created_at time
|
21
|
+
|
22
|
+
0.0.5 / 2017-07-10
|
23
|
+
==================
|
24
|
+
|
25
|
+
* Return body directly instead of using block
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Create an instance of the client:
|
|
22
22
|
koko = Koko::Tracker.new(auth: 'YOUR_AUTH_KEY')
|
23
23
|
```
|
24
24
|
|
25
|
-
Track content, see more [here](https://docs.koko.ai/#track-endpoints).
|
25
|
+
Track content, flags and moderations, see more [here](https://docs.koko.ai/#track-endpoints).
|
26
26
|
```ruby
|
27
27
|
koko.track_content(id: "123",
|
28
28
|
created_at: Time.now,
|
@@ -36,28 +36,27 @@ koko.track_flag(id: "123",
|
|
36
36
|
flagger_id: "123",
|
37
37
|
type: "spam",
|
38
38
|
created_at: Time.now,
|
39
|
-
|
39
|
+
targets: [{content_id: "123"}])
|
40
40
|
|
41
41
|
koko.track_moderation(id: "123",
|
42
42
|
type: "user_warned",
|
43
43
|
created_at: Time.now,
|
44
|
-
|
44
|
+
targets: [{content_id: "123" }])
|
45
45
|
|
46
46
|
```
|
47
47
|
|
48
|
-
To get behavorial classifications when tracking content, pass
|
49
|
-
|
50
|
-
called synchronously.
|
48
|
+
To get behavorial classifications when tracking content, pass the classifiers
|
49
|
+
you want run as an options param
|
51
50
|
```ruby
|
52
|
-
koko.track_content(id: "123",
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
51
|
+
classifications = koko.track_content(id: "123",
|
52
|
+
created_at: Time.now,
|
53
|
+
user_id: "123",
|
54
|
+
type: "post",
|
55
|
+
context_id: "123",
|
56
|
+
content_type: "text",
|
57
|
+
content: { text: "Some content" },
|
58
|
+
options: { classifiers: ['crisis'] })
|
59
|
+
|
61
60
|
```
|
62
61
|
|
63
62
|
## Testing
|
data/lib/koko/tracker/client.rb
CHANGED
@@ -25,20 +25,14 @@ module Koko
|
|
25
25
|
# public: Track content
|
26
26
|
#
|
27
27
|
# attrs - Hash (see https://docs.koko.ai/#track-endpoints)
|
28
|
-
def track_content attrs
|
28
|
+
def track_content attrs
|
29
29
|
symbolize_keys! attrs
|
30
30
|
|
31
31
|
timestamp = attrs[:created_at] || Time.now
|
32
32
|
check_timestamp! timestamp
|
33
33
|
attrs[:created_at] = timestamp
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
if block
|
38
|
-
block.call(response.body)
|
39
|
-
end
|
40
|
-
|
41
|
-
true
|
35
|
+
handle_response(Request.new(path: '/track/content').post(@auth, attrs)).body
|
42
36
|
end
|
43
37
|
|
44
38
|
# public: Track flag
|
@@ -51,9 +45,7 @@ module Koko
|
|
51
45
|
check_timestamp! timestamp
|
52
46
|
attrs[:created_at] = timestamp
|
53
47
|
|
54
|
-
handle_response(Request.new(path: '/track/flag').post(@auth, attrs))
|
55
|
-
|
56
|
-
true
|
48
|
+
handle_response(Request.new(path: '/track/flag').post(@auth, attrs)).body
|
57
49
|
end
|
58
50
|
|
59
51
|
# public: Track moderation
|
@@ -66,9 +58,7 @@ module Koko
|
|
66
58
|
check_timestamp! timestamp
|
67
59
|
attrs[:created_at] = timestamp
|
68
60
|
|
69
|
-
handle_response(Request.new(path: '/track/moderation').post(@auth, attrs))
|
70
|
-
|
71
|
-
true
|
61
|
+
handle_response(Request.new(path: '/track/moderation').post(@auth, attrs)).body
|
72
62
|
end
|
73
63
|
|
74
64
|
private
|
data/lib/koko/tracker/version.rb
CHANGED
@@ -63,11 +63,9 @@ module Koko
|
|
63
63
|
expect(WebMock).to have_requested(:post, "https://#{Defaults::Request.host}/track/content").with(body: expected_body)
|
64
64
|
end
|
65
65
|
|
66
|
-
it 'returns the parsed body
|
67
|
-
response_body =
|
68
|
-
|
69
|
-
response_body = response
|
70
|
-
end
|
66
|
+
it 'returns the parsed body' do
|
67
|
+
response_body = client.track_content(Factory.content)
|
68
|
+
|
71
69
|
expect(response_body).to eq(JSON.load(body))
|
72
70
|
end
|
73
71
|
end
|