Class: Resizor::ResizorConnection
- Inherits:
-
Object
- Object
- Resizor::ResizorConnection
- Defined in:
- lib/resizor/connection.rb
Instance Attribute Summary collapse
-
#api_host ⇒ Object
Returns the value of attribute api_host.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_port ⇒ Object
Returns the value of attribute api_port.
-
#cdn_host ⇒ Object
Returns the value of attribute cdn_host.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
Instance Method Summary collapse
- #api_url(force_http = false) ⇒ Object
- #delete(request_uri, params = {}, append_api_key = true) ⇒ Object
- #get(request_uri, params = {}, append_api_key = true) ⇒ Object
-
#initialize(options = {}) ⇒ ResizorConnection
constructor
A new instance of ResizorConnection.
- #post(request_uri, params = {}, append_api_key = true) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ResizorConnection
Returns a new instance of ResizorConnection.
6 7 8 9 10 11 12 |
# File 'lib/resizor/connection.rb', line 6 def initialize(={}) @api_host = [:api_host] || ['api_host'] || 'resizor.com' @api_port = [:api_port] || ['api_port'] || 80 @api_key = [:api_key] || ['api_key'] @use_ssl = [:use_ssl] || ['use_ssl'] || true @cdn_host = [:cdn_host] || ['cdn_host'] end |
Instance Attribute Details
#api_host ⇒ Object
Returns the value of attribute api_host.
4 5 6 |
# File 'lib/resizor/connection.rb', line 4 def api_host @api_host end |
#api_key ⇒ Object
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/resizor/connection.rb', line 4 def api_key @api_key end |
#api_port ⇒ Object
Returns the value of attribute api_port.
4 5 6 |
# File 'lib/resizor/connection.rb', line 4 def api_port @api_port end |
#cdn_host ⇒ Object
Returns the value of attribute cdn_host.
4 5 6 |
# File 'lib/resizor/connection.rb', line 4 def cdn_host @cdn_host end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
4 5 6 |
# File 'lib/resizor/connection.rb', line 4 def use_ssl @use_ssl end |
Instance Method Details
#api_url(force_http = false) ⇒ Object
37 38 39 |
# File 'lib/resizor/connection.rb', line 37 def api_url(force_http = false) "#{(@use_ssl == true && force_http == false) ? 'https' : 'http'}://#{@api_host}:#{(@use_ssl == true && force_http == false) ? '443' : @api_port}" end |
#delete(request_uri, params = {}, append_api_key = true) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/resizor/connection.rb', line 29 def delete(request_uri, params={}, append_api_key=true) params[:api_key] = @api_key if append_api_key query = make_query(params) do_request do make_response_for resource[request_uri + '?' + query].delete end end |
#get(request_uri, params = {}, append_api_key = true) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/resizor/connection.rb', line 14 def get(request_uri, params={}, append_api_key=true) params[:api_key] = @api_key if append_api_key query = make_query(params) do_request do make_response_for resource[request_uri + '?' + query].get end end |
#post(request_uri, params = {}, append_api_key = true) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/resizor/connection.rb', line 22 def post(request_uri, params={}, append_api_key=true) params[:api_key] = @api_key if append_api_key do_request do make_response_for resource[request_uri].post params end end |