Class: Animoto::Client
- Inherits:
-
Object
- Object
- Animoto::Client
- Defined in:
- lib/animoto/client.rb
Constant Summary collapse
- API_ENDPOINT =
The default endpoint where requests go.
"https://platform-sandbox.animoto.com/"
- API_VERSION =
The version of the Animoto API this client targets.
1
- BASE_CONTENT_TYPE =
The common prefix all vendor-specific Animoto content types share.
"application/vnd.animoto"
Instance Attribute Summary collapse
-
#endpoint ⇒ String
The base URL where all requests will be sent.
-
#http_engine ⇒ HTTPEngines::Base
The engine to handle HTTP requests.
-
#key ⇒ String
Your API key.
-
#logger ⇒ Logger
A logger.
-
#response_parser ⇒ ResponseParsers::Base
The engine to handle parsing XML or JSON responses.
-
#secret ⇒ String
Your API secret.
Instance Method Summary collapse
-
#bundle!(manifest, options = {}) ⇒ Jobs::StoryboardBundling
Sends a request to bundle a storyboard.
-
#delete!(resource, options = {}) ⇒ Boolean
Delete a resource.
-
#direct!(manifest, options = {}) ⇒ Jobs::Directing
Sends a request to start directing a storyboard.
-
#direct_and_render!(manifest, options = {}) ⇒ Jobs::DirectingAndRendering
Sends a request to start directing and rendering a video.
-
#find(klass, url, options = {}) ⇒ Resources::Base
Finds a resource by its URL.
-
#initialize(*args) ⇒ Client
constructor
Creates a new Client object which handles credentials, versioning, making requests, and parsing responses.
-
#reload!(resource, options = {}) ⇒ Resources::Base
Update a resource with the latest attributes.
-
#render!(manifest, options = {}) ⇒ Jobs::Rendering
Sends a request to start rendering a video.
-
#unbundle!(manifest, options = {}) ⇒ Jobs::StoryboardUnbundling
Sends a request to unbundle a storyboard.
Constructor Details
#initialize(*args) ⇒ Client
Creates a new Client object which handles credentials, versioning, making requests, and parsing responses.
If you have your key and secret in ~/.animotorc or /etc/.animotorc, those credentials will be read from those files (in that order) whenever you make a new Client if you don’t specify them explicitly. You can also specify the endpoint (staging, sandbox, etc.) in the rc file. The default endpoint will be used if one isn’t specified.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/animoto/client.rb', line 111 def initialize *args = args.last.is_a?(Hash) ? args.pop : {} @key = args[0] @secret = args[1] @endpoint = [:endpoint] @logger = [:logger] || ::Logger.new(STDOUT) configure_from_rc_file @endpoint ||= API_ENDPOINT self.http_engine = [:http_engine] || :net_http self.response_parser= [:response_parser] || :json end |
Instance Attribute Details
#endpoint ⇒ String
The base URL where all requests will be sent.
60 61 62 |
# File 'lib/animoto/client.rb', line 60 def endpoint @endpoint end |
#http_engine ⇒ HTTPEngines::Base #http_engine=(engine) ⇒ HTTPEngines::Base
The engine to handle HTTP requests.
81 82 83 |
# File 'lib/animoto/client.rb', line 81 def http_engine @http_engine end |
#key ⇒ String
Your API key.
52 53 54 |
# File 'lib/animoto/client.rb', line 52 def key @key end |
#logger ⇒ Logger
A logger.
64 65 66 |
# File 'lib/animoto/client.rb', line 64 def logger @logger end |
#response_parser ⇒ ResponseParsers::Base #response_parser=(parser) ⇒ ResponseParsers::Base
The engine to handle parsing XML or JSON responses.
97 98 99 |
# File 'lib/animoto/client.rb', line 97 def response_parser @response_parser end |
#secret ⇒ String
Your API secret.
56 57 58 |
# File 'lib/animoto/client.rb', line 56 def secret @secret end |
Instance Method Details
#bundle!(manifest, options = {}) ⇒ Jobs::StoryboardBundling
Sends a request to bundle a storyboard.
195 196 197 |
# File 'lib/animoto/client.rb', line 195 def bundle! manifest, = {} Resources::Jobs::StoryboardBundling.load(send_manifest(manifest, Resources::Jobs::StoryboardBundling.endpoint, )) end |
#delete!(resource, options = {}) ⇒ Boolean
Delete a resource. May not supported for all types of resources.
223 224 225 |
# File 'lib/animoto/client.rb', line 223 def delete! resource, = {} request(:delete, resource.url, nil) end |
#direct!(manifest, options = {}) ⇒ Jobs::Directing
Sends a request to start directing a storyboard.
168 169 170 |
# File 'lib/animoto/client.rb', line 168 def direct! manifest, = {} Resources::Jobs::Directing.load(send_manifest(manifest, Resources::Jobs::Directing.endpoint, )) end |
#direct_and_render!(manifest, options = {}) ⇒ Jobs::DirectingAndRendering
Sends a request to start directing and rendering a video.
186 187 188 |
# File 'lib/animoto/client.rb', line 186 def direct_and_render! manifest, = {} Resources::Jobs::DirectingAndRendering.load(send_manifest(manifest, Resources::Jobs::DirectingAndRendering.endpoint, )) end |
#find(klass, url, options = {}) ⇒ Resources::Base
Finds a resource by its URL.
159 160 161 |
# File 'lib/animoto/client.rb', line 159 def find klass, url, = {} klass.load(find_request(klass, url, )) end |
#reload!(resource, options = {}) ⇒ Resources::Base
Update a resource with the latest attributes. Useful to update the state of a Job to see if it’s ready if you are not using HTTP callbacks.
214 215 216 |
# File 'lib/animoto/client.rb', line 214 def reload! resource, = {} resource.load(find_request(resource.class, resource.url, )) end |
#render!(manifest, options = {}) ⇒ Jobs::Rendering
Sends a request to start rendering a video.
177 178 179 |
# File 'lib/animoto/client.rb', line 177 def render! manifest, = {} Resources::Jobs::Rendering.load(send_manifest(manifest, Resources::Jobs::Rendering.endpoint, )) end |
#unbundle!(manifest, options = {}) ⇒ Jobs::StoryboardUnbundling
Sends a request to unbundle a storyboard.
204 205 206 |
# File 'lib/animoto/client.rb', line 204 def unbundle! manifest, = {} Resources::Jobs::StoryboardUnbundling.load(send_manifest(manifest, Resources::Jobs::StoryboardUnbundling.endpoint, )) end |