datawow 1.4.3 → 1.5.0
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 +4 -4
- data/README.md +16 -5
- data/README/moderation_docs.md +173 -0
- data/datawow.gemspec +3 -3
- data/lib/datawow.rb +7 -0
- data/lib/datawow/connector.rb +5 -4
- data/lib/datawow/models/moderation.rb +16 -0
- data/lib/datawow/version.rb +1 -1
- data/test/datawow/connector_test.rb +8 -8
- data/test/datawow/moderation_test.rb +46 -0
- data/test/fixtures/moderation/all.json +68 -0
- data/test/fixtures/moderation/create.json +26 -0
- data/test/fixtures/moderation/find_by.json +26 -0
- data/test/test_helper.rb +23 -17
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f82f9ec8ce308478592a366086601bd8032ad8987172ade55f297a0298b49b38
|
4
|
+
data.tar.gz: 412032d9da061263adf2967b0bf18db3388ee610fcb0b45a93815a88e4595887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a0b2338ad4b0713dce6ce4abe81663c748d9a96a6a5a0044168bc3128dd350c24a0704de93699005869f7bd0ad955435e5b9d52f203eb7fbce03107587276ac
|
7
|
+
data.tar.gz: 910620d35233d3da899d9a8f9f650b0e3fa53ec2732b53b2f0d9cad985ec482a89d2048d8cea9184f970f69c7ec4044846d3891566ec8b669df82be450a25019
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ HTTP RESTFul for calling DataWow APIs
|
|
6
6
|
|
7
7
|
# Installation
|
8
8
|
```ruby
|
9
|
-
gem 'datawow', '~> 1.
|
9
|
+
gem 'datawow', '~> 1.5.0'
|
10
10
|
```
|
11
11
|
|
12
12
|
### Rails
|
@@ -37,14 +37,14 @@ Datawow.document_verification
|
|
37
37
|
```
|
38
38
|
---
|
39
39
|
|
40
|
-
#### Video
|
40
|
+
#### Video class `Datawow.video_*`
|
41
41
|
There is 1 API for video class
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
Datawow.video_classification
|
45
45
|
```
|
46
46
|
---
|
47
|
-
#### Text
|
47
|
+
#### Text classes `Datawow.text_*`
|
48
48
|
There are 4 APIs for text class
|
49
49
|
|
50
50
|
```ruby
|
@@ -56,13 +56,22 @@ Datawow.text_ja
|
|
56
56
|
|
57
57
|
---
|
58
58
|
|
59
|
-
#### Prediction
|
60
|
-
There
|
59
|
+
#### Prediction class `Datawow.prediction`
|
60
|
+
There is 1 API for prediction class
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
Datawow.prediction
|
64
64
|
```
|
65
65
|
|
66
|
+
---
|
67
|
+
|
68
|
+
#### Moderation class `Datawow.moderation`
|
69
|
+
There is 1 API for moderation class
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
Datawow.moderation
|
73
|
+
```
|
74
|
+
|
66
75
|
Above methods are shortcuts for calling the following classes
|
67
76
|
```ruby
|
68
77
|
Datawow::ImageClosedQuestion
|
@@ -77,6 +86,7 @@ Datawow::TextConversation
|
|
77
86
|
Datawow::TextJa
|
78
87
|
Datawow::Prediction
|
79
88
|
Datawow::DocumentVerification
|
89
|
+
Datawow::Moderation
|
80
90
|
```
|
81
91
|
---
|
82
92
|
## Available methods in our APIs
|
@@ -199,3 +209,4 @@ end
|
|
199
209
|
- Video Documentation [link](README/video_docs.md)
|
200
210
|
- Text Documentation [link](README/text_docs.md)
|
201
211
|
- AI/Prediction Documentation [link](README/ai_docs.md)
|
212
|
+
- Moderation Documentation [link](README/moderation_docs.md)
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# Moderation class
|
2
|
+
|
3
|
+
We're going to explain about how to and example of usage
|
4
|
+
|
5
|
+
# Table of Content
|
6
|
+
- [How to use](#how-to-use)
|
7
|
+
- [Create](#create)
|
8
|
+
- [All](#all)
|
9
|
+
- [Find by](#find-by)
|
10
|
+
|
11
|
+
## How to Use
|
12
|
+
There are 3 methods available in moderation class (create, all, find_by). Each
|
13
|
+
method return a response of type `Datawow::Response`, which has two attributes,
|
14
|
+
`body` and `code`. You can simply access response's body by calling `.body`
|
15
|
+
|
16
|
+
### Create
|
17
|
+
```ruby
|
18
|
+
Datawow.project_key = YOUR_PROJECT_KEY
|
19
|
+
params = {
|
20
|
+
data: data,
|
21
|
+
postback_url: postback_url,
|
22
|
+
postback_method: postback_method,
|
23
|
+
custom_id: custom_id,
|
24
|
+
info: info,
|
25
|
+
sandbox: sandbox
|
26
|
+
}
|
27
|
+
Datawow.moderation.create(params)
|
28
|
+
```
|
29
|
+
|
30
|
+
`data` could be text or image's url depends on your project's input type
|
31
|
+
|
32
|
+
#### params
|
33
|
+
|
34
|
+
| Field | Type | Required | Description |
|
35
|
+
| ------------- |:-------------:| :-----:| :-----|
|
36
|
+
| data | string | **Yes** | URL of image |
|
37
|
+
| postback_url| string| No | URL for answer callback once image has been checked |
|
38
|
+
| postback_method| string | No | Configuration HTTP method GET POST PUT PATCH |
|
39
|
+
| custom_id | string | No | Custom ID that used for search |
|
40
|
+
| info | json | No | Additional info for Document Verification |
|
41
|
+
| sandbox | boolean | No | Moderate data using sandbox credit |
|
42
|
+
|
43
|
+
#### result
|
44
|
+
```
|
45
|
+
response = Datawow.moderation.create({
|
46
|
+
data: YOUR_DATA,
|
47
|
+
custom_id: 'data-1'
|
48
|
+
})
|
49
|
+
|
50
|
+
print(response.body)
|
51
|
+
```
|
52
|
+
You will receive response like below, once you created moderation successfully.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
{
|
56
|
+
"data" => {
|
57
|
+
"id" => "5dbab19ebbadfc32kefb56bf",
|
58
|
+
"type" => "moderation",
|
59
|
+
"attributes" => {
|
60
|
+
"custom_id" => "data-1",
|
61
|
+
"data" => YOUR_DATA,
|
62
|
+
"postback_url" => YOUR_POSTBACK_URL,
|
63
|
+
"postback_method" => YOUR_POSTBACK_METHOD,
|
64
|
+
"result" => nil,
|
65
|
+
"type" => YOUR_PROJECT_INPUT_TYPE, # your project's input type
|
66
|
+
"info" => {},
|
67
|
+
"created_at" => "2019-10-31T17:04:14.540+07:00",
|
68
|
+
"processed_at" => nil,
|
69
|
+
"status" => "unprocessed",
|
70
|
+
"dataset_id" => nil,
|
71
|
+
"id" => "5dbab19ebbadfc32kefb56bf",
|
72
|
+
"project_id" => YOUR_PROJECT_ID,
|
73
|
+
"sent_postback_yet" => false
|
74
|
+
}
|
75
|
+
},
|
76
|
+
"meta" => {
|
77
|
+
"code" => 201,
|
78
|
+
"message" => "Created"
|
79
|
+
}
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
### All
|
84
|
+
Method `all` is used to retrieve all of your moderations
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
Datawow.project_key = YOUR_PROJECT_KEY
|
88
|
+
Datawow.moderation.all
|
89
|
+
```
|
90
|
+
|
91
|
+
#### result
|
92
|
+
```ruby
|
93
|
+
{
|
94
|
+
"data" => [
|
95
|
+
{
|
96
|
+
"id" => "5dbab19ebbadfc32kefb56bf",
|
97
|
+
"type" => "moderation",
|
98
|
+
"attributes" => {
|
99
|
+
"custom_id" => "data-1",
|
100
|
+
"data" => YOUR_DATA,
|
101
|
+
"postback_url" => YOUR_POSTBACK_URL,
|
102
|
+
"postback_method" => YOUR_POSTBACK_METHOD,
|
103
|
+
"result" => {
|
104
|
+
"approved" => 0.97
|
105
|
+
},
|
106
|
+
"type" => YOUR_PROJECT_INPUT_TYPE,
|
107
|
+
"info" => {},
|
108
|
+
"created_at" => "2019-10-31T17:15:15.302+07:00",
|
109
|
+
"processed_at" => "2019-10-31T17:16:15.814+07:00",
|
110
|
+
"status" => "processed",
|
111
|
+
"dataset_id" => nil,
|
112
|
+
"id" => "5dbab19ebbadfc32kefb56bf",
|
113
|
+
"project_id" => YOUR_PROJECT_ID,
|
114
|
+
"sent_postback_yet" => false
|
115
|
+
}
|
116
|
+
}
|
117
|
+
],
|
118
|
+
"meta" => {
|
119
|
+
"code" => 200,
|
120
|
+
"message" => "OK"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
```
|
124
|
+
|
125
|
+
Fields `result` and `processed_at` will be present if your data was successfully processed.
|
126
|
+
|
127
|
+
### Find by
|
128
|
+
Method `find_by` is used to find a particular moderation. You can use either its
|
129
|
+
ID or Custom ID. This method will return only moderation with fully matched ID.
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
Datawow.project_key = YOUR_PROJECT_KEY
|
133
|
+
id = 'data-1' # or use an ID from creation response (example: '5dbab19ebbadfc32kefb56bf')
|
134
|
+
Datawow.moderation.find_by(id: id)
|
135
|
+
```
|
136
|
+
|
137
|
+
#### params
|
138
|
+
|
139
|
+
| Field | Type | Required | Description |
|
140
|
+
| ------------- |:-------------:| :-----:| :-----|
|
141
|
+
| id | string | **Yes** | ID or Custom ID of a moderation |
|
142
|
+
|
143
|
+
#### result
|
144
|
+
```ruby
|
145
|
+
{
|
146
|
+
"data" => {
|
147
|
+
"id" => "5dbab19ebbadfc32kefb56bf",
|
148
|
+
"type" => "moderation",
|
149
|
+
"attributes" => {
|
150
|
+
"custom_id" => "tp-1",
|
151
|
+
"data" => YOUR_DATA,
|
152
|
+
"postback_url" => YOUR_POSTBACK_URL,
|
153
|
+
"postback_method" => YOUR_POSTBACK_METHOD,
|
154
|
+
"result" => {
|
155
|
+
"approved" => 0.97
|
156
|
+
},
|
157
|
+
"type" => YOUR_PROJECT_INPUT_TYPE,
|
158
|
+
"info" => {},
|
159
|
+
"created_at" => "2019-10-31T17:04:14.540+07:00",
|
160
|
+
"processed_at" => "2019-10-31T17:05:16.243+07:00",
|
161
|
+
"status" => "processed",
|
162
|
+
"dataset_id" => nil,
|
163
|
+
"id" => "5dbab19ebbadfc32kefb56bf",
|
164
|
+
"project_id" => YOUR_PROJECT_ID,
|
165
|
+
"sent_postback_yet" => false
|
166
|
+
}
|
167
|
+
},
|
168
|
+
"meta" => {
|
169
|
+
"code" => 200,
|
170
|
+
"message" => "OK"
|
171
|
+
}
|
172
|
+
}
|
173
|
+
```
|
data/datawow.gemspec
CHANGED
@@ -5,8 +5,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'datawow'
|
8
|
-
s.version = '1.
|
9
|
-
s.date = '2019-
|
8
|
+
s.version = '1.5.0'
|
9
|
+
s.date = '2019-10-29'
|
10
10
|
s.summary = 'HTTP RESTFul for calling DataWow APIs'
|
11
11
|
s.description = 'Moderation suite'
|
12
12
|
s.post_install_message = File.read('INSTALL.md') if File.exist?('INSTALL.md')
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.email = 'ton@nanameue.jp'
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.homepage = 'https://datawow.io'
|
17
|
-
s.license = '
|
17
|
+
s.license = 'MIT'
|
18
18
|
s.require_paths = ['lib']
|
19
19
|
|
20
20
|
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
data/lib/datawow.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative 'datawow/response'
|
3
4
|
require_relative 'datawow/connector'
|
4
5
|
require_relative 'datawow/error'
|
@@ -13,6 +14,8 @@ require_relative 'datawow/models/images/nanameue_human'
|
|
13
14
|
require_relative 'datawow/models/images/document_verification'
|
14
15
|
require_relative 'datawow/models/predictions/predictors'
|
15
16
|
|
17
|
+
require_relative 'datawow/models/moderation'
|
18
|
+
|
16
19
|
require_relative 'datawow/models/texts/text_categories'
|
17
20
|
require_relative 'datawow/models/texts/text_closed_questions'
|
18
21
|
require_relative 'datawow/models/texts/text_conversations'
|
@@ -78,5 +81,9 @@ module Datawow
|
|
78
81
|
def document_verification
|
79
82
|
DocumentVerification.new
|
80
83
|
end
|
84
|
+
|
85
|
+
def moderation
|
86
|
+
Moderation.new
|
87
|
+
end
|
81
88
|
end
|
82
89
|
end
|
data/lib/datawow/connector.rb
CHANGED
@@ -100,10 +100,11 @@ module Datawow
|
|
100
100
|
|
101
101
|
def base_point(type)
|
102
102
|
{
|
103
|
-
image: 'https://
|
104
|
-
ai: 'https://
|
105
|
-
text: 'https://
|
106
|
-
video: 'https://
|
103
|
+
image: 'https://image.datawow.io/api',
|
104
|
+
ai: 'https://image.datawow.io/api',
|
105
|
+
text: 'https://text.datawow.io/api',
|
106
|
+
video: 'https://image.datawow.io/api',
|
107
|
+
moderation: 'https://api.datawow.io/api'
|
107
108
|
}[type]
|
108
109
|
end
|
109
110
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datawow
|
4
|
+
# :nodoc:
|
5
|
+
class Moderation
|
6
|
+
include Datawow::Models::Interface
|
7
|
+
|
8
|
+
attr_writer :project_key
|
9
|
+
|
10
|
+
def initialize(token = nil)
|
11
|
+
@project_key = token
|
12
|
+
@type = :moderation
|
13
|
+
@path = 'moderations'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/datawow/version.rb
CHANGED
@@ -5,7 +5,7 @@ require 'test_helper'
|
|
5
5
|
module Datawow
|
6
6
|
class ConnectorTest < Minitest::Test
|
7
7
|
def test_get_success
|
8
|
-
stub_request(:get, 'https://
|
8
|
+
stub_request(:get, 'https://image.datawow.io/api/v1/images')
|
9
9
|
.to_return(body: JSON.generate(data: 'foo', meta: { message: 'success', code: 200 }), status: 200)
|
10
10
|
response = connector.get
|
11
11
|
assert_instance_of(Response, response)
|
@@ -15,7 +15,7 @@ module Datawow
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_get_failed
|
18
|
-
stub_request(:get, 'https://
|
18
|
+
stub_request(:get, 'https://image.datawow.io/api/v1/images')
|
19
19
|
.to_return(body: JSON.generate(data: '', meta: { message: 'Internal Server Error', code: 500 }), status: 500)
|
20
20
|
response = connector.get
|
21
21
|
assert_instance_of(Response, response)
|
@@ -23,7 +23,7 @@ module Datawow
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_post_success
|
26
|
-
stub_request(:post, 'https://
|
26
|
+
stub_request(:post, 'https://image.datawow.io/api/v1/images')
|
27
27
|
.to_return(body: JSON.generate(data: 'foo', meta: { code: 200 }), status: 200)
|
28
28
|
response = connector.post
|
29
29
|
assert_instance_of(Response, response)
|
@@ -31,7 +31,7 @@ module Datawow
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_post_failed
|
34
|
-
stub_request(:post, 'https://
|
34
|
+
stub_request(:post, 'https://image.datawow.io/api/v1/images')
|
35
35
|
.to_return(body: JSON.generate(data: '', meta: { code: 500, message: 'Internal Server Error' }), status: 500)
|
36
36
|
response = connector.post
|
37
37
|
assert_instance_of(Response, response)
|
@@ -39,7 +39,7 @@ module Datawow
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_bad_request_status
|
42
|
-
stub_request(:get, 'https://
|
42
|
+
stub_request(:get, 'https://image.datawow.io/api/v1/images')
|
43
43
|
.to_return(status: 400, body: JSON.generate(data: '', meta: { message: 'bad request', code: 400 }))
|
44
44
|
response = connector.get
|
45
45
|
assert_instance_of(Response, response)
|
@@ -47,7 +47,7 @@ module Datawow
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_forbidden_status
|
50
|
-
stub_request(:get, 'https://
|
50
|
+
stub_request(:get, 'https://image.datawow.io/api/v1/images')
|
51
51
|
.to_return(body: JSON.generate(data: '', meta: { message: 'forbidden', code: 403 }), status: 403)
|
52
52
|
response = connector.get
|
53
53
|
assert_instance_of(Response, response)
|
@@ -55,7 +55,7 @@ module Datawow
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_not_found_status
|
58
|
-
stub_request(:get, 'https://
|
58
|
+
stub_request(:get, 'https://image.datawow.io/api/v1/images')
|
59
59
|
.to_return(body: JSON.generate(data: '', meta: { message: 'not found', code: 404 }), status: 404)
|
60
60
|
response = connector.get
|
61
61
|
assert_instance_of(Response, response)
|
@@ -63,7 +63,7 @@ module Datawow
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_edge_case_error
|
66
|
-
stub_request(:get, 'https://
|
66
|
+
stub_request(:get, 'https://image.datawow.io/api/v1/images')
|
67
67
|
.to_return(body: JSON.generate(data: '', meta: { message: 'version not supported', code: 505 }), status: 505)
|
68
68
|
response = connector.get
|
69
69
|
assert_instance_of(Response, response)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
module Datawow
|
6
|
+
class ModerationTest < TestBase
|
7
|
+
def test_all
|
8
|
+
stub_request(:get, MODERATION_URL)
|
9
|
+
.to_return(body: JSON.generate(@moderation_all), status: 200)
|
10
|
+
response = model.all
|
11
|
+
|
12
|
+
assert_instance_of(Response, response)
|
13
|
+
assert_equal(200, response.status)
|
14
|
+
refute_nil(response.data)
|
15
|
+
refute_nil(response.meta)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create
|
19
|
+
stub_request(:post, MODERATION_URL)
|
20
|
+
.to_return(body: JSON.generate(@moderation_create), status: 201)
|
21
|
+
response = model.create(options)
|
22
|
+
|
23
|
+
assert_instance_of(Response, response)
|
24
|
+
assert_equal(201, response.status)
|
25
|
+
refute_nil(response.data)
|
26
|
+
refute_nil(response.meta)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_find_by
|
30
|
+
stub_request(:get, "#{MODERATION_URL}?id=test")
|
31
|
+
.to_return(body: JSON.generate(@moderation_find_by), status: 200)
|
32
|
+
response = model.find_by(id: 'test')
|
33
|
+
|
34
|
+
assert_instance_of(Response, response)
|
35
|
+
assert_equal(200, response.status)
|
36
|
+
refute_nil(response.data)
|
37
|
+
refute_nil(response.meta)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def model
|
43
|
+
@model ||= Moderation.new('test')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"id": "5db6c2476ce1c068b2773ae6",
|
5
|
+
"type": "moderation",
|
6
|
+
"attributes": {
|
7
|
+
"custom_id": "test",
|
8
|
+
"data": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR83e5RhkOsU2wKswgQbrbR3LjtdTFjquXzmzKHt7q8kJemXoc4QA&s",
|
9
|
+
"postback_url": null,
|
10
|
+
"postback_method": "GET",
|
11
|
+
"result": null,
|
12
|
+
"type": "image",
|
13
|
+
"info": {},
|
14
|
+
"created_at": "2019-10-28T17:26:15.597+07:00",
|
15
|
+
"processed_at": null,
|
16
|
+
"status": "unprocessed",
|
17
|
+
"dataset_id": null,
|
18
|
+
"id": "5db6c2476ce1c068b2773ae6",
|
19
|
+
"project_id": 245,
|
20
|
+
"sent_postback_yet": false
|
21
|
+
}
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"id": "5db6c3a7bcbc136ac7c8ff6c",
|
25
|
+
"type": "moderation",
|
26
|
+
"attributes": {
|
27
|
+
"custom_id": null,
|
28
|
+
"data": "https://ae01.alicdn.com/kf/HTB1UdUBXdfvK1RjSszhq6AcGFXaW/shaonvmeiwu-Thin-translucent-lace-underwear-with-small-boobs-tucked-into-a-sexy-bra-with-three-rows.jpg",
|
29
|
+
"postback_url": null,
|
30
|
+
"postback_method": "GET",
|
31
|
+
"result": null,
|
32
|
+
"type": "image",
|
33
|
+
"info": {},
|
34
|
+
"created_at": "2019-10-28T17:32:07.251+07:00",
|
35
|
+
"processed_at": null,
|
36
|
+
"status": "unprocessed",
|
37
|
+
"dataset_id": null,
|
38
|
+
"id": "5db6c3a7bcbc136ac7c8ff6c",
|
39
|
+
"project_id": 245,
|
40
|
+
"sent_postback_yet": false
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"id": "5db7a2d9bcbc136ac9343da8",
|
45
|
+
"type": "moderation",
|
46
|
+
"attributes": {
|
47
|
+
"custom_id": null,
|
48
|
+
"data": "https://upload.wikimedia.org/wikipedia/commons/c/c5/Bikini_Model_Jassi_2.jpg",
|
49
|
+
"postback_url": null,
|
50
|
+
"postback_method": "GET",
|
51
|
+
"result": null,
|
52
|
+
"type": "image",
|
53
|
+
"info": {},
|
54
|
+
"created_at": "2019-10-29T09:24:25.725+07:00",
|
55
|
+
"processed_at": null,
|
56
|
+
"status": "unprocessed",
|
57
|
+
"dataset_id": null,
|
58
|
+
"id": "5db7a2d9bcbc136ac9343da8",
|
59
|
+
"project_id": 245,
|
60
|
+
"sent_postback_yet": false
|
61
|
+
}
|
62
|
+
}
|
63
|
+
],
|
64
|
+
"meta": {
|
65
|
+
"code": 200,
|
66
|
+
"message": "OK"
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"data": {
|
3
|
+
"id": "5db7a2d9bcbc136ac9343da8",
|
4
|
+
"type": "moderation",
|
5
|
+
"attributes": {
|
6
|
+
"custom_id": null,
|
7
|
+
"data": "https:upload.wikimedia.org/wikipedia/commons/c/c5/Bikini_Model_Jassi_2.jpg",
|
8
|
+
"postback_url": null,
|
9
|
+
"postback_method": "GET",
|
10
|
+
"result": null,
|
11
|
+
"type": "image",
|
12
|
+
"info": {},
|
13
|
+
"created_at": "2019-10-29T09::.725+07:",
|
14
|
+
"processed_at": null,
|
15
|
+
"status": "unprocessed",
|
16
|
+
"dataset_id": null,
|
17
|
+
"id": "5db7a2d9bcbc136ac9343da8",
|
18
|
+
"project_id": 245,
|
19
|
+
"sent_postback_yet": false
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"meta": {
|
23
|
+
"code": 201,
|
24
|
+
"message": "Created"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"data": {
|
3
|
+
"id": "5db6c2476ce1c068b2773ae6",
|
4
|
+
"type": "moderation",
|
5
|
+
"attributes": {
|
6
|
+
"custom_id": "test",
|
7
|
+
"data": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR83e5RhkOsU2wKswgQbrbR3LjtdTFjquXzmzKHt7q8kJemXoc4QA&s",
|
8
|
+
"postback_url": null,
|
9
|
+
"postback_method": "GET",
|
10
|
+
"result": null,
|
11
|
+
"type": "image",
|
12
|
+
"info": {},
|
13
|
+
"created_at": "2019-10-28T17:26:15.597+07:00",
|
14
|
+
"processed_at": null,
|
15
|
+
"status": "unprocessed",
|
16
|
+
"dataset_id": null,
|
17
|
+
"id": "5db6c2476ce1c068b2773ae6",
|
18
|
+
"project_id": 245,
|
19
|
+
"sent_postback_yet": false
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"meta": {
|
23
|
+
"code": 200,
|
24
|
+
"message": "OK"
|
25
|
+
}
|
26
|
+
}
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
2
4
|
require 'simplecov'
|
3
5
|
|
@@ -16,23 +18,24 @@ class TestBase < Minitest::Test
|
|
16
18
|
:text_closed_questions, :text_closed_question, :nanameue_human, :nanameue_humans,
|
17
19
|
:text_ja, :text_jas, :image_document_verifications, :image_document_verification
|
18
20
|
|
19
|
-
IMAGE_CHOICES_URL = 'https://
|
20
|
-
IMAGE_CHOICE_URL = 'https://
|
21
|
-
IMAGE_CLOSED_QUESTIONS_URL = 'https://
|
22
|
-
IMAGE_CLOSED_QUESTION_URL = 'https://
|
23
|
-
IMAGE_MESSAGES_URL = 'https://
|
24
|
-
IMAGE_MESSAGE_URL = 'https://
|
25
|
-
IMAGE_PHOTO_TAGS = 'https://
|
26
|
-
IMAGE_PHOTO_TAG = 'https://
|
27
|
-
IMAGE_DOCUMENT_VERIFICATION_URL = 'https://
|
28
|
-
PREDICTIONS_URL = 'https://
|
29
|
-
IMAGE_URL = 'https://
|
30
|
-
VIDEO_URL = 'https://
|
31
|
-
NANAMEUE_HUMAN_URL = 'https://
|
32
|
-
TEXT_CATEGORY_URL = 'https://
|
33
|
-
TEXT_CONVERSATION_URL = 'https://
|
34
|
-
TEXT_CLOSED_QUESTION_URL = 'https://
|
35
|
-
TEXT_JA_URL = 'https://
|
21
|
+
IMAGE_CHOICES_URL = 'https://image.datawow.io/api/v1/images/choices'
|
22
|
+
IMAGE_CHOICE_URL = 'https://image.datawow.io/api/v1/images/choice'
|
23
|
+
IMAGE_CLOSED_QUESTIONS_URL = 'https://image.datawow.io/api/v1/images/closed_questions'
|
24
|
+
IMAGE_CLOSED_QUESTION_URL = 'https://image.datawow.io/api/v1/images/closed_question'
|
25
|
+
IMAGE_MESSAGES_URL = 'https://image.datawow.io/api/v1/images/messages'
|
26
|
+
IMAGE_MESSAGE_URL = 'https://image.datawow.io/api/v1/images/message'
|
27
|
+
IMAGE_PHOTO_TAGS = 'https://image.datawow.io/api/v1/images/photo_tags'
|
28
|
+
IMAGE_PHOTO_TAG = 'https://image.datawow.io/api/v1/images/photo_tag'
|
29
|
+
IMAGE_DOCUMENT_VERIFICATION_URL = 'https://image.datawow.io/api/v1/images/document_verifications'
|
30
|
+
PREDICTIONS_URL = 'https://image.datawow.io/api/v1/prime/predictions'
|
31
|
+
IMAGE_URL = 'https://image.datawow.io/api/v1/projects/images'
|
32
|
+
VIDEO_URL = 'https://image.datawow.io/api/v1/videos/closed_questions'
|
33
|
+
NANAMEUE_HUMAN_URL = 'https://image.datawow.io/api/v1/jobs/nanameue/consensuses'
|
34
|
+
TEXT_CATEGORY_URL = 'https://text.datawow.io/api/v1/text/text_categories'
|
35
|
+
TEXT_CONVERSATION_URL = 'https://text.datawow.io/api/v1/text/text_conversations'
|
36
|
+
TEXT_CLOSED_QUESTION_URL = 'https://text.datawow.io/api/v1/text/text_closed_questions'
|
37
|
+
TEXT_JA_URL = 'https://text.datawow.io/api/v1/text_ai/text_ja'
|
38
|
+
MODERATION_URL = 'https://api.datawow.io/api/v1/moderations'
|
36
39
|
|
37
40
|
def setup
|
38
41
|
@image_choices = FileReader.new('test/fixtures/image_choice/all.json').read_json
|
@@ -59,6 +62,9 @@ class TestBase < Minitest::Test
|
|
59
62
|
@text_closed_questions = FileReader.new('test/fixtures/text_closed_question/all.json').read_json
|
60
63
|
@text_ja = FileReader.new('test/fixtures/text_ja/create.json').read_json
|
61
64
|
@text_jas = FileReader.new('test/fixtures/text_ja/all.json').read_json
|
65
|
+
@moderation_all = FileReader.new('test/fixtures/moderation/all.json').read_json
|
66
|
+
@moderation_create = FileReader.new('test/fixtures/moderation/create.json').read_json
|
67
|
+
@moderation_find_by = FileReader.new('test/fixtures/moderation/find_by.json').read_json
|
62
68
|
@options = {
|
63
69
|
token: 'project token'
|
64
70
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datawow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesdakorn Samittiauttakorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- README.md
|
107
107
|
- README/ai_docs.md
|
108
108
|
- README/image_docs.md
|
109
|
+
- README/moderation_docs.md
|
109
110
|
- README/text_docs.md
|
110
111
|
- README/video_docs.md
|
111
112
|
- Rakefile
|
@@ -120,6 +121,7 @@ files:
|
|
120
121
|
- lib/datawow/models/images/image_photo_tags.rb
|
121
122
|
- lib/datawow/models/images/nanameue_human.rb
|
122
123
|
- lib/datawow/models/interface.rb
|
124
|
+
- lib/datawow/models/moderation.rb
|
123
125
|
- lib/datawow/models/predictions/predictors.rb
|
124
126
|
- lib/datawow/models/texts/text_categories.rb
|
125
127
|
- lib/datawow/models/texts/text_closed_questions.rb
|
@@ -136,6 +138,7 @@ files:
|
|
136
138
|
- test/datawow/image_document_verification_test.rb
|
137
139
|
- test/datawow/image_messages_test.rb
|
138
140
|
- test/datawow/image_photo_tags_test.rb
|
141
|
+
- test/datawow/moderation_test.rb
|
139
142
|
- test/datawow/nanameue_human_test.rb
|
140
143
|
- test/datawow/predictors_test.rb
|
141
144
|
- test/datawow/response_test.rb
|
@@ -155,6 +158,9 @@ files:
|
|
155
158
|
- test/fixtures/image_message/create.json
|
156
159
|
- test/fixtures/image_photo_tag/all.json
|
157
160
|
- test/fixtures/image_photo_tag/create.json
|
161
|
+
- test/fixtures/moderation/all.json
|
162
|
+
- test/fixtures/moderation/create.json
|
163
|
+
- test/fixtures/moderation/find_by.json
|
158
164
|
- test/fixtures/nanameue_human/all.json
|
159
165
|
- test/fixtures/nanameue_human/create.json
|
160
166
|
- test/fixtures/prediction/all.json
|
@@ -173,7 +179,7 @@ files:
|
|
173
179
|
- test/test_helper.rb
|
174
180
|
homepage: https://datawow.io
|
175
181
|
licenses:
|
176
|
-
-
|
182
|
+
- MIT
|
177
183
|
metadata: {}
|
178
184
|
post_install_message: |
|
179
185
|
After install datawow
|