ruby-carrot 0.6.5 → 0.7.1
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.
- data/lib/ruby-carrot.rb +85 -10
- metadata +11 -11
data/lib/ruby-carrot.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# Author:: Jorge Vargas (mailto:jorge.vargas@voicebunny.com)
|
2
|
+
# Copyright:: Copyright (c) 2008 Torrenegra IP, LLC.
|
3
|
+
# License:: Distributed under Creative Commons CC-BY license http://creativecommons.org/licenses/by/3.0/
|
4
|
+
|
5
|
+
# This module hace the class that handle the connection
|
6
|
+
# to the VoiceBunny API
|
1
7
|
|
2
8
|
module RubyCarrot
|
3
9
|
class VBCarrot
|
@@ -10,6 +16,7 @@ module RubyCarrot
|
|
10
16
|
@api_user = nil
|
11
17
|
@api_key = nil
|
12
18
|
|
19
|
+
# Initializes the carrot and save the account information on class variables
|
13
20
|
def initialize(user, id, key)
|
14
21
|
@api_id = id
|
15
22
|
@api_user = user
|
@@ -18,6 +25,7 @@ module RubyCarrot
|
|
18
25
|
setup
|
19
26
|
end
|
20
27
|
|
28
|
+
# Setup the connection to the API using Faraday, and saves the connection object in a class variable
|
21
29
|
def setup
|
22
30
|
@conn = Faraday.new(:url =>("https://"+ @api_id.to_s+":"+@api_key +"@"+API_BASE_URL),:ssl => {:verify => false}) do |builder|
|
23
31
|
builder.use Faraday::Request::Multipart
|
@@ -27,72 +35,139 @@ module RubyCarrot
|
|
27
35
|
end
|
28
36
|
end
|
29
37
|
|
38
|
+
# Returns the balance of the user initialized
|
30
39
|
def balance
|
31
40
|
resp = @conn.get 'balance.json'
|
32
41
|
resp.body
|
33
42
|
end
|
34
43
|
|
44
|
+
# Returns the projects created by the user initialized
|
35
45
|
def all_projects
|
36
46
|
resp = @conn.get 'projects.json'
|
37
47
|
resp.body
|
38
48
|
end
|
39
49
|
|
50
|
+
# Return the project with the specified ID
|
40
51
|
def get_project(id)
|
41
52
|
resp = @conn.get 'projects/'+id.to_s+'.json'
|
42
53
|
resp.body
|
43
54
|
end
|
44
55
|
|
56
|
+
# Create a project given a hashtable with the project information
|
45
57
|
def create_project(project)
|
46
|
-
resp = @conn.post 'projects/
|
58
|
+
resp = @conn.post 'projects/addSpeedy.json', {
|
47
59
|
title: project[:title],
|
48
60
|
script: project[:script],
|
49
|
-
|
61
|
+
price: project[:price],
|
50
62
|
genderAndAge: project[:genderAndAge],
|
51
63
|
language: project[:language],
|
52
64
|
lifetime: project[:lifetime],
|
53
65
|
ping: project[:ping],
|
54
66
|
test: project[:test],
|
55
|
-
|
56
|
-
|
67
|
+
currency: project[:currency],
|
68
|
+
remarks: project[:remarks],
|
69
|
+
timedRecording: project[:timedRecording]
|
57
70
|
}
|
58
71
|
|
59
72
|
resp.body
|
60
73
|
end
|
61
74
|
|
75
|
+
# Create a booking project for a certain user
|
76
|
+
def create_booking_project(project)
|
77
|
+
resp = @conn.post 'projects/addBooking.json', {
|
78
|
+
title: project[:title],
|
79
|
+
script: project[:script],
|
80
|
+
talentID: project[:talentID],
|
81
|
+
genderAndAge: project[:genderAndAge],
|
82
|
+
language: project[:language],
|
83
|
+
lifetime: project[:lifetime],
|
84
|
+
ping: project[:ping],
|
85
|
+
test: project[:test],
|
86
|
+
currency: project[:currency],
|
87
|
+
remarks: project[:remarks],
|
88
|
+
timedRecording: project[:timedRecording]
|
89
|
+
}
|
90
|
+
|
91
|
+
resp.body
|
92
|
+
end
|
93
|
+
|
94
|
+
# Dispose the project with the specified ID
|
62
95
|
def force_dispose(id)
|
63
96
|
resp = @conn.get 'projects/forceDispose/'+id.to_s+'.json'
|
64
97
|
resp.body
|
65
98
|
end
|
66
99
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
100
|
+
# Returns the suggested amount of money, of a a project with the given script
|
101
|
+
def quote(params)
|
102
|
+
data = Hash.new
|
103
|
+
data[:language] = params[:language]
|
104
|
+
data[:fulfilmentType] = params[:fulfilmentType]
|
105
|
+
data[:maxEntries] = params[:maxEntries]
|
106
|
+
data[:talentID] = params[:talentID]
|
107
|
+
if params.has_key?('numberOfCharacters')
|
108
|
+
data[:numberOfCharacters] = params[:numberOfCharacters]
|
109
|
+
elsif params.has_key?('numberOfWords')
|
110
|
+
data[:numberOfWords] = params[:numberOfWords]
|
111
|
+
else
|
112
|
+
data[:script] = params[:script]
|
113
|
+
end
|
114
|
+
resp = @conn.post 'projects/quote.json', data
|
73
115
|
resp.body
|
74
116
|
end
|
75
117
|
|
118
|
+
# Returns the read with the specified ID
|
76
119
|
def get_read(id)
|
77
120
|
resp = @conn.get 'reads/'+id.to_s+'.json'
|
78
121
|
resp.body
|
79
122
|
end
|
80
123
|
|
124
|
+
# Approve the read with the specified ID
|
81
125
|
def approve_read(id)
|
82
126
|
resp = @conn.get 'reads/approve/'+id.to_s+'.json'
|
83
127
|
resp.body
|
84
128
|
end
|
85
129
|
|
130
|
+
# Reject the read with the specified ID
|
86
131
|
def reject_read(id)
|
87
132
|
resp = @conn.get 'reads/reject/'+id.to_s+'.json'
|
88
133
|
resp.body
|
89
134
|
end
|
90
135
|
|
136
|
+
# Quote how much a revision of a given read cost
|
137
|
+
def revision_quote(readId, params)
|
138
|
+
data = Hash.new
|
139
|
+
data[:voiceBunnyError] = params[:voiceBunnyError]
|
140
|
+
if params.has_key?('charactersAddedOrChanged')
|
141
|
+
data[:charactersAddedOrChanged] = params[:charactersAddedOrChanged]
|
142
|
+
else
|
143
|
+
data[:wordsAddedOrChanged] = params[:wordsAddedOrChanged]
|
144
|
+
end
|
145
|
+
resp = @conn.get 'reads/'+readId.to_s+'/revision/quote.json', data
|
146
|
+
resp.body
|
147
|
+
end
|
148
|
+
|
149
|
+
# Request a revision for a given read
|
150
|
+
def revision_add(readId, params)
|
151
|
+
data = Hash.new
|
152
|
+
data[:ping] = params[:ping]
|
153
|
+
data[:instructions] = params[:instructions]
|
154
|
+
data[:voiceBunnyError] = params[:voiceBunnyError]
|
155
|
+
if params.has_key?('charactersAddedOrChanged')
|
156
|
+
data[:charactersAddedOrChanged] = params[:charactersAddedOrChanged]
|
157
|
+
else
|
158
|
+
data[:wordsAddedOrChanged] = params[:wordsAddedOrChanged]
|
159
|
+
end
|
160
|
+
resp = @conn.get 'reads/'+readId.to_s+'/revision/add.json', data
|
161
|
+
resp.body
|
162
|
+
end
|
163
|
+
|
164
|
+
# Return a list of all the languages supported by the service
|
91
165
|
def languages
|
92
166
|
resp = @conn.get 'languages.json'
|
93
167
|
resp.body
|
94
168
|
end
|
95
169
|
|
170
|
+
# Return a list of all the gender and ages supported by the service
|
96
171
|
def gender_ages
|
97
172
|
resp = @conn.get 'genderAndAges.json'
|
98
173
|
resp.body
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-carrot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,33 +10,33 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
17
|
-
requirement: &
|
17
|
+
requirement: &3180312 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.8.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *3180312
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: faraday_middleware
|
28
|
-
requirement: &
|
28
|
+
requirement: &3179196 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.8.
|
33
|
+
version: 0.8.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *3179196
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: test/unit
|
39
|
-
requirement: &
|
39
|
+
requirement: &3178332 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,9 +44,9 @@ dependencies:
|
|
44
44
|
version: 2.4.5
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *3178332
|
48
48
|
description: VoiceBunny library for accessing API using Ruby.
|
49
|
-
email:
|
49
|
+
email: api@voicebunny.com
|
50
50
|
executables: []
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|