Class: Fleakr::Api::MethodRequest
- Inherits:
-
Object
- Object
- Fleakr::Api::MethodRequest
- Includes:
- Support::Request
- Defined in:
- lib/fleakr/api/method_request.rb
Overview
MethodRequest
Handles all API requests that are non-upload related. For upload requests see the UploadRequest class.
Instance Attribute Summary collapse
-
#method ⇒ Object
Returns the value of attribute method.
Attributes included from Support::Request
Class Method Summary collapse
-
.with_response!(method, additional_parameters = {}) ⇒ Object
Makes a request to the Flickr API and returns a valid Response object.
Instance Method Summary collapse
- #endpoint_url ⇒ Object
-
#initialize(method, additional_parameters = {}) ⇒ MethodRequest
constructor
Create a new request for the specified API method and pass along any additional parameters.
-
#send ⇒ Object
:nodoc:.
Methods included from Support::Request
Constructor Details
#initialize(method, additional_parameters = {}) ⇒ MethodRequest
Create a new request for the specified API method and pass along any additional parameters. The Flickr API uses namespacing for its methods - this is optional when calling this method.
This must be called after initializing the library with the required API key see (#Fleakr.api_key=)
The additional_parameters
is a list of parameters to pass directly to the Flickr API call. The exception to this is the :authenticate?
option that will force the call to not be authenticated if it is set to false (The default behavior is to authenticate all calls when we have a token).
40 41 42 43 |
# File 'lib/fleakr/api/method_request.rb', line 40 def initialize(method, additional_parameters = {}) super(additional_parameters) self.method = method end |
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
13 14 15 |
# File 'lib/fleakr/api/method_request.rb', line 13 def method @method end |
Class Method Details
.with_response!(method, additional_parameters = {}) ⇒ Object
Makes a request to the Flickr API and returns a valid Response object. If there are errors on the response it will raise an ApiError exception. See MethodRequest#new for details about the additional parameters
19 20 21 22 23 24 25 26 |
# File 'lib/fleakr/api/method_request.rb', line 19 def self.with_response!(method, additional_parameters = {}) request = self.new(method, additional_parameters) response = request.send raise(Fleakr::ApiError, "Code: #{response.error.code} - #{response.error.}") if response.error? response end |
Instance Method Details
#endpoint_url ⇒ Object
50 51 52 |
# File 'lib/fleakr/api/method_request.rb', line 50 def endpoint_url 'http://api.flickr.com/services/rest/' end |