posmoni 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 +7 -0
- data/.gitignore +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +42 -0
- data/INSTALL.md +7 -0
- data/README.md +184 -0
- data/Rakefile +12 -0
- data/lib/generators/posmoni/install_generator.rb +18 -0
- data/lib/generators/templates/posmoni_api.rb +7 -0
- data/lib/posmoni.rb +26 -0
- data/lib/posmoni/connector.rb +107 -0
- data/lib/posmoni/error.rb +15 -0
- data/lib/posmoni/interface.rb +22 -0
- data/lib/posmoni/moderation.rb +13 -0
- data/lib/posmoni/response.rb +40 -0
- data/lib/posmoni/version.rb +3 -0
- data/posmoni.gemspec +25 -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_document_verification/all.json +143 -0
- data/test/fixtures/image_document_verification/create.json +27 -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/moderation/all.json +68 -0
- data/test/fixtures/moderation/create.json +26 -0
- data/test/fixtures/moderation/find_by.json +26 -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/text_ja/all.json +35 -0
- data/test/fixtures/text_ja/create.json +28 -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/posmoni/moderation_test.rb +46 -0
- data/test/posmoni_test.rb +14 -0
- data/test/test_helper.rb +25 -0
- metadata +174 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Posmoni::Interface
|
|
4
|
+
def all(options = {})
|
|
5
|
+
connector.get(options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def create(options)
|
|
9
|
+
connector.post(options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def find_by(options = {})
|
|
13
|
+
@query_str = true if @query_str.nil?
|
|
14
|
+
connector.get(options.merge({ query: options[:id] }), @query_str)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def connector
|
|
20
|
+
@connection ||= Posmoni::Connector.new(@path, @type, token: @project_key)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Posmoni
|
|
4
|
+
class Response
|
|
5
|
+
attr_reader :body, :code
|
|
6
|
+
|
|
7
|
+
def initialize(body, code)
|
|
8
|
+
@body = body
|
|
9
|
+
@code = code.to_i
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def successful?
|
|
13
|
+
[200, 201].include? code
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def data
|
|
17
|
+
body['data']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def status
|
|
21
|
+
code
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def error
|
|
25
|
+
body['error'] unless successful?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def message
|
|
29
|
+
meta['message']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def meta
|
|
33
|
+
body['meta']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def total
|
|
37
|
+
meta['total_count'] || 0
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/posmoni.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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 = 'posmoni'
|
|
8
|
+
s.version = '0.0.5'
|
|
9
|
+
s.date = '2019-12-09'
|
|
10
|
+
s.summary = 'HTTP RESTFul for calling Posmoni APIs'
|
|
11
|
+
s.description = 'Posmoni 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 = 'MIT'
|
|
18
|
+
s.require_paths = ['lib']
|
|
19
|
+
|
|
20
|
+
s.add_runtime_dependency 'json', '~> 2.2'
|
|
21
|
+
s.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.3'
|
|
22
|
+
s.add_development_dependency 'rake', '~> 12.3'
|
|
23
|
+
s.add_development_dependency 'simplecov', '~> 0.15.1'
|
|
24
|
+
s.add_development_dependency 'webmock', '~> 3.3'
|
|
25
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"images": [
|
|
4
|
+
{
|
|
5
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
6
|
+
"allow_empty": false,
|
|
7
|
+
"answer": [],
|
|
8
|
+
"categories": [
|
|
9
|
+
"Gnoon"
|
|
10
|
+
],
|
|
11
|
+
"credit_charged": 0,
|
|
12
|
+
"custom_id": null,
|
|
13
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
14
|
+
"instruction": "Instruction",
|
|
15
|
+
"multiple": false,
|
|
16
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
17
|
+
"processed_at": null,
|
|
18
|
+
"project_id": 102,
|
|
19
|
+
"status": "unprocess"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"meta": {
|
|
24
|
+
"code": 200,
|
|
25
|
+
"message": "success"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"image": {
|
|
4
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
5
|
+
"allow_empty": false,
|
|
6
|
+
"answer": [],
|
|
7
|
+
"categories": [
|
|
8
|
+
"foo,bar"
|
|
9
|
+
],
|
|
10
|
+
"credit_charged": 0,
|
|
11
|
+
"custom_id": null,
|
|
12
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
13
|
+
"instruction": "Image's instruction",
|
|
14
|
+
"multiple": false,
|
|
15
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
16
|
+
"processed_at": null,
|
|
17
|
+
"project_id": 105,
|
|
18
|
+
"status": "unprocess"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"meta": {
|
|
22
|
+
"code": 200,
|
|
23
|
+
"message": "success"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"images": [
|
|
4
|
+
{
|
|
5
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
6
|
+
"answer": "declined",
|
|
7
|
+
"credit_charged": 1,
|
|
8
|
+
"custom_id": null,
|
|
9
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
10
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
11
|
+
"processed_at": "2017-12-28T10:40:30.462+07:00",
|
|
12
|
+
"project_id": 102,
|
|
13
|
+
"status": "processed"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"meta": {
|
|
18
|
+
"code": 200,
|
|
19
|
+
"message": "success"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"image": {
|
|
4
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
5
|
+
"answer": "declined",
|
|
6
|
+
"credit_charged": 1,
|
|
7
|
+
"custom_id": null,
|
|
8
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
9
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
10
|
+
"processed_at": "2017-12-28T10:40:30.462+07:00",
|
|
11
|
+
"project_id": 102,
|
|
12
|
+
"status": "processed"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"meta": {
|
|
16
|
+
"code": 200,
|
|
17
|
+
"message": "success"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": "5c5cfb176e1157d3a56622fa",
|
|
5
|
+
"custom_id": null,
|
|
6
|
+
"status": "processed",
|
|
7
|
+
"postback_url": "https://9a9fe5c0.ap.ngrok.io/api/v1/moderate/images/closed_questions",
|
|
8
|
+
"postback": false,
|
|
9
|
+
"postback_method": "GET",
|
|
10
|
+
"project_id": 192,
|
|
11
|
+
"created_at": "2019-02-08T10:44:23.981+07:00",
|
|
12
|
+
"processed_at": "2019-02-08T10:44:36.350+07:00",
|
|
13
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
14
|
+
"infos": {
|
|
15
|
+
"type": {
|
|
16
|
+
"value": "student_card",
|
|
17
|
+
"valid": true
|
|
18
|
+
},
|
|
19
|
+
"dob": {
|
|
20
|
+
"value": "91/11/28",
|
|
21
|
+
"valid": true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"contributors": [
|
|
25
|
+
999999,
|
|
26
|
+
49
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "5c5ce5bc6e1157b669f2ae5d",
|
|
31
|
+
"custom_id": null,
|
|
32
|
+
"status": "processed",
|
|
33
|
+
"postback_url": "https://9a9fe5c0.ap.ngrok.io/api/v1/moderate/images/closed_questions",
|
|
34
|
+
"postback": false,
|
|
35
|
+
"postback_method": "GET",
|
|
36
|
+
"project_id": 192,
|
|
37
|
+
"created_at": "2019-02-08T09:13:16.410+07:00",
|
|
38
|
+
"processed_at": "2019-02-08T10:34:26.088+07:00",
|
|
39
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
40
|
+
"infos": {
|
|
41
|
+
"type": {
|
|
42
|
+
"value": "student_card",
|
|
43
|
+
"valid": false
|
|
44
|
+
},
|
|
45
|
+
"dob": {
|
|
46
|
+
"value": "91/11/28",
|
|
47
|
+
"valid": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"contributors": [
|
|
51
|
+
49,
|
|
52
|
+
999999
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "5c5cdac56e1157a373e24da6",
|
|
57
|
+
"custom_id": null,
|
|
58
|
+
"status": "processed",
|
|
59
|
+
"postback_url": "https://9a9fe5c0.ap.ngrok.io/api/v1/moderate/images/closed_questions",
|
|
60
|
+
"postback": false,
|
|
61
|
+
"postback_method": "GET",
|
|
62
|
+
"project_id": 192,
|
|
63
|
+
"created_at": "2019-02-08T08:26:29.070+07:00",
|
|
64
|
+
"processed_at": "2019-02-08T08:29:18.893+07:00",
|
|
65
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
66
|
+
"infos": {
|
|
67
|
+
"type": {
|
|
68
|
+
"value": "student_card",
|
|
69
|
+
"valid": false
|
|
70
|
+
},
|
|
71
|
+
"dob": {
|
|
72
|
+
"value": "91/11/28",
|
|
73
|
+
"valid": false
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"contributors": [
|
|
77
|
+
49,
|
|
78
|
+
999999
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "5c5c02df6e1157989273f33e",
|
|
83
|
+
"custom_id": null,
|
|
84
|
+
"status": "processed",
|
|
85
|
+
"postback_url": "https://9a9fe5c0.ap.ngrok.io/api/v1/moderate/images/closed_questions",
|
|
86
|
+
"postback": false,
|
|
87
|
+
"postback_method": "GET",
|
|
88
|
+
"project_id": 192,
|
|
89
|
+
"created_at": "2019-02-07T17:05:19.586+07:00",
|
|
90
|
+
"processed_at": "2019-02-07T17:05:34.045+07:00",
|
|
91
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
92
|
+
"infos": {
|
|
93
|
+
"type": {
|
|
94
|
+
"value": "student_card",
|
|
95
|
+
"valid": false
|
|
96
|
+
},
|
|
97
|
+
"dob": {
|
|
98
|
+
"value": "91/11/28",
|
|
99
|
+
"valid": false
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"contributors": [
|
|
103
|
+
999999,
|
|
104
|
+
49
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "5c5c02796e1157989273f33b",
|
|
109
|
+
"custom_id": null,
|
|
110
|
+
"status": "processed",
|
|
111
|
+
"postback_url": "https://9a9fe5c0.ap.ngrok.io/api/v1/moderate/images/closed_questions",
|
|
112
|
+
"postback": false,
|
|
113
|
+
"postback_method": "GET",
|
|
114
|
+
"project_id": 192,
|
|
115
|
+
"created_at": "2019-02-07T17:03:37.214+07:00",
|
|
116
|
+
"processed_at": "2019-02-07T17:05:02.430+07:00",
|
|
117
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
118
|
+
"infos": {
|
|
119
|
+
"type": {
|
|
120
|
+
"value": "student_card",
|
|
121
|
+
"valid": true
|
|
122
|
+
},
|
|
123
|
+
"dob": {
|
|
124
|
+
"value": "91/11/28",
|
|
125
|
+
"valid": true
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"contributors": [
|
|
129
|
+
999999,
|
|
130
|
+
49
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"meta": {
|
|
135
|
+
"code": 200,
|
|
136
|
+
"message": "success",
|
|
137
|
+
"current_page": 1,
|
|
138
|
+
"next_page": -1,
|
|
139
|
+
"prev_page": -1,
|
|
140
|
+
"total_pages": 1,
|
|
141
|
+
"total_count": 5
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"id": "5c5d399b6e11571af0b87911",
|
|
4
|
+
"custom_id": null,
|
|
5
|
+
"status": "unprocess",
|
|
6
|
+
"postback_url": "https://9a9fe5c0.ap.ngrok.io/api/v1/moderate/images/closed_questions",
|
|
7
|
+
"postback": false,
|
|
8
|
+
"postback_method": "GET",
|
|
9
|
+
"project_id": 192,
|
|
10
|
+
"created_at": "2019-02-08T15:11:07.116+07:00",
|
|
11
|
+
"processed_at": null,
|
|
12
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
13
|
+
"infos": {
|
|
14
|
+
"type": {
|
|
15
|
+
"value": "student_card"
|
|
16
|
+
},
|
|
17
|
+
"dob": {
|
|
18
|
+
"value": "91/11/28"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"contributors": []
|
|
22
|
+
},
|
|
23
|
+
"meta": {
|
|
24
|
+
"code": 201,
|
|
25
|
+
"message": "created success"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"images": [
|
|
4
|
+
{
|
|
5
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
6
|
+
"answer": null,
|
|
7
|
+
"credit_charged": 0,
|
|
8
|
+
"custom_id": null,
|
|
9
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
10
|
+
"instruction": "Instruction",
|
|
11
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
12
|
+
"processed_at": null,
|
|
13
|
+
"project_id": 102,
|
|
14
|
+
"status": "unprocess"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"meta": {
|
|
19
|
+
"code": 200,
|
|
20
|
+
"message": "success"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"image": {
|
|
4
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
5
|
+
"answer": null,
|
|
6
|
+
"credit_charged": 0,
|
|
7
|
+
"custom_id": null,
|
|
8
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
9
|
+
"instruction": "Instruction",
|
|
10
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
11
|
+
"processed_at": null,
|
|
12
|
+
"project_id": 102,
|
|
13
|
+
"status": "unprocess"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"meta": {
|
|
17
|
+
"code": 200,
|
|
18
|
+
"message": "success"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"images": [
|
|
4
|
+
{
|
|
5
|
+
"id": "5a44671ab3957c2ab5c33326",
|
|
6
|
+
"answer": [],
|
|
7
|
+
"credit_charged": 0,
|
|
8
|
+
"custom_id": null,
|
|
9
|
+
"data": "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png",
|
|
10
|
+
"instruction": "Instruction",
|
|
11
|
+
"postback_url": "https://9333bbac.ngrok.io/callbacks",
|
|
12
|
+
"processed_at": null,
|
|
13
|
+
"project_id": 102,
|
|
14
|
+
"status": "unprocess"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"meta": {
|
|
19
|
+
"code": 200,
|
|
20
|
+
"message": "success"
|
|
21
|
+
}
|
|
22
|
+
}
|