Class: CloudConvert::Client
- Includes:
- HTTMultiParty
- Defined in:
- lib/cloud_convert/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
The api key obtained from the cloud convert service.
-
#processes ⇒ Object
readonly
An array containing references to the processes created through the client.
-
#return_type ⇒ Object
Returns the value of attribute return_type.
Instance Method Summary collapse
-
#build_process(opts = {}) ⇒ Object
Builds a process object and adds it to the client.
-
#initialize(args = {}) ⇒ Client
constructor
Creates a new client with an api key.
-
#list ⇒ Object
Returns an array of hash with the results from the Cloud Convert list endpoint.
Constructor Details
#initialize(args = {}) ⇒ Client
Creates a new client with an api key. Optionally, you can also pass an array of processes.
24 25 26 27 28 29 30 |
# 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 |
Instance Attribute Details
#api_key ⇒ Object (readonly)
The api key obtained from the cloud convert service.
16 17 18 |
# File 'lib/cloud_convert/client.rb', line 16 def api_key @api_key end |
#processes ⇒ Object (readonly)
An array containing references to the processes created through the client.
19 20 21 |
# File 'lib/cloud_convert/client.rb', line 19 def processes @processes end |
#return_type ⇒ Object
Returns the value of attribute return_type.
20 21 22 |
# File 'lib/cloud_convert/client.rb', line 20 def return_type @return_type end |
Instance Method Details
#build_process(opts = {}) ⇒ Object
Builds a process object and adds it to the client. Accepts the input format and output format for the conversion.
34 35 36 37 38 39 |
# 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 ⇒ Object
Returns an array of hash with the results from the Cloud Convert list endpoint.
43 44 45 46 47 |
# File 'lib/cloud_convert/client.rb', line 43 def list url = "#{CloudConvert::PROTOCOL}://api.#{CloudConvert::DOMAIN}/processes" response = CloudConvert::Client.send(:get, url, query: {apikey: self.api_key}) return convert_response response end |