scaleapi 0.1.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.
@@ -0,0 +1,32 @@
1
+ require 'json'
2
+ require 'scale/api/tasks/base_task'
3
+
4
+ class Scale
5
+ class Api
6
+ class Tasks
7
+ class Categorization < BaseTask
8
+ CREATE_PATH = 'task/categorize'.freeze
9
+
10
+ def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, categories: [], urgency: 'day', category_ids: {}, allow_multiple: false, metadata: {}, client: nil)
11
+ body = {
12
+ callback_url: callback_url,
13
+ instruction: instruction,
14
+ attachment_type: attachment_type,
15
+ attachment: attachment,
16
+ categories: categories,
17
+ urgency: urgency,
18
+ category_ids: category_ids,
19
+ allow_multiple: allow_multiple,
20
+ metadata: metadata
21
+ }
22
+
23
+ body.delete(:category_ids) if category_ids.keys.count.zero?
24
+ body.delete(:categories) if categories.count.zero?
25
+
26
+ response = client.post(CREATE_PATH, body)
27
+ Categorization.new(JSON.parse(response.body))
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+ require 'scale/api/tasks/base_task'
3
+
4
+ class Scale
5
+ class Api
6
+ class Tasks
7
+ class Comparison < BaseTask
8
+ CREATE_PATH = 'task/comparison'.freeze
9
+
10
+ def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachments: [], fields: {}, urgency: 'day', choices: {}, metadata: {}, client: nil)
11
+ response = client.post(CREATE_PATH, {
12
+ callback_url: callback_url,
13
+ instruction: instruction,
14
+ attachment_type: attachment_type,
15
+ attachments: attachments,
16
+ fields: fields,
17
+ choices: choices,
18
+ urgency: urgency,
19
+ metadata: metadata
20
+ })
21
+
22
+ Comparison.new(JSON.parse(response.body))
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+ require 'scale/api/tasks/base_task'
3
+
4
+ class Scale
5
+ class Api
6
+ class Tasks
7
+ class Datacollection < BaseTask
8
+ CREATE_PATH = 'task/datacollection'.freeze
9
+
10
+ def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, fields: {}, urgency: 'day', metadata: {}, client: nil)
11
+ response = client.post(CREATE_PATH, {
12
+ callback_url: callback_url,
13
+ instruction: instruction,
14
+ attachment_type: attachment_type,
15
+ attachment: attachment,
16
+ fields: fields,
17
+ urgency: urgency,
18
+ metadata: metadata
19
+ })
20
+
21
+ Datacollection.new(JSON.parse(response.body))
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+ require 'scale/api/tasks/base_task'
3
+
4
+ class Scale
5
+ class Api
6
+ class Tasks
7
+ class ImageRecognition < Scale::Api::Tasks::BaseTask
8
+ CREATE_PATH = 'task/annotation'.freeze
9
+
10
+ def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, examples: [], urgency: 'day', metadata: {}, client: nil)
11
+ response = client.post(CREATE_PATH, {
12
+ callback_url: callback_url,
13
+ instruction: instruction,
14
+ attachment_type: attachment_type,
15
+ attachment: attachment,
16
+ objects_to_annotate: objects_to_annotate,
17
+ with_labels: with_labels,
18
+ examples: examples,
19
+ urgency: urgency,
20
+ metadata: metadata
21
+ })
22
+
23
+ ImageRecognition.new(JSON.parse(response.body))
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ require 'json'
2
+ require 'scale/api/tasks/base_task'
3
+
4
+ class Scale
5
+ class Api
6
+ class Tasks
7
+ class PhoneCall < Scale::Api::Tasks::BaseTask
8
+ CREATE_PATH = 'task/phonecall'.freeze
9
+
10
+ def self.create(callback_url: nil, instruction: nil, phone_number: nil, script: nil, entity_name: nil, attachment: nil, attachment_type: nil, fields: {}, choices: {}, urgency: 'day', metadata: {}, client: nil)
11
+ response = client.post(CREATE_PATH, {
12
+ callback_url: callback_url,
13
+ instruction: instruction,
14
+ attachment_type: attachment_type,
15
+ attachment: attachment,
16
+ phone_number: phone_number,
17
+ script: script,
18
+ entity_name: entity_name,
19
+ fields: fields,
20
+ choices: choices,
21
+ urgency: urgency,
22
+ metadata: metadata
23
+ })
24
+
25
+ PhoneCall.new(JSON.parse(response.body))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+ require 'scale/api/tasks/base_task'
3
+
4
+ class Scale
5
+ class Api
6
+ class Tasks
7
+ class Transcription < BaseTask
8
+ CREATE_PATH = 'task/transcription'.freeze
9
+
10
+ def self.create(callback_url: nil, instruction: nil, attachment_type: nil, choices: {}, attachment: null, fields: {}, urgency: 'day', metadata: {}, client: nil)
11
+ response = client.post(CREATE_PATH, {
12
+ callback_url: callback_url,
13
+ instruction: instruction,
14
+ attachment_type: attachment_type,
15
+ attachment: attachment,
16
+ fields: fields,
17
+ choices: choices,
18
+ urgency: urgency,
19
+ metadata: metadata
20
+ })
21
+
22
+ Transcription.new(JSON.parse(response.body))
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "scaleapi"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Alexandr Wang"]
9
+ spec.email = ["alex@scaleapi.com"]
10
+
11
+ spec.summary = %q{Official Ruby Client for Scale API}
12
+ spec.description = %q{Scale is an API For Human Intelligence. Get high quality results for all sorts of tasks within minutes. This is the official Ruby client.}
13
+ spec.homepage = "https://www.scaleapi.com"
14
+ spec.license = "MIT"
15
+
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_dependency "faraday", "0.11.0"
27
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scaleapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexandr Wang
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.11.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.11.0
55
+ description: Scale is an API For Human Intelligence. Get high quality results for
56
+ all sorts of tasks within minutes. This is the official Ruby client.
57
+ email:
58
+ - alex@scaleapi.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/scale.rb
71
+ - lib/scale/api.rb
72
+ - lib/scale/api/callback.rb
73
+ - lib/scale/api/errors.rb
74
+ - lib/scale/api/task_list.rb
75
+ - lib/scale/api/tasks.rb
76
+ - lib/scale/api/tasks/audio_transcription.rb
77
+ - lib/scale/api/tasks/base_task.rb
78
+ - lib/scale/api/tasks/categorization.rb
79
+ - lib/scale/api/tasks/comparison.rb
80
+ - lib/scale/api/tasks/datacollection.rb
81
+ - lib/scale/api/tasks/image_recognition.rb
82
+ - lib/scale/api/tasks/phone_call.rb
83
+ - lib/scale/api/tasks/transcription.rb
84
+ - scaleapi-ruby.gemspec
85
+ homepage: https://www.scaleapi.com
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.5.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Official Ruby Client for Scale API
109
+ test_files: []