Class: EncodingDotCom::Connection
- Inherits:
-
Object
- Object
- EncodingDotCom::Connection
- Includes:
- HTTParty
- Defined in:
- lib/encoding_dot_com/connection.rb
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.s3_key ⇒ Object
Returns the value of attribute s3_key.
-
.s3_secret ⇒ Object
Returns the value of attribute s3_secret.
-
.user_id ⇒ Object
Returns the value of attribute user_id.
-
.user_key ⇒ Object
Returns the value of attribute user_key.
Class Method Summary collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
38 39 40 |
# File 'lib/encoding_dot_com/connection.rb', line 38 def logger @logger end |
.s3_key ⇒ Object
Returns the value of attribute s3_key.
38 39 40 |
# File 'lib/encoding_dot_com/connection.rb', line 38 def s3_key @s3_key end |
.s3_secret ⇒ Object
Returns the value of attribute s3_secret.
38 39 40 |
# File 'lib/encoding_dot_com/connection.rb', line 38 def s3_secret @s3_secret end |
.user_id ⇒ Object
Returns the value of attribute user_id.
38 39 40 |
# File 'lib/encoding_dot_com/connection.rb', line 38 def user_id @user_id end |
.user_key ⇒ Object
Returns the value of attribute user_key.
38 39 40 |
# File 'lib/encoding_dot_com/connection.rb', line 38 def user_key @user_key end |
Class Method Details
.call(request_xml_document) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/encoding_dot_com/connection.rb', line 40 def call(request_xml_document) if logger logger.info("Sending encoding.com request:\n#{request_xml_document}") end response = post('/', :body => {:xml => request_xml_document}) if logger logger.info("Received encoding.com response:\n#{response.inspect}") end response = response['response'] if response['errors'] = response['errors']['error'] case when /Wrong XML/, /No XML/, /Wrong query format/, /Invalid action/, /No formats specified/, /No output format specified/, /Output format .* is not allowed/ raise(BadRequestError.new(, request_xml_document)) when /Wrong user id or key/ raise(AuthenticationError.new(, request_xml_document)) when /Media ID is not indicated/, /Wrong Media ID/ raise(NotFoundError.new(, request_xml_document)) when /Wrong source file url/, /Source file is not indicated/ raise(BadSourceUrlError.new(, request_xml_document)) when /Wrong destination file url/ raise(BadDestinationUrlError.new(, request_xml_document)) else raise(EncodingDotComError.new(, request_xml_document)) end end response end |