Class: Episodic::Platform::CreateUpdateEpisodeResponse

Inherits:
WriteResponse show all
Defined in:
lib/episodic/platform/write_methods.rb

Overview

Extends Episodic::Platform::WriteResponse to add methods for getting upload information.

Instance Method Summary collapse

Methods inherited from WriteResponse

#method_missing, #respond_to?

Methods inherited from Response

#xml

Constructor Details

#initialize(response) ⇒ CreateUpdateEpisodeResponse

Override to define array elements.

Parameters

response<Episodic::Platform::HTTPResponse>

The response object returned from an Episodic Platform API request.



376
377
378
# File 'lib/episodic/platform/write_methods.rb', line 376

def initialize(response)
  super(response, "ForceArray" => ["upload"])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Episodic::Platform::WriteResponse

Instance Method Details

#upload_for_filepath(filepath) ⇒ Object

Get the pending upload information for a specific file expressed by file path. The object returned from this method can be passed to Episodic::Platform::WriteMethods.upload_file_for_episode.

Parameters

filepath<String>

The path to the file to be uploaded.

Returns

Hash

A hash with the filepath (passed in) and the corresponding upload params



410
411
412
413
414
415
416
# File 'lib/episodic/platform/write_methods.rb', line 410

def upload_for_filepath filepath 
  filename = File.basename(filepath)
  
  upload = uploads.detect{|u| u.filename == filename}
  
  return upload ? {:filepath => filepath, :upload => upload} : nil
end

#uploadsObject

Get the array of Upload objects that represent the pending uploads

Returns

Array

An array of Upload objects



387
388
389
390
391
392
393
394
395
396
# File 'lib/episodic/platform/write_methods.rb', line 387

def uploads
  unless @uploads
    @uploads = []
    @parsed_body["upload"].each do |upload|
      @uploads << Upload.new(upload) 
    end unless @parsed_body["upload"].nil?
  end
  
  return @uploads
end