rev-api 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +22 -22
  3. data/.ruby-gemset +1 -1
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +8 -8
  6. data/Gemfile +3 -3
  7. data/LICENSE +191 -191
  8. data/README.md +131 -131
  9. data/Rakefile +13 -13
  10. data/examples/cli.rb +270 -270
  11. data/lib/rev-api.rb +26 -26
  12. data/lib/rev-api/api.rb +326 -326
  13. data/lib/rev-api/api_serializable.rb +30 -30
  14. data/lib/rev-api/exceptions.rb +97 -97
  15. data/lib/rev-api/http_client.rb +97 -97
  16. data/lib/rev-api/models/order.rb +129 -130
  17. data/lib/rev-api/models/order_request.rb +276 -276
  18. data/lib/rev-api/version.rb +3 -3
  19. data/rev-api.gemspec +33 -33
  20. data/spec/fixtures/api_cassettes/cancel_order.yml +38 -38
  21. data/spec/fixtures/api_cassettes/cancel_order_not_allowed.yml +40 -40
  22. data/spec/fixtures/api_cassettes/get_attachment_content.yml +399 -399
  23. data/spec/fixtures/api_cassettes/get_attachment_content_as_pdf.yml +399 -399
  24. data/spec/fixtures/api_cassettes/get_attachment_content_as_text.yml +65 -65
  25. data/spec/fixtures/api_cassettes/get_attachment_content_as_youtube_transcript.yml +66 -66
  26. data/spec/fixtures/api_cassettes/get_attachment_content_unacceptable_representation.yml +42 -42
  27. data/spec/fixtures/api_cassettes/get_attachment_content_with_invalid_id.yml +42 -42
  28. data/spec/fixtures/api_cassettes/get_attachment_metadata.yml +42 -42
  29. data/spec/fixtures/api_cassettes/get_attachment_with_invalid_id.yml +40 -40
  30. data/spec/fixtures/api_cassettes/get_orders.yml +122 -122
  31. data/spec/fixtures/api_cassettes/get_orders_with_clientRef.yml +41 -41
  32. data/spec/fixtures/api_cassettes/get_tc_order.yml +44 -44
  33. data/spec/fixtures/api_cassettes/get_third_page_of_orders.yml +52 -52
  34. data/spec/fixtures/api_cassettes/link_input.yml +44 -44
  35. data/spec/fixtures/api_cassettes/link_input_with_all_attributes.yml +44 -44
  36. data/spec/fixtures/api_cassettes/link_input_with_spaces_in_filename.yml +45 -45
  37. data/spec/fixtures/api_cassettes/not_found_order.yml +42 -42
  38. data/spec/fixtures/api_cassettes/submit_cp_order.yml +45 -45
  39. data/spec/fixtures/api_cassettes/submit_su_order.yml +45 -45
  40. data/spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml +45 -45
  41. data/spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml +45 -45
  42. data/spec/fixtures/api_cassettes/submit_tc_order_without_specifying_payment.yml +45 -45
  43. data/spec/fixtures/api_cassettes/unauthorized.yml +42 -42
  44. data/spec/fixtures/api_cassettes/upload_input.yml +90 -90
  45. data/spec/fixtures/api_cassettes/upload_input_with_invalid_content_type.yml +91 -91
  46. data/spec/lib/rev/api_spec.rb +24 -24
  47. data/spec/lib/rev/cancel_order_spec.rb +24 -24
  48. data/spec/lib/rev/exceptions_spec.rb +8 -8
  49. data/spec/lib/rev/get_attachment_content_spec.rb +79 -79
  50. data/spec/lib/rev/get_attachment_metadata_spec.rb +33 -33
  51. data/spec/lib/rev/get_order_spec.rb +52 -52
  52. data/spec/lib/rev/get_orders_spec.rb +62 -62
  53. data/spec/lib/rev/http_client_spec.rb +32 -32
  54. data/spec/lib/rev/models/order_spec.rb +58 -58
  55. data/spec/lib/rev/post_inputs_spec.rb +94 -94
  56. data/spec/lib/rev/post_order_spec.rb +163 -163
  57. data/spec/spec_helper.rb +47 -47
  58. data/spec/test_helpers.rb +5 -5
  59. metadata +36 -78
