Class: CloudConvertMergePdf::Merge
- Inherits:
-
Object
- Object
- CloudConvertMergePdf::Merge
- Defined in:
- lib/cloud_convert_merge_pdf/merge.rb
Overview
CloudConvertMergePdf::Merge
Instance Attribute Summary collapse
-
#download_url ⇒ Object
readonly
Returns the value of attribute download_url.
Instance Method Summary collapse
- #call ⇒ Object
- #download ⇒ Object
- #fetch_process_url ⇒ Object
-
#initialize(files, download = true) ⇒ Merge
constructor
A new instance of Merge.
- #process ⇒ Object
Constructor Details
#initialize(files, download = true) ⇒ Merge
Returns a new instance of Merge.
13 14 15 16 17 18 19 |
# File 'lib/cloud_convert_merge_pdf/merge.rb', line 13 def initialize(files, download = true) @connection = Faraday.new( url: CloudConvertMergePdf::CLOUD_CONVERT_ENDPOINT ) @files = files @can_download = download end |
Instance Attribute Details
#download_url ⇒ Object (readonly)
Returns the value of attribute download_url.
11 12 13 |
# File 'lib/cloud_convert_merge_pdf/merge.rb', line 11 def download_url @download_url end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cloud_convert_merge_pdf/merge.rb', line 21 def call api_key = CloudConvertMergePdf.configuration.api_key return CloudConvertMergePdf::API_KEY_ERROR if api_key.nil? fetch_process_url process download end |
#download ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/cloud_convert_merge_pdf/merge.rb', line 48 def download response = @connection.get @download_url return parse_response(response.body) if response.status != 200 return clean_url(@download_url) unless @can_download combined_pdf(response.body) end |
#fetch_process_url ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/cloud_convert_merge_pdf/merge.rb', line 31 def fetch_process_url response = @connection.post '/process', process_url_params parsed_response = parse_response(response.body) @process_url = parsed_response['url'] end |
#process ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/cloud_convert_merge_pdf/merge.rb', line 39 def process response = @connection.post @process_url, process_params parsed_response = parse_response(response.body) return nil if parsed_response['output'].nil? @download_url = parsed_response['output']['url'] end |