Class: ElasticTranscoder::Utilities

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_transcoder/utilities.rb

Constant Summary collapse

@@api_version =
"2012-09-25"
@@host =
"elastictranscoder.us-east-1.amazonaws.com"

Instance Method Summary collapse

Instance Method Details

#build_url(action) ⇒ Object



20
21
22
# File 'lib/elastic_transcoder/utilities.rb', line 20

def build_url action
  "https://#{@@host}/#{@@api_version}/#{action}"
end

#execute_delete(url, headers) ⇒ Object



31
32
33
# File 'lib/elastic_transcoder/utilities.rb', line 31

def execute_delete url, headers
  HTTParty.delete url, :headers=>headers
end

#execute_get(url, headers) ⇒ Object



24
25
26
# File 'lib/elastic_transcoder/utilities.rb', line 24

def execute_get url, headers
  HTTParty.get url, :headers=>headers
end

#execute_post(url, headers, body) ⇒ Object



27
28
29
# File 'lib/elastic_transcoder/utilities.rb', line 27

def execute_post url, headers, body
  HTTParty.post url, :body=>body, :headers=>headers
end

#initialize_headers(action, options = {}) ⇒ Object

options could be [method, payload]



11
12
13
14
15
16
17
18
# File 'lib/elastic_transcoder/utilities.rb', line 11

def initialize_headers action, options = {}
  amz_credentials = ElasticTranscoder::Transcoder::Base.amazon_credentials
  authorization, date = ElasticTranscoder::Transcoder::Authentication.build_authorization amz_credentials[:aws_access_key_id], amz_credentials[:aws_secret_access_key], @@host, options[:method], action, "2012-09-25", {}, options[:payload]
  headers = {"Authorization"=> authorization,
              "x-amz-date"=>date,
              "Content-Length"=>"#{options[:payload].size}"}
  return headers
end