class CloudConvert::Client
Attributes
api_key[R]
The api key obtained from the cloud convert service.
processes[R]
An array containing references to the processes created through the client.
return_type[RW]
Public Class Methods
new(args = {})
click to toggle source
Creates a new client with an api key. Optionally, you can also pass an array of processes.
# File lib/cloud_convert/client.rb, line 24 def initialize(args = {}) @api_key = args[:api_key] args[:processes].nil? ? @processes = [] : @processes = args[:processes] @return_type = args[:return_type] || :json end
Public Instance Methods
build_process(opts = {})
click to toggle source
Builds a process object and adds it to the client. Accepts the input format and output format for the conversion.
# File lib/cloud_convert/client.rb, line 34 def build_process(opts = {}) opts[:client] = self process = CloudConvert::Process.new(opts) processes.push(process) return process end
list()
click to toggle source
Returns an array of hash with the results from the Cloud Convert list endpoint.
# File lib/cloud_convert/client.rb, line 43 def list url = "#{CloudConvert::PROTOCOL}://#{CloudConvert::API_DOMAIN}/processes" response = CloudConvert::Client.send(:get, url, {query: {apikey: self.api_key}}) return convert_response response end
Private Instance Methods
convert_response(response)
click to toggle source
# File lib/cloud_convert/client.rb, line 51 def convert_response(response) return response.response if self.return_type == :response return response.parsed_response.deep_symbolize end