datawow 1.2.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 +7 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +59 -0
- data/INSTALL.md +7 -0
- data/README/ai_docs.md +153 -0
- data/README/image_docs.md +119 -0
- data/README/text_docs.md +83 -0
- data/README/video_docs.md +53 -0
- data/README.md +160 -0
- data/Rakefile +12 -0
- data/datawow.gemspec +28 -0
- data/lib/datawow/client_response.rb +18 -0
- data/lib/datawow/connection.rb +99 -0
- data/lib/datawow/connector.rb +118 -0
- data/lib/datawow/error.rb +15 -0
- data/lib/datawow/faraday/raise_http_exception.rb +40 -0
- data/lib/datawow/models/images/image_choices.rb +16 -0
- data/lib/datawow/models/images/image_closed_questions.rb +16 -0
- data/lib/datawow/models/images/image_messages.rb +16 -0
- data/lib/datawow/models/images/image_photo_tags.rb +16 -0
- data/lib/datawow/models/images/nanameue_human.rb +16 -0
- data/lib/datawow/models/interface.rb +26 -0
- data/lib/datawow/models/predictions/predictors.rb +18 -0
- data/lib/datawow/models/texts/text_categories.rb +16 -0
- data/lib/datawow/models/texts/text_closed_questions.rb +16 -0
- data/lib/datawow/models/texts/text_conversations.rb +16 -0
- data/lib/datawow/models/videos/video_classifications.rb +17 -0
- data/lib/datawow/version.rb +3 -0
- data/lib/datawow.rb +75 -0
- data/lib/generators/datawow/install_generator.rb +18 -0
- data/lib/generators/templates/datawow_api.rb +5 -0
- data/test/datawow/client_response_test.rb +29 -0
- data/test/datawow/connection_test.rb +85 -0
- data/test/datawow/connector_test.rb +79 -0
- data/test/datawow/image_choices_test.rb +48 -0
- data/test/datawow/image_closed_questions_test.rb +47 -0
- data/test/datawow/image_messages_test.rb +48 -0
- data/test/datawow/image_photo_tags_test.rb +48 -0
- data/test/datawow/nanameue_human_test.rb +47 -0
- data/test/datawow/predictors_test.rb +48 -0
- data/test/datawow/text_categories_test.rb +48 -0
- data/test/datawow/text_closed_questions_test.rb +48 -0
- data/test/datawow/text_conversations_test.rb +48 -0
- data/test/datawow/video_classifications_test.rb +48 -0
- data/test/datawow_test.rb +34 -0
- data/test/fixtures/image_choice/all.json +27 -0
- data/test/fixtures/image_choice/create.json +25 -0
- data/test/fixtures/image_closed_question/all.json +21 -0
- data/test/fixtures/image_closed_question/create.json +19 -0
- data/test/fixtures/image_message/all.json +22 -0
- data/test/fixtures/image_message/create.json +20 -0
- data/test/fixtures/image_photo_tag/all.json +22 -0
- data/test/fixtures/image_photo_tag/create.json +20 -0
- data/test/fixtures/nanameue_human/all.json +25 -0
- data/test/fixtures/nanameue_human/create.json +21 -0
- data/test/fixtures/prediction/all.json +21 -0
- data/test/fixtures/prediction/create.json +19 -0
- data/test/fixtures/text_category/all.json +34 -0
- data/test/fixtures/text_category/create.json +27 -0
- data/test/fixtures/text_closed_question/all.json +27 -0
- data/test/fixtures/text_closed_question/create.json +20 -0
- data/test/fixtures/text_conversation/all.json +33 -0
- data/test/fixtures/text_conversation/create.json +26 -0
- data/test/fixtures/video_classification/all.json +21 -0
- data/test/fixtures/video_classification/create.json +19 -0
- data/test/helper/file_reader.rb +11 -0
- data/test/test_helper.rb +59 -0
- metadata +254 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2ab7e943518feee57c144e25d9f384a3336dea35767a70857e98689833d6f26f
|
4
|
+
data.tar.gz: 57eb64866865b7e7d35a6f1e23be00cbd6de32b48f09a423a312173d7a94df28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63e3ab17bd9b5163934a30dd4b29acc6980f2416b48bd680d8533a88876dd243cc3ef40e4510b601b094949786fed7acf1051ad364bbfc2ff073ba811644e82d
|
7
|
+
data.tar.gz: 903c6b7a47a6c8aa6003358f8dfcce8e1d2342f2fe1528ab4eb12c53177ebbe785d6aaad7e219ee447f0f0c0c6c4b0088dda3d4861629ebe880e56f673e323f1
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
coverage
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
datawow (1.2.0)
|
5
|
+
faraday (~> 0.13.1, >= 0.13.1)
|
6
|
+
faraday_middleware (~> 0.12.2, >= 0.12.2)
|
7
|
+
json (~> 1.8, >= 1.8.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
14
|
+
byebug (10.0.2)
|
15
|
+
coderay (1.1.2)
|
16
|
+
crack (0.4.3)
|
17
|
+
safe_yaml (~> 1.0.0)
|
18
|
+
docile (1.1.5)
|
19
|
+
faraday (0.13.1)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
faraday_middleware (0.12.2)
|
22
|
+
faraday (>= 0.7.4, < 1.0)
|
23
|
+
hashdiff (0.3.7)
|
24
|
+
json (1.8.6)
|
25
|
+
method_source (0.9.2)
|
26
|
+
minitest (5.11.3)
|
27
|
+
multipart-post (2.0.0)
|
28
|
+
pry (0.12.2)
|
29
|
+
coderay (~> 1.1.0)
|
30
|
+
method_source (~> 0.9.0)
|
31
|
+
pry-byebug (3.6.0)
|
32
|
+
byebug (~> 10.0)
|
33
|
+
pry (~> 0.10)
|
34
|
+
public_suffix (3.0.3)
|
35
|
+
rake (12.3.1)
|
36
|
+
safe_yaml (1.0.4)
|
37
|
+
simplecov (0.15.1)
|
38
|
+
docile (~> 1.1.0)
|
39
|
+
json (>= 1.8, < 3)
|
40
|
+
simplecov-html (~> 0.10.0)
|
41
|
+
simplecov-html (0.10.2)
|
42
|
+
webmock (3.4.2)
|
43
|
+
addressable (>= 2.3.6)
|
44
|
+
crack (>= 0.3.2)
|
45
|
+
hashdiff
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
datawow!
|
52
|
+
minitest (~> 5.11, >= 5.11.3)
|
53
|
+
pry-byebug (~> 3.6)
|
54
|
+
rake (~> 12.3)
|
55
|
+
simplecov (~> 0.15.1)
|
56
|
+
webmock (~> 3.3)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
1.17.1
|
data/INSTALL.md
ADDED
data/README/ai_docs.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
# Table of Content
|
2
|
+
- [How to use it](#create)
|
3
|
+
#### [Type of AI](#response-of-each-type-ai)
|
4
|
+
- [Standard Criteria](#standard-criteria)
|
5
|
+
- [Nudity/Sexual](#nuditysexual)
|
6
|
+
- [Demographic](#demographic)
|
7
|
+
- [Standard Criteria & Human](#standard-criteria--human)
|
8
|
+
- [Common function](#common-function)
|
9
|
+
|
10
|
+
### Prediction Images (AI Beta / 95% accuracy)
|
11
|
+
- [nanameue]Standard Criteria (~1 min)
|
12
|
+
- [sexual]Nudity/Sexual (~1 min)
|
13
|
+
- [demographic]Demographic (~3 mins)
|
14
|
+
- [ai_human]Standard Criteria & Human
|
15
|
+
|
16
|
+
#### Create prediction
|
17
|
+
**Note**: For creation of prediction, a type of AI will be separated by token. Once, you sent request to server your token will be used for find AI'type automatically and you will get response upon your token type
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
params = { ..., token: '_token' }
|
21
|
+
Datawow.prediction.create(params)
|
22
|
+
```
|
23
|
+
#### params
|
24
|
+
| Field | Type | Required | Description |
|
25
|
+
| ------------- |:-------------:| :-----:| :-----|
|
26
|
+
| data | string | Yes |Data for attachment|
|
27
|
+
| postback_url | string | No | Image postback url|
|
28
|
+
| postback_method | string | No |Postback method|
|
29
|
+
| custom_id | string | No |Custom's id|
|
30
|
+
|
31
|
+
## Response of each type AI
|
32
|
+
#### [nanameue]Standard Criteria (~1 min)
|
33
|
+
```json
|
34
|
+
{
|
35
|
+
"data": {
|
36
|
+
"id": "5a41c388aa05617baa283457",
|
37
|
+
"answer": nil,
|
38
|
+
"credit_charged": 0,
|
39
|
+
"custom_id": "custom_id",
|
40
|
+
"data": "image_url",
|
41
|
+
"postback_url": "https://example.com/callbacks",
|
42
|
+
"processed_at": nil,
|
43
|
+
"project_id": "project_id",
|
44
|
+
"status": "processing"
|
45
|
+
},
|
46
|
+
"success": true,
|
47
|
+
"status": 200,
|
48
|
+
"message": "success",
|
49
|
+
"meta": {
|
50
|
+
"code": 200,
|
51
|
+
"message": "success"
|
52
|
+
}
|
53
|
+
}
|
54
|
+
```
|
55
|
+
---
|
56
|
+
#### [sexual]Nudity/Sexual (~1 min)
|
57
|
+
```json
|
58
|
+
{
|
59
|
+
"data": {
|
60
|
+
"id": "5a41ce6eaa05617baa2836aa",
|
61
|
+
"answer": nil,
|
62
|
+
"credit_charged": 0,
|
63
|
+
"custom_id": "custom_id",
|
64
|
+
"data": "image_url",
|
65
|
+
"postback_url": "https://example.com/callbacks",
|
66
|
+
"processed_at": nil,
|
67
|
+
"project_id": "project_id",
|
68
|
+
"status": "processing"
|
69
|
+
},
|
70
|
+
"success": true,
|
71
|
+
"status": 200,
|
72
|
+
"message": "success",
|
73
|
+
"meta": {
|
74
|
+
"code": 200,
|
75
|
+
"message": "success"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
```
|
79
|
+
---
|
80
|
+
#### [demographic]Demographic (~3 mins)
|
81
|
+
```json
|
82
|
+
{
|
83
|
+
"data": {
|
84
|
+
"id": "5a41d011fb9d7f273a75a62d",
|
85
|
+
"answer": nil,
|
86
|
+
"credit_charged": 0,
|
87
|
+
"custom_id": "custom_id",
|
88
|
+
"data": "image_url",
|
89
|
+
"postback_url": "https://example.com/callbacks",
|
90
|
+
"processed_at": nil,
|
91
|
+
"project_id": "project_id",
|
92
|
+
"status": "processing"
|
93
|
+
},
|
94
|
+
"success": true,
|
95
|
+
"status": 200,
|
96
|
+
"message": "success",
|
97
|
+
"meta": {
|
98
|
+
"code": 200,
|
99
|
+
"message": "success"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
```
|
103
|
+
---
|
104
|
+
#### [ai_human]Standard Criteria & Human
|
105
|
+
```json
|
106
|
+
{
|
107
|
+
"data": {
|
108
|
+
"id": "5a41d10efb9d7f27354c8963",
|
109
|
+
"answer": nil,
|
110
|
+
"credit_charged": 0,
|
111
|
+
"custom_id": "custom_id",
|
112
|
+
"data": "image_url",
|
113
|
+
"postback_url": "https://example.com/callbacks",
|
114
|
+
"processed_at": nil,
|
115
|
+
"project_id": "project_id",
|
116
|
+
"status": "processing"
|
117
|
+
},
|
118
|
+
"success": true,
|
119
|
+
"status": 200,
|
120
|
+
"message": "success",
|
121
|
+
"meta": {
|
122
|
+
"code": 200,
|
123
|
+
"message": "success"
|
124
|
+
}
|
125
|
+
}
|
126
|
+
```
|
127
|
+
---
|
128
|
+
|
129
|
+
# Common function
|
130
|
+
For every classes there are common functions to get list of data and find by ID. We're going to show you how to use it.
|
131
|
+
|
132
|
+
## Query list of data by `all()`
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
params = { ..., token: '_token' }
|
136
|
+
Datawow.[model].all(params)
|
137
|
+
```
|
138
|
+
#### params
|
139
|
+
| Field | Type | Required | Description |
|
140
|
+
| ------------- |:-------------:| :-----:| :-----|
|
141
|
+
| page | interger | No | default 0|
|
142
|
+
| per_page | string | No | default 20 |
|
143
|
+
|
144
|
+
|
145
|
+
## Find data with ID by `find_by()`
|
146
|
+
```ruby
|
147
|
+
params = { id: '_id', token: '_token' }
|
148
|
+
Datawow.[model].find_by(params)
|
149
|
+
```
|
150
|
+
#### params
|
151
|
+
| Field | Type | Required | Description |
|
152
|
+
| ------------- |:-------------:| :----:| :-----|
|
153
|
+
| id | string | **Yes** | Image's ID or custom ID which is you were assigned|
|
@@ -0,0 +1,119 @@
|
|
1
|
+
## Images class
|
2
|
+
|
3
|
+
We're going to explant about parameter for creation and example of use
|
4
|
+
|
5
|
+
# Table of Content
|
6
|
+
- [Choice class](#choice-class)
|
7
|
+
- [Closed Question class](#closed-question-class)
|
8
|
+
- [Image message class](#image-messages-class)
|
9
|
+
- [Photo tags class](#photo-tags-class)
|
10
|
+
- [Common function](#common-function)
|
11
|
+
|
12
|
+
## Choice class
|
13
|
+
Description: Yes or No Question from Image (30 mins response time) - This model used for create select list on a moderator screen and let's they answer your question on what they're seeing. Answer can be only one or multiple choice
|
14
|
+
|
15
|
+
#### Create
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
params = { ..., token: '_token' }
|
19
|
+
Datawow.image_choice.create(params)
|
20
|
+
```
|
21
|
+
#### params
|
22
|
+
|
23
|
+
|Field | Type | Required | Description |
|
24
|
+
| ------------- |:-------------:| :-----:| :-----|
|
25
|
+
| instruction| string|**Yes**| Tell moderator what answer you expected and what image is|
|
26
|
+
|categories | Array[string]|**Yes** | List of answers that you were expected. sparate by use space |
|
27
|
+
| data |string | **Yes** |URL of image|
|
28
|
+
| postback_url| string|No| URL for answer callback once image has been checked|
|
29
|
+
| postback_method|string | No |Configuration HTTP method GET POST PUT PATCH|
|
30
|
+
| allow_empty| boolean|No|Allow answer can be blank. default is `false`|
|
31
|
+
|multiple | boolean | No | Configuration for multiple selection of category to answer default is `false` |
|
32
|
+
| custom_id | string | No |Custom ID that used for search|
|
33
|
+
---
|
34
|
+
|
35
|
+
|
36
|
+
## Closed Question class
|
37
|
+
Description: Standard Criteria (5 mins response time) - Answer can be only approved, declined or ban
|
38
|
+
### Create
|
39
|
+
```ruby
|
40
|
+
params = { ..., token: '_token' }
|
41
|
+
Datawow.image_closed_question.create(params)
|
42
|
+
```
|
43
|
+
#### params
|
44
|
+
| Field | Type | Required | Description |
|
45
|
+
| ------------- |:-------------:| :-----:| :-----|
|
46
|
+
| data | string | **Yes** |URL of image|
|
47
|
+
| postback_url | string | No | URL for answer callback once image has been checked|
|
48
|
+
| postback_method | string | No |Configuration HTTP method GET POST PUT PATCH|
|
49
|
+
| custom_id | string | No |Custom ID that used for search|
|
50
|
+
---
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## Image messages class
|
55
|
+
Description: Message Question from Image (30 mins response time) - Allow a moderator to typing a answer on what they're seeing.
|
56
|
+
|
57
|
+
### Create
|
58
|
+
```ruby
|
59
|
+
params = { ..., token: '_token' }
|
60
|
+
Datawow.image_message.create(params)
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
#### params
|
65
|
+
| Field | Type | Required | Description |
|
66
|
+
| ------------- |:-------------:| :-----:| :-----|
|
67
|
+
| instruction | string | **Yes** | Tell moderator what answer you expected and what image is|
|
68
|
+
| data | string | **Yes** |URL of image|
|
69
|
+
| postback_url | string | No | URL for answer callback once image has been checked|
|
70
|
+
| postback_method | string | No |Configuration HTTP method GET POST PUT PATCH|
|
71
|
+
| custom_id | string | No |Custom ID that used for search|
|
72
|
+
|
73
|
+
---
|
74
|
+
|
75
|
+
|
76
|
+
## Photo tags class
|
77
|
+
Description: Identifying an object in the image (60 mins response time) - This model is used for identifying the object within the hand drawn rectangle from the moderator, following any instructions given by the customer.
|
78
|
+
|
79
|
+
### Create
|
80
|
+
```python
|
81
|
+
>>> from datawow.images import PhotoTag as photo_tag
|
82
|
+
>>> result = photo_tag("PROJECT KEY").create(params=param)
|
83
|
+
```
|
84
|
+
|
85
|
+
#### params
|
86
|
+
| Field | Type| Required | Description |
|
87
|
+
| ------------- |:-------------:| :-----:| :-----|
|
88
|
+
|instruction| string|**Yes** |Tell moderator what answer you expected and what image is|
|
89
|
+
|data|string| **Yes** |URL of image|
|
90
|
+
|postback_url|string| No |URL for answer callback once image has been checked|
|
91
|
+
|postback_method|string | No |Configuration HTTP method GET POST PUT PATCH|
|
92
|
+
|custom_id|string|No|Custom ID that used for search|
|
93
|
+
|
94
|
+
---
|
95
|
+
# Common function
|
96
|
+
For every classes there are common functions to get list of data and find by ID. We're going to show you how to use it.
|
97
|
+
|
98
|
+
## Query list of data by `all()`
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
params = { ..., token: '_token' }
|
102
|
+
Datawow.[model].all(params)
|
103
|
+
```
|
104
|
+
#### params
|
105
|
+
| Field | Type | Required | Description |
|
106
|
+
| ------------- |:-------------:| :-----:| :-----|
|
107
|
+
| page | interger | No | default 0|
|
108
|
+
| per_page | string | No | default 20 |
|
109
|
+
|
110
|
+
|
111
|
+
## Find data with ID by `find_by()`
|
112
|
+
```ruby
|
113
|
+
params = { id: '_id', token: '_token' }
|
114
|
+
Datawow.[model].find_by(params)
|
115
|
+
```
|
116
|
+
#### params
|
117
|
+
| Field | Type | Required | Description |
|
118
|
+
| ------------- |:-------------:| :----:| :-----|
|
119
|
+
| id | string | **Yes** | Image's ID or custom ID which is you were assigned|
|
data/README/text_docs.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
## Texts class
|
2
|
+
|
3
|
+
We're going to explant about parameter for creation and example of use
|
4
|
+
|
5
|
+
# Table of Content
|
6
|
+
- [Category class](#category-class)
|
7
|
+
- [Closed Question class](#closed-question-class)
|
8
|
+
- [Conversation class](#conversation-class)
|
9
|
+
- [Common function](#common-function)
|
10
|
+
|
11
|
+
|
12
|
+
## Category class
|
13
|
+
Description: Classify type in many level of category type
|
14
|
+
```ruby
|
15
|
+
params = { ..., token: '_token' }
|
16
|
+
Datawow.text_category.create(params)
|
17
|
+
```
|
18
|
+
|
19
|
+
|Field | Type | Required | Description |
|
20
|
+
| ------------- |:-------------:| :-----:| :-----|
|
21
|
+
| conversation| array of dict|**Yes**| Example: `[{ "name": "...", "message": "..." }]`|
|
22
|
+
|title|string|**Yes**|Title of conversation|
|
23
|
+
|allow_empty |bool| |No|Answer can be empty|
|
24
|
+
|postback_url|string|No|URL for callback|
|
25
|
+
|postback_method| string|No| Configuration HTTP method GET POST PUT PATCH|
|
26
|
+
|custom_id| string|No| Custom ID that used for search|
|
27
|
+
|
28
|
+
|
29
|
+
## Closed Question class
|
30
|
+
Description: Classify inappropriate conversation
|
31
|
+
```ruby
|
32
|
+
params = { ..., token: '_token' }
|
33
|
+
Datawow.text_closed_question.create(params)
|
34
|
+
```
|
35
|
+
|
36
|
+
|Field | Type | Required | Description |
|
37
|
+
| ------------- |:-------------:| :-----:| :-----|
|
38
|
+
|data|string|**Yes**|Stream of text to moderate|
|
39
|
+
|postback_url|string|No|URL for callback|
|
40
|
+
|postback_method| string|No| Configuration HTTP method GET POST PUT PATCH|
|
41
|
+
|custom_id| string|No| Custom ID that used for search|
|
42
|
+
|
43
|
+
|
44
|
+
## Conversation class
|
45
|
+
Description: Classify conversation
|
46
|
+
```ruby
|
47
|
+
params = { ..., token: '_token' }
|
48
|
+
Datawow.text_conversation.create(params)
|
49
|
+
```
|
50
|
+
|
51
|
+
|Field | Type | Required | Description |
|
52
|
+
| ------------- |:-------------:| :-----:| :-----|
|
53
|
+
|conversation| array of dict|**Yes**| Example: `["foo", "bar"]`|
|
54
|
+
|custom_conversation_ids|string|**Yes**|Example: `['1','2']`|
|
55
|
+
|postback_url|string|No|URL for callback|
|
56
|
+
|postback_method| string|No| Configuration HTTP method GET POST PUT PATCH|
|
57
|
+
|custom_id| string|No| Custom ID that used for search|
|
58
|
+
|
59
|
+
# Common function
|
60
|
+
For every classes there are common functions to get list of data and find by ID. We're going to show you how to use it.
|
61
|
+
|
62
|
+
## Query list of data by `all()`
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
params = { ..., token: '_token' }
|
66
|
+
Datawow.[model].all(params)
|
67
|
+
```
|
68
|
+
#### params
|
69
|
+
| Field | Type | Required | Description |
|
70
|
+
| ------------- |:-------------:| :-----:| :-----|
|
71
|
+
| page | interger | No | default 0|
|
72
|
+
| per_page | string | No | default 20 |
|
73
|
+
|
74
|
+
|
75
|
+
## Find data with ID by `find_id()`
|
76
|
+
```ruby
|
77
|
+
params = { id: '_id', token: '_token' }
|
78
|
+
Datawow.[model].find_by(params)
|
79
|
+
```
|
80
|
+
#### params
|
81
|
+
| Field | Type | Required | Description |
|
82
|
+
| ------------- |:-------------:| :----:| :-----|
|
83
|
+
| id | string | **Yes** | Text's ID or custom ID which is you were assigned|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
## Videos class
|
2
|
+
|
3
|
+
We're going to explant about parameter for creation and example of use
|
4
|
+
|
5
|
+
# Table of Content
|
6
|
+
- [Video classification class](#video-classification-class)
|
7
|
+
- [Common function](#common-function)
|
8
|
+
|
9
|
+
## Video Classification class
|
10
|
+
Description: Video classification - Answer can be only approved, declined or ban
|
11
|
+
### Create
|
12
|
+
```ruby
|
13
|
+
params = { ..., token: '_token' }
|
14
|
+
Datawow.video_classification.create(params)
|
15
|
+
```
|
16
|
+
|
17
|
+
#### params
|
18
|
+
| Field | Type | Required | Description |
|
19
|
+
| ------------- |:-------------:| :-----:| :-----|
|
20
|
+
| data | string | **Yes** |URL of Video|
|
21
|
+
| play_at | float |No |Setting video start time|
|
22
|
+
| allow_seeking |bool| No |Allow seeking video player (default `true`)|
|
23
|
+
|muted |bool|No| Mute video on start (default: `true`)|
|
24
|
+
| postback_url | string | No | URL for answer callback once video has been checked|
|
25
|
+
| postback_method | string | No |Configuration HTTP method GET POST PUT PATCH|
|
26
|
+
| custom_id | string | No |Custom ID that used for search|
|
27
|
+
|
28
|
+
---
|
29
|
+
# Common function
|
30
|
+
For every classes there are common functions to get list of data and find by ID. We're going to show you how to use it.
|
31
|
+
|
32
|
+
## Query list of data by `all()`
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
params = { ..., token: '_token' }
|
36
|
+
Datawow.[model].all(params)
|
37
|
+
```
|
38
|
+
#### params
|
39
|
+
| Field | Type | Required | Description |
|
40
|
+
| ------------- |:-------------:| :-----:| :-----|
|
41
|
+
| page | interger | No | default 0|
|
42
|
+
| per_page | string | No | default 20 |
|
43
|
+
|
44
|
+
|
45
|
+
## Find data with ID by `find_by()`
|
46
|
+
```ruby
|
47
|
+
params = { id: '_id', token: '_token' }
|
48
|
+
Datawow.[model].find_by(params)
|
49
|
+
```
|
50
|
+
#### params
|
51
|
+
| Field | Type | Required | Description |
|
52
|
+
| ------------- |:-------------:| :----:| :-----|
|
53
|
+
| id | string | **Yes** | Video's ID or custom ID which is you were assigned|
|
data/README.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# Datawow-ruby
|
2
|
+
|
3
|
+
HTTP RESTFul for calling DataWow APIs
|
4
|
+
|
5
|
+
###### support or question support@datawow.io
|
6
|
+
|
7
|
+
# Installation
|
8
|
+
```ruby
|
9
|
+
gem 'datawow', '~> 1.2.0'
|
10
|
+
```
|
11
|
+
|
12
|
+
#### Generate setting
|
13
|
+
|
14
|
+
```console
|
15
|
+
$ rails generate datawow:install
|
16
|
+
```
|
17
|
+
The generator will install an initializer which describes ALL of library's configuration options. It is *imperative* that you take a look at it. When you are done, you are ready to call it to any of your codes.
|
18
|
+
|
19
|
+
**Note**: Our library work with Rails 4.1 or above
|
20
|
+
|
21
|
+
# Usage
|
22
|
+
|
23
|
+
To call our module use `Datawow` and follow by class of APIs which we're going to explain what API we have
|
24
|
+
|
25
|
+
## Class explanation
|
26
|
+
#### Image classe `Datawow.image_*`
|
27
|
+
There are 4 APIs for image class
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Datawow.image_closed_question
|
31
|
+
Datawow.image_photo_tag
|
32
|
+
Datawow.image_choice
|
33
|
+
Datawow.image_message
|
34
|
+
```
|
35
|
+
---
|
36
|
+
|
37
|
+
#### Video classe `Datawow.video_*`
|
38
|
+
There is 1 API for video class
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Datawow.video_classification
|
42
|
+
```
|
43
|
+
---
|
44
|
+
#### Text classe `Datawow.text_*`
|
45
|
+
There are 3 APIs for text class
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
Datawow.text_closed_question
|
49
|
+
Datawow.text_category
|
50
|
+
Datawow.text_conversation
|
51
|
+
```
|
52
|
+
---
|
53
|
+
|
54
|
+
#### Prediction classe `Datawow.prediction`
|
55
|
+
There are 1 API for prediction class
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Datawow.prediction
|
59
|
+
```
|
60
|
+
---
|
61
|
+
## Calling APIs
|
62
|
+
Every classes there are 3 function that is `create`, `find_by` and `all`
|
63
|
+
#### `create`
|
64
|
+
```ruby
|
65
|
+
Datawow.[class].create({data: "image URL", token: '_token'})
|
66
|
+
```
|
67
|
+
|
68
|
+
#### `find_by`
|
69
|
+
```ruby
|
70
|
+
Datawow.[class].find_by({id: "_image_id", token: '_token'})
|
71
|
+
```
|
72
|
+
|
73
|
+
#### `all`
|
74
|
+
```ruby
|
75
|
+
Datawow.[class].all({token: '_token'})
|
76
|
+
```
|
77
|
+
---
|
78
|
+
## Nanameue with Consensus
|
79
|
+
#### `create`
|
80
|
+
```ruby
|
81
|
+
Datawow::NanameueHuman.new('_token').create({data: "image URL"})
|
82
|
+
```
|
83
|
+
|
84
|
+
#### `find_by`
|
85
|
+
```ruby
|
86
|
+
Datawow::NanameueHuman.new('_token').find_by({id: "_image_id"})
|
87
|
+
```
|
88
|
+
|
89
|
+
#### `all`
|
90
|
+
```ruby
|
91
|
+
Datawow::NanameueHuman.new('_token').all({page: '_page', per_page: '_per_page'})
|
92
|
+
```
|
93
|
+
|
94
|
+
# Setting default token
|
95
|
+
|
96
|
+
If you have only one token that use on your project, you could config auto append or set token by default. This for Ruby On Rails project.
|
97
|
+
|
98
|
+
`config/initializers/datawow.rb`
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
Datawow.setup do |config|
|
102
|
+
# ==> Secret key Configuration
|
103
|
+
# You can change it below and use your own secret key.
|
104
|
+
config.project_key = 'your token'
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
After configuration has been set. You can calling APIs by not insert token like this
|
109
|
+
```ruby
|
110
|
+
Datawow.[class].create({data: "image URL"})
|
111
|
+
```
|
112
|
+
The system will be looking for your token by automatically
|
113
|
+
|
114
|
+
# Response
|
115
|
+
|
116
|
+
Response is a module and it contain such as meta-data, message, status and data.
|
117
|
+
#### Example of response module
|
118
|
+
```ruby
|
119
|
+
<Datawow::Response @status=200, @message="success" @meta={"code"=>200, "message"=>"success"}, @data={...}, />
|
120
|
+
```
|
121
|
+
you can use data whit calling `data` property and you will be get data like a example below
|
122
|
+
|
123
|
+
```json
|
124
|
+
{
|
125
|
+
"data": {
|
126
|
+
"image": {
|
127
|
+
"id": "5a40be59fb9d7f27354c5efa",
|
128
|
+
"answer": "approved",
|
129
|
+
"credit_charged": 1,
|
130
|
+
"custom_id": "custom_id",
|
131
|
+
"data": "image_url",
|
132
|
+
"postback_url": "postback_url",
|
133
|
+
"processed_at": "2017-12-25T16:02:00.599+07:00",
|
134
|
+
"project_id": "project_id",
|
135
|
+
"status": "processed"
|
136
|
+
}
|
137
|
+
},
|
138
|
+
"status": 200,
|
139
|
+
"message": "success",
|
140
|
+
"meta": {
|
141
|
+
"code": 200,
|
142
|
+
"message": "success"
|
143
|
+
}
|
144
|
+
}
|
145
|
+
```
|
146
|
+
---
|
147
|
+
#### Checking status with `successful?`
|
148
|
+
```ruby
|
149
|
+
if response.successful?
|
150
|
+
# Do stuff
|
151
|
+
else
|
152
|
+
log.error("Request was not successful, something went wrong.")
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
# Demo and Usage
|
157
|
+
- Image Documentation [link](README/image_docs.md)
|
158
|
+
- Video Documentation [link](README/video_docs.md)
|
159
|
+
- Text Documentation [link](README/text_docs.md)
|
160
|
+
- AI/Prediction Documentation [link](README/ai_docs.md)
|
data/Rakefile
ADDED
data/datawow.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'datawow'
|
8
|
+
s.version = '1.2.0'
|
9
|
+
s.date = '2018-11-27'
|
10
|
+
s.summary = 'HTTP RESTFul for calling DataWow APIs'
|
11
|
+
s.description = 'Moderation suite'
|
12
|
+
s.post_install_message = File.read('INSTALL.md') if File.exist?('INSTALL.md')
|
13
|
+
s.authors = ['Jesdakorn Samittiauttakorn']
|
14
|
+
s.email = 'ton@nanameue.jp'
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.homepage = 'https://datawow.io'
|
17
|
+
s.license = 'Commercial'
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'faraday', '~> 0.13.1', '>= 0.13.1'
|
21
|
+
s.add_runtime_dependency 'faraday_middleware', '~> 0.12.2', '>= 0.12.2'
|
22
|
+
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
23
|
+
s.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.3'
|
24
|
+
s.add_development_dependency 'pry-byebug', '~> 3.6'
|
25
|
+
s.add_development_dependency 'rake', '~> 12.3'
|
26
|
+
s.add_development_dependency 'simplecov', '~> 0.15.1'
|
27
|
+
s.add_development_dependency 'webmock', '~> 3.3'
|
28
|
+
end
|