@@ -1,276 +1,276 @@
1
- require 'rev-api/api_serializable'
2
-
3
- module Rev
4
- # OrderRequest is used for constructing order 'spec' in consumer code and passing it into.
5
- # It consists of three main elements: :payment, :transcription_options and :notification.
6
- # You can also supply reference number, customer comment, and whether standard turnaround time is not required
7
- #
8
- # @note https://www.rev.com/api/ordersposttranscription, https://www.rev.com/api/orderspostcaption
9
-
10
- GLOSSARY_ENTRIES_LIMIT = 1000
11
- GLOSSARY_ENTRY_LENGTH_LIMIT = 255
12
- SPEAKER_ENTRIES_LIMIT = 100
13
- SPEAKER_ENTRY_LENGTH_LIMIT = 15
14
-
15
- class OrderRequest < ApiSerializable
16
- # see {Rev::Payment}
17
- attr_reader :payment
18
-
19
- # see {Rev::TranscriptionOptions}
20
- attr_reader :transcription_options
21
-
22
- # see {Rev::CaptionOptions}
23
- attr_reader :caption_options
24
-
25
- # see {Rev::Notification}
26
- attr_reader :notification
27
-
28
- # a reference number for the order meaningful for the client (optional)
29
- attr_reader :client_ref
30
-
31
- # a comment with any special messages about the order (optional)
32
- attr_reader :comment
33
-
34
- # a boolean flag specifying whether normal turnaround time is not required, defaults to false (optional)
35
- attr_reader :non_standard_tat_guarantee
36
-
37
- # @param payment [Payment] payment info
38
- # @param fields [Hash] of fields to initialize instance. See instance attributes for available fields.
39
- # @deprecated payment always defaults to :account_balance
40
- def self.new_with_payment(payment, fields = {})
41
- fields = { :non_standard_tat_guarantee => false }.merge(fields)
42
- super fields
43
- @payment = payment
44
- end
45
-
46
- # @param fields [Hash] of fields to initialize instance. See instance attributes for available fields.
47
- def initialize(fields = {})
48
- fields = { :non_standard_tat_guarantee => false }.merge(fields)
49
- @payment = Rev::Payment.with_account_balance
50
- super fields
51
- end
52
- end
53
-
54
- # Payment Info. Payment can only be done by debiting the user's account balance.
55
- # @deprecated setting the payment is no longer necessary. All orders now default to :account_balance
56
- class Payment < ApiSerializable
57
- attr_accessor :type
58
-
59
- # use to correctly set payment type
60
- TYPES = {
61
- :account_balance => 'AccountBalance'
62
- }
63
-
64
- CC_ON_FILE_ID = 1
65
-
66
- # @param type [String] payment method
67
- def initialize(type)
68
- @type = type
69
- end
70
-
71
- class << self
72
- def with_account_balance()
73
- Payment::new(TYPES[:account_balance])
74
- end
75
- end
76
- end
77
-
78
- # Billing address
79
- class BillingAddress < ApiSerializable
80
- attr_reader :street, :street2, :city, :state, :zip, :country_alpha2
81
- end
82
-
83
- # Superclass for the business-line options that handles capture and common validation of inputs.
84
- class InputOptions < ApiSerializable
85
- # Mandatory, contains list of inputs. Must have at least one element.
86
- attr_reader :inputs
87
-
88
- # @param inputs [Array] list of inputs
89
- # @param info [Hash] of fields to initialize instance.
90
- def initialize(inputs, info = {})
91
- super info
92
- raise(ArgumentError, "inputs must have at least one element") unless validate_inputs(inputs)
93
- @inputs = inputs
94
- end
95
-
96
- private
97
-
98
- def validate_inputs(inputs)
99
- !inputs.nil? && inputs.length > 0
100
- end
101
- end
102
-
103
- # Transcription options. This section contains the input media that must be transferred to our servers
104
- # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
105
- # @see https://www.rev.com/api/ordersposttranscription
106
- class TranscriptionOptions < InputOptions
107
- # Optional, should we transcribe the provided files verbatim? If true,
108
- # all filler words (i.e. umm, huh) will be included.
109
- attr_reader :verbatim
110
-
111
- # Optional, should we include timestamps?
112
- attr_reader :timestamps
113
-
114
- # @param inputs [Array] list of inputs
115
- # @param info [Hash] of fields to initialize instance. May contain:
116
- # - :verbatim => true/false
117
- # - :timestamps => true/false
118
- def initialize(inputs, info = {})
119
- super inputs, info
120
- options_validation(inputs)
121
- end
122
-
123
- private
124
-
125
- def options_validation(inputs)
126
- inputs.each { |input|
127
- input.validate_glossary
128
- input.validate_speakers
129
- input.validate_accents
130
- }
131
- end
132
- end
133
-
134
- # Caption options. This section contains the input media that must be transferred to our servers
135
- # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
136
- # @see https://www.rev.com/api/orderspostcaption
137
- class CaptionOptions < InputOptions
138
- # Array of file formats the captions should be delivered as. (Optional, default is SubRip)
139
- attr_reader :output_file_formats
140
-
141
- # Optional, Array of language codes to request foreign language subtitles
142
- attr_reader :subtitle_languages
143
-
144
- # All supported output file formats
145
- OUTPUT_FILE_FORMATS = {
146
- :subrip => 'SubRip',
147
- :scc => 'Scc',
148
- :mcc => 'Mcc',
149
- :ttml => 'Ttml',
150
- :qttext => 'QTtext',
151
- :transcript => 'Transcript',
152
- :webvtt => 'WebVtt',
153
- :dfxp => 'Dfxp',
154
- :cheetahcap => 'CheetahCap'
155
- }
156
-
157
- # @param inputs [Array] list of inputs
158
- # @param info [Hash] of fields to initialize instance. May contain:
159
- # - :subtitle_languages
160
- # @see For language codes refer to http://www.loc.gov/standards/iso639-2/php/code_list.php
161
- def initialize(inputs, info = {})
162
- super(inputs, info)
163
- raise(ArgumentError, "invalid format(s)") unless validate_output_formats(info[:output_file_formats])
164
- options_validation(inputs)
165
- end
166
-
167
- private
168
-
169
- def validate_output_formats(formats)
170
- formats.nil? || formats.select{|f| !OUTPUT_FILE_FORMATS.has_value?(f) }.empty?
171
- end
172
-
173
- def options_validation(inputs)
174
- inputs.each { |input|
175
- input.validate_glossary
176
- input.validate_speakers
177
- }
178
- end
179
- end
180
-
181
- # Input for order (aka source file)
182
- class Input < ApiSerializable
183
- # Length of audio in seconds (mandatory in case of inability to determine it automatically).
184
- # Used within {Rev::OrderRequest::TranscriptionInfo}
185
- attr_reader :audio_length_seconds
186
-
187
- # Length of video in seconds (mandatory in case of inability to determine it automatically).
188
- # Used within {Rev::OrderRequest::CaptionInfo}
189
- attr_reader :video_length_seconds
190
-
191
- # Mandatory, URI of the media, as returned from the call to POST /inputs.
192
- # :external_link might substitute :uri for Transcription or Caption.
193
- attr_reader :uri
194
-
195
- # External URL, if sources wasn't POSTed as input (YouTube, Vimeo, Dropbox, etc)
196
- attr_reader :external_link
197
-
198
- # Optional, list of glossary entries.
199
- attr_reader :glossary
200
-
201
- # Optional, list of speaker names.
202
- attr_reader :speakers
203
-
204
- # Optional, list of accents.
205
- attr_reader :accents
206
-
207
- SUPPORTED_ACCENTS = {
208
- :american_neutral => 'AmericanNeutral',
209
- :american_southern => 'AmericanSouthern',
210
- :asian => 'Asian',
211
- :australian => 'Australian',
212
- :british => 'British',
213
- :indian => 'Indian',
214
- :other => 'Other',
215
- :unknown => 'Unknown'
216
- }
217
-
218
- def validate_glossary
219
- if glossary
220
- if glossary.length > GLOSSARY_ENTRIES_LIMIT
221
- raise(ArgumentError, "Glossary must not exceed #{GLOSSARY_ENTRIES_LIMIT} entries")
222
- end
223
- glossary.each { |term|
224
- if term.length > GLOSSARY_ENTRY_LENGTH_LIMIT
225
- raise(ArgumentError, "Glossary entries cannot exceed #{GLOSSARY_ENTRY_LENGTH_LIMIT} characters")
226
- end
227
- }
228
- end
229
- end
230
-
231
- def validate_speakers
232
- if speakers
233
- if speakers.length > SPEAKER_ENTRIES_LIMIT
234
- raise(ArgumentError, "Speaker list must not exceed #{SPEAKER_ENTRIES_LIMIT} entries")
235
- end
236
- speakers.each { |speaker|
237
- if speaker.length > SPEAKER_ENTRY_LENGTH_LIMIT
238
- raise(ArgumentError, "Speaker name cannot exceed #{SPEAKER_ENTRY_LENGTH_LIMIT} characters")
239
- end
240
- }
241
- end
242
- end
243
-
244
- def validate_accents
245
- if accents
246
- if accents.length > SUPPORTED_ACCENTS.length
247
- raise(ArgumentError, "Length of accents list cannot exceed number of supported accents.")
248
- end
249
- if accents.any?{ |accent| !Rev::Input::SUPPORTED_ACCENTS.has_value?(accent) }
250
- raise(ArgumentError, 'Unsupported accent provided')
251
- end
252
- end
253
- end
254
- end
255
-
256
- # Notification Info. Optionally you may request that an HTTP post be made to a url of your choice when the order enters
257
- # a new status (eg being transcribed or reviewed) and when it is complete.
258
- class Notification < ApiSerializable
259
- attr_reader :url, :level
260
-
261
- # Notification levels
262
- LEVELS = {
263
- :detailed => 'Detailed',
264
- :final_only => 'FinalOnly'
265
- }
266
-
267
- # @param url [String] The url for notifications. Mandatory if the notifications element is used. Updates will be posted to this URL
268
- # @param level [String] Optional, specifies which notifications are sent:
269
- # - :detailed - a notification is sent whenever the order is in a new status or has a new comment
270
- # - :final_only - (the default), notification is sent only when the order is complete
271
- def initialize(url, level = nil)
272
- @url = url
273
- @level = level ? level : LEVELS[:final_only]
274
- end
275
- end
276
- end
1
+ require 'rev-api/api_serializable'
2
+
3
+ module Rev
4
+ # OrderRequest is used for constructing order 'spec' in consumer code and passing it into.
5
+ # It consists of three main elements: :payment, :transcription_options and :notification.
6
+ # You can also supply reference number, customer comment, and whether standard turnaround time is not required
7
+ #
8
+ # @note https://www.rev.com/api/ordersposttranscription, https://www.rev.com/api/orderspostcaption
9
+
10
+ GLOSSARY_ENTRIES_LIMIT = 1000
11
+ GLOSSARY_ENTRY_LENGTH_LIMIT = 255
12
+ SPEAKER_ENTRIES_LIMIT = 100
13
+ SPEAKER_ENTRY_LENGTH_LIMIT = 15
14
+
15
+ class OrderRequest < ApiSerializable
16
+ # see {Rev::Payment}
17
+ attr_reader :payment
18
+
19
+ # see {Rev::TranscriptionOptions}
20
+ attr_reader :transcription_options
21
+
22
+ # see {Rev::CaptionOptions}
23
+ attr_reader :caption_options
24
+
25
+ # see {Rev::Notification}
26
+ attr_reader :notification
27
+
28
+ # a reference number for the order meaningful for the client (optional)
29
+ attr_reader :client_ref
30
+
31
+ # a comment with any special messages about the order (optional)
32
+ attr_reader :comment
33
+
34
+ # a boolean flag specifying whether normal turnaround time is not required, defaults to false (optional)
35
+ attr_reader :non_standard_tat_guarantee
36
+
37
+ # @param payment [Payment] payment info
38
+ # @param fields [Hash] of fields to initialize instance. See instance attributes for available fields.
39
+ # @deprecated payment always defaults to :account_balance
40
+ def self.new_with_payment(payment, fields = {})
41
+ fields = { :non_standard_tat_guarantee => false }.merge(fields)
42
+ super fields
43
+ @payment = payment
44
+ end
45
+
46
+ # @param fields [Hash] of fields to initialize instance. See instance attributes for available fields.
47
+ def initialize(fields = {})
48
+ fields = { :non_standard_tat_guarantee => false }.merge(fields)
49
+ @payment = Rev::Payment.with_account_balance
50
+ super fields
51
+ end
52
+ end
53
+
54
+ # Payment Info. Payment can only be done by debiting the user's account balance.
55
+ # @deprecated setting the payment is no longer necessary. All orders now default to :account_balance
56
+ class Payment < ApiSerializable
57
+ attr_accessor :type
58
+
59
+ # use to correctly set payment type
60
+ TYPES = {
61
+ :account_balance => 'AccountBalance'
62
+ }
63
+
64
+ CC_ON_FILE_ID = 1
65
+
66
+ # @param type [String] payment method
67
+ def initialize(type)
68
+ @type = type
69
+ end
70
+
71
+ class << self
72
+ def with_account_balance()
73
+ Payment::new(TYPES[:account_balance])
74
+ end
75
+ end
76
+ end
77
+
78
+ # Billing address
79
+ class BillingAddress < ApiSerializable
80
+ attr_reader :street, :street2, :city, :state, :zip, :country_alpha2
81
+ end
82
+
83
+ # Superclass for the business-line options that handles capture and common validation of inputs.
84
+ class InputOptions < ApiSerializable
85
+ # Mandatory, contains list of inputs. Must have at least one element.
86
+ attr_reader :inputs
87
+
88
+ # @param inputs [Array] list of inputs
89
+ # @param info [Hash] of fields to initialize instance.
90
+ def initialize(inputs, info = {})
91
+ super info
92
+ raise(ArgumentError, "inputs must have at least one element") unless validate_inputs(inputs)
93
+ @inputs = inputs
94
+ end
95
+
96
+ private
97
+
98
+ def validate_inputs(inputs)
99
+ !inputs.nil? && inputs.length > 0
100
+ end
101
+ end
102
+
103
+ # Transcription options. This section contains the input media that must be transferred to our servers
104
+ # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
105
+ # @see https://www.rev.com/api/ordersposttranscription
106
+ class TranscriptionOptions < InputOptions
107
+ # Optional, should we transcribe the provided files verbatim? If true,
108
+ # all filler words (i.e. umm, huh) will be included.
109
+ attr_reader :verbatim
110
+
111
+ # Optional, should we include timestamps?
112
+ attr_reader :timestamps
113
+
114
+ # @param inputs [Array] list of inputs
115
+ # @param info [Hash] of fields to initialize instance. May contain:
116
+ # - :verbatim => true/false
117
+ # - :timestamps => true/false
118
+ def initialize(inputs, info = {})
119
+ super inputs, info
120
+ options_validation(inputs)
121
+ end
122
+
123
+ private
124
+
125
+ def options_validation(inputs)
126
+ inputs.each { |input|
127
+ input.validate_glossary
128
+ input.validate_speakers
129
+ input.validate_accents
130
+ }
131
+ end
132
+ end
133
+
134
+ # Caption options. This section contains the input media that must be transferred to our servers
135
+ # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
136
+ # @see https://www.rev.com/api/orderspostcaption
137
+ class CaptionOptions < InputOptions
138
+ # Array of file formats the captions should be delivered as. (Optional, default is SubRip)
139
+ attr_reader :output_file_formats
140
+
141
+ # Optional, Array of language codes to request foreign language subtitles
142
+ attr_reader :subtitle_languages
143
+
144
+ # All supported output file formats
145
+ OUTPUT_FILE_FORMATS = {
146
+ :subrip => 'SubRip',
147
+ :scc => 'Scc',
148
+ :mcc => 'Mcc',
149
+ :ttml => 'Ttml',
150
+ :qttext => 'QTtext',
151
+ :transcript => 'Transcript',
152
+ :webvtt => 'WebVtt',
153
+ :dfxp => 'Dfxp',
154
+ :cheetahcap => 'CheetahCap'
155
+ }
156
+
157
+ # @param inputs [Array] list of inputs
158
+ # @param info [Hash] of fields to initialize instance. May contain:
159
+ # - :subtitle_languages
160
+ # @see For language codes refer to http://www.loc.gov/standards/iso639-2/php/code_list.php
161
+ def initialize(inputs, info = {})
162
+ super(inputs, info)
163
+ raise(ArgumentError, "invalid format(s)") unless validate_output_formats(info[:output_file_formats])
164
+ options_validation(inputs)
165
+ end
166
+
167
+ private
168
+
169
+ def validate_output_formats(formats)
170
+ formats.nil? || formats.select{|f| !OUTPUT_FILE_FORMATS.has_value?(f) }.empty?
171
+ end
172
+
173
+ def options_validation(inputs)
174
+ inputs.each { |input|
175
+ input.validate_glossary
176
+ input.validate_speakers
177
+ }
178
+ end
179
+ end
180
+
181
+ # Input for order (aka source file)
182
+ class Input < ApiSerializable
183
+ # Length of audio in seconds (mandatory in case of inability to determine it automatically).
184
+ # Used within {Rev::OrderRequest::TranscriptionInfo}
185
+ attr_reader :audio_length_seconds
186
+
187
+ # Length of video in seconds (mandatory in case of inability to determine it automatically).
188
+ # Used within {Rev::OrderRequest::CaptionInfo}
189
+ attr_reader :video_length_seconds
190
+
191
+ # Mandatory, URI of the media, as returned from the call to POST /inputs.
192
+ # :external_link might substitute :uri for Transcription or Caption.
193
+ attr_reader :uri
194
+
195
+ # External URL, if sources wasn't POSTed as input (YouTube, Vimeo, Dropbox, etc)
196
+ attr_reader :external_link
197
+
198
+ # Optional, list of glossary entries.
199
+ attr_reader :glossary
200
+
201
+ # Optional, list of speaker names.
202
+ attr_reader :speakers
203
+
204
+ # Optional, list of accents.
205
+ attr_reader :accents
206
+
207
+ SUPPORTED_ACCENTS = {
208
+ :american_neutral => 'AmericanNeutral',
209
+ :american_southern => 'AmericanSouthern',
210
+ :asian => 'Asian',
211
+ :australian => 'Australian',
212
+ :british => 'British',
213
+ :indian => 'Indian',
214
+ :other => 'Other',
215
+ :unknown => 'Unknown'
216
+ }
217
+
218
+ def validate_glossary
219
+ if glossary
220
+ if glossary.length > GLOSSARY_ENTRIES_LIMIT
221
+ raise(ArgumentError, "Glossary must not exceed #{GLOSSARY_ENTRIES_LIMIT} entries")
222
+ end
223
+ glossary.each { |term|
224
+ if term.length > GLOSSARY_ENTRY_LENGTH_LIMIT
225
+ raise(ArgumentError, "Glossary entries cannot exceed #{GLOSSARY_ENTRY_LENGTH_LIMIT} characters")
226
+ end
227
+ }
228
+ end
229
+ end
230
+
231
+ def validate_speakers
232
+ if speakers
233
+ if speakers.length > SPEAKER_ENTRIES_LIMIT
234
+ raise(ArgumentError, "Speaker list must not exceed #{SPEAKER_ENTRIES_LIMIT} entries")
235
+ end
236
+ speakers.each { |speaker|
237
+ if speaker.length > SPEAKER_ENTRY_LENGTH_LIMIT
238
+ raise(ArgumentError, "Speaker name cannot exceed #{SPEAKER_ENTRY_LENGTH_LIMIT} characters")
239
+ end
240
+ }
241
+ end
242
+ end
243
+
244
+ def validate_accents
245
+ if accents
246
+ if accents.length > SUPPORTED_ACCENTS.length
247
+ raise(ArgumentError, "Length of accents list cannot exceed number of supported accents.")
248
+ end
249
+ if accents.any?{ |accent| !Rev::Input::SUPPORTED_ACCENTS.has_value?(accent) }
250
+ raise(ArgumentError, 'Unsupported accent provided')
251
+ end
252
+ end
253
+ end
254
+ end
255
+
256
+ # Notification Info. Optionally you may request that an HTTP post be made to a url of your choice when the order enters
257
+ # a new status (eg being transcribed or reviewed) and when it is complete.
258
+ class Notification < ApiSerializable
259
+ attr_reader :url, :level
260
+
261
+ # Notification levels
262
+ LEVELS = {
263
+ :detailed => 'Detailed',
264
+ :final_only => 'FinalOnly'
265
+ }
266
+
267
+ # @param url [String] The url for notifications. Mandatory if the notifications element is used. Updates will be posted to this URL
268
+ # @param level [String] Optional, specifies which notifications are sent:
269
+ # - :detailed - a notification is sent whenever the order is in a new status or has a new comment
270
+ # - :final_only - (the default), notification is sent only when the order is complete
271
+ def initialize(url, level = nil)
272
+ @url = url
273
+ @level = level ? level : LEVELS[:final_only]
274
+ end
275
+ end
276
+ end