diff --git a/Gemfile b/Gemfile
index a6f48e1..8a3059a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source :rubygems
+source 'https://rubygems.org'
gemspec
@@ -9,4 +9,4 @@ group :development do
gem "mocha", "0.9.8"
gem "blankslate", "~> 2.1.2.0"
gem "hanna", "~> 0.1.0"
-end
\ No newline at end of file
+end
diff --git a/lib/fleakr/api/method_request.rb b/lib/fleakr/api/method_request.rb
index 20d8bab..719a607 100644
--- a/lib/fleakr/api/method_request.rb
+++ b/lib/fleakr/api/method_request.rb
@@ -1,30 +1,30 @@
module Fleakr
module Api # :nodoc:
-
+
# = MethodRequest
- #
+ #
# Handles all API requests that are non-upload related. For upload requests see the
# UploadRequest class.
#
class MethodRequest
-
+
include Fleakr::Support::Request
-
+
attr_reader :method
-
+
# 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
+ # there are errors on the response it will raise an ApiError exception. See
# MethodRequest#new for details about the additional parameters
#
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.message}") if response.error?
response
end
-
+
# 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.
@@ -32,7 +32,7 @@ def self.with_response!(method, additional_parameters = {})
# 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 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).
@@ -41,25 +41,25 @@ def initialize(method, additional_parameters = {})
super(additional_parameters)
self.method = method
end
-
+
def method=(method) # :nodoc:
@method = method.sub(/^(flickr\.)?/, 'flickr.')
parameters.add_option(:method, @method)
end
def endpoint_url
- 'http://api.flickr.com/services/rest/'
+ 'https://api.flickr.com/services/rest/'
end
def send # :nodoc:
logger.info("Sending request to: #{endpoint_uri}")
response_xml = Net::HTTP.get(endpoint_uri)
logger.debug("Response data:\n#{response_xml}")
-
+
Response.new(response_xml)
end
-
+
end
-
+
end
-end
\ No newline at end of file
+end
diff --git a/lib/fleakr/api/upload_request.rb b/lib/fleakr/api/upload_request.rb
index b2d1657..9a405cc 100644
--- a/lib/fleakr/api/upload_request.rb
+++ b/lib/fleakr/api/upload_request.rb
@@ -1,75 +1,75 @@
module Fleakr
module Api # :nodoc:
-
+
# = UploadRequest
- #
+ #
# This implements the upload functionality of the Flickr API which is needed
# to create new photos and replace the photo content of existing photos
#
class UploadRequest
ENDPOINT_URIS = {
- :create => 'http://api.flickr.com/services/upload/',
- :update => 'http://api.flickr.com/services/replace/'
+ :create => 'https://api.flickr.com/services/upload/',
+ :update => 'https://api.flickr.com/services/replace/'
}
attr_reader :parameters, :type
# Send a request and return a Response object. If an API error occurs, this raises
- # a Fleakr::ApiError with the reason for the error. See UploadRequest#new for more
+ # a Fleakr::ApiError with the reason for the error. See UploadRequest#new for more
# details.
#
def self.with_response!(filename, type = :create, options = {})
request = self.new(filename, type, options)
response = request.send
-
+
raise(Fleakr::ApiError, "Code: #{response.error.code} - #{response.error.message}") if response.error?
response
end
-
+
# Create a new UploadRequest with the specified filename, type, and options. Type
# is one of :create or :update to specify whether we are saving a new
- # image or replacing an existing one.
+ # image or replacing an existing one.
#
# For a list of available options, see the documentation in Fleakr::Objects::Photo
#
def initialize(filename, type = :create, options = {})
@type = type
@options = options
-
+
@parameters = ParameterList.new(upload_options)
parameters.add_upload_option(:photo, filename)
end
-
+
# A list of upload options for this upload request (see Fleakr::Api::Option)
#
def upload_options
option_list = @options.map {|key, value| Option.for(key, value) }
option_list.inject({}) {|hash, option| hash.merge(option.to_hash)}
end
-
+
def headers # :nodoc:
{'Content-Type' => "multipart/form-data; boundary=#{self.parameters.boundary}"}
end
def send # :nodoc:
- response = Net::HTTP.start(endpoint_uri.host, endpoint_uri.port) do |http|
+ response = Net::HTTP.start(endpoint_uri.host, endpoint_uri.port) do |http|
logger.info("Sending upload request to: #{endpoint_uri}")
logger.debug("Request data:\n#{self.parameters.to_form}")
logger.debug("Request headers:\n#{self.headers.inspect}")
-
+
http.post(endpoint_uri.path, self.parameters.to_form, self.headers)
end
logger.debug("Response data:\n#{response.body}")
Response.new(response.body)
end
-
+
private
def endpoint_uri
@endpoint_uri ||= URI.parse(ENDPOINT_URIS[self.type])
end
end
-
+
end
-end
\ No newline at end of file
+end
diff --git a/test/unit/fleakr/api/method_request_test.rb b/test/unit/fleakr/api/method_request_test.rb
index 9d0003f..d984aa7 100644
--- a/test/unit/fleakr/api/method_request_test.rb
+++ b/test/unit/fleakr/api/method_request_test.rb
@@ -7,7 +7,7 @@ class MethodRequestTest < Test::Unit::TestCase
should "know the endpoint URL" do
request = MethodRequest.new('people.findByUsername')
- request.endpoint_url.should == 'http://api.flickr.com/services/rest/'
+ request.endpoint_url.should == 'https://api.flickr.com/services/rest/'
end
should "add the method name to the list of parameters" do
@@ -73,4 +73,4 @@ class MethodRequestTest < Test::Unit::TestCase
end
end
-end
\ No newline at end of file
+end
diff --git a/test/unit/fleakr/api/upload_request_test.rb b/test/unit/fleakr/api/upload_request_test.rb
index 581b9c4..59d2fbd 100644
--- a/test/unit/fleakr/api/upload_request_test.rb
+++ b/test/unit/fleakr/api/upload_request_test.rb
@@ -52,12 +52,12 @@ class UploadRequestTest < Test::Unit::TestCase
should "know the endpoint_uri" do
request = UploadRequest.new('filename')
- request.__send__(:endpoint_uri).should == URI.parse('http://api.flickr.com/services/upload/')
+ request.__send__(:endpoint_uri).should == URI.parse('https://api.flickr.com/services/upload/')
end
should "know the endpoint_uri for an :update request" do
request = UploadRequest.new('filename', :update)
- request.__send__(:endpoint_uri).should == URI.parse('http://api.flickr.com/services/replace/')
+ request.__send__(:endpoint_uri).should == URI.parse('https://api.flickr.com/services/replace/')
end
should "only parse the endpoint URI once" do
@@ -136,4 +136,4 @@ class UploadRequestTest < Test::Unit::TestCase
end
end
-end
\ No newline at end of file
+end