Class: Fleakr::Api::MethodRequest
- Inherits:
-
Object
- Object
- Fleakr::Api::MethodRequest
- 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.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
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
-
#initialize(method, additional_parameters = {}) ⇒ MethodRequest
constructor
Create a new request for the specified API method and pass along any additional parameters.
-
#send ⇒ Object
:nodoc:.
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).
37 38 39 40 41 |
# File 'lib/fleakr/api/method_request.rb', line 37 def initialize(method, additional_parameters = {}) @parameters = ParameterList.new(additional_parameters) self.method = method end |
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
10 11 12 |
# File 'lib/fleakr/api/method_request.rb', line 10 def method @method end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
10 11 12 |
# File 'lib/fleakr/api/method_request.rb', line 10 def parameters @parameters 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
16 17 18 19 20 21 22 23 |
# File 'lib/fleakr/api/method_request.rb', line 16 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 |