koko-ai-ruby 0.0.4 → 0.0.5

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: bbab8eb849d6a88baf77197a3626975c3376238d
4
- data.tar.gz: 87c099458959d5efe6f655b7a1cd622ca2d6fbc2
3
+ metadata.gz: c6c9f7847f52c86060024c1a7bec1db9f8b39a49
4
+ data.tar.gz: fad4787b80d50b0f36732fd71a71b4f7d4cc2f7c
5
5
  SHA512:
6
- metadata.gz: fb14079af0a2669d54eab7e731b0f52ed664f37f02dfde0e440d4fc9599126eddc13c487a3eb419fa7717d1447af93539b2e30c3b6c000d22de730982f4ede4d
7
- data.tar.gz: 3d9196f33b107d62d89e4806be3da1ea70fc08902483d2020cbc9098d33cd8202bbdc9797579fc4a9c2b463cb31e3ab7a60899efd0623c503b9a5f2102bc6b73
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-06-28
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
- content: {"id":"123"})
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
- content: { id:"123" })
44
+ targets: [{content_id: "123" }])
45
45
 
46
46
  ```
47
47
 
48
- To get behavorial classifications when tracking content, pass a block with a
49
- single parameter which will be populated with the results. This block will be
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
- created_at: "2016-08-29T09:12:33.001Z",
54
- user_id: "123",
55
- type: "post",
56
- context_id: "123",
57
- content_type: "text",
58
- content: { text: "Some content" }) do |classification|
59
- crisis_confidence = classification.find { |c| c['label'] == 'crisis' }['confidence']
60
- end
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
@@ -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, &block
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
- response = handle_response(Request.new(path: '/track/content').post(@auth, attrs))
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
@@ -1,5 +1,5 @@
1
1
  module Koko
2
2
  class Tracker
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -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 if a block is passed' do
67
- response_body = nil
68
- client.track_content(Factory.content) do |response|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koko-ai-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koko