Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RDoc added for relevant methods.

  • Loading branch information...
commit 2b24b5059feb07ba5264a64e8e148c70b9225cca 1 parent f015f63
Chavez authored
View
4 .gitignore
@@ -17,4 +17,6 @@
coverage/*
coverage.data
-.rvmrc
+.rvmrc
+rdoc
+doc
View
2  README.rdoc
@@ -20,7 +20,7 @@ A wrapper around the Partner API calls. Allows post, priority post and get calls
req.priority_post { :keyword => 'Centaurs', :locale => 'en-us', :engine => 'google' }
-== Meta
+== License
Written by Chavez
View
2  lib/al_papi.rb
@@ -10,3 +10,5 @@ module AlPapi
require File.dirname(__FILE__) + '/al_papi/http'
require File.dirname(__FILE__) + '/al_papi/request'
require File.dirname(__FILE__) + '/al_papi/request_error'
+require File.dirname(__FILE__) + '/al_papi/locales'
+require File.dirname(__FILE__) + '/al_papi/engines'
View
12 lib/al_papi/config.rb
@@ -5,12 +5,14 @@ class Config
DEFAULT_HOST = 'http://api.authoritylabs.com'
DEFAULT_PORT = 80
- class << self
- attr_writer :api_key, :host, :port
- end
-
attr_reader :api_key, :host, :port
-
+
+ ##
+ #
+ # == Options
+ #
+ # [auth_key] Your Partner API api key. Required to make any API requests
+
def initialize(options = {})
@api_key = options[:api_key]
@host = DEFAULT_HOST
View
2  lib/al_papi/http.rb
@@ -1,6 +1,6 @@
module AlPapi
- class Http # :nodoc:
+ class Http # :nodoc:all:
def initialize(req)
@api_req, @config = req, req.config
View
50 lib/al_papi/request.rb
@@ -4,29 +4,77 @@ class Request
attr_accessor :response, :success, :errors
attr_reader :config
+
+ ##
+ #
+ # [config] * Hash { auth_key: 'your_auth_token' }
+ # * OR AlPapi::Config
def initialize(config)
@config = config.is_a?(AlPapi::Config) ? config : Config.new(config)
@success, @errors = false, []
end
- def http
+ def http # :nodoc:
Http.new(self)
end
+
+ ##
+ # == Params
+ #
+ # [keyword] <b>Required</b> -
+ # Your keyword you want to get results for
+ # [engine] <em>Optional</em> -
+ # Defaults to google. Allowed engines are google, yahoo, bing.
+ # [locale] <em>Optional</em> -
+ # Defaults to en-us. See AlPapi::Locales for supported locales.
+ # [pages_from] <em>Optional</em> -
+ # Default is false. Google specific parameter to get results from
+ # the locale passed in when set to true.
+ # [callback] <em>Optional</em> -
+ # Default is set on your account through the website.
+ # Set specific callbacks here for each request. Callback a url that
+ # is sent a POST when results are returned.
def post(params = {}, priority = false)
path = priority ? '/keywords/priority' : '/keyword'
http.post path, params
end
+ ##
+ # == Params
+ #
+ # See post for required params
+
def priority_post(params = {})
post params, true
end
+ ##
+ # == Params
+ #
+ # Parameters should be the same as what was posted to the Partner API where applies.
+ #
+ # [keyword] <b>Required</b> -
+ # The keyword you are ready to get results for.
+ # [engine] <em>Optional</em> -
+ # Defaults to google. Allowed engines are google, yahoo, bing.
+ # [locale] <em>Optional</em> -
+ # Defaults to en-us. See AlPapi::Locales for supported locales.
+ # [rank_date] <em>Optional</em> -
+ # Default is set to today UTC time.
+ # Date should be in format of YYYY-MM-DD ie. 2011-12-28
+ # [data_format] <em>Optional</em> -
+ # Default is JSON. Options are HTML or JSON.
+
def get(params = {})
http.get '/keywords/get', params
end
+ ##
+ #
+ # Convenience method to determine if request was successfull or not
+
def success?
return @success
end
View
2  lib/al_papi/request_error.rb
@@ -4,7 +4,7 @@ class RequestError
attr_reader :message, :code, :path, :params
- def initialize(_message, _code, _path, _params)
+ def initialize(_message, _code, _path, _params) # :nodoc:
@message, @code, @path, @params = _message, _code, _path, _params
end
Please sign in to comment.
Something went wrong with that request. Please try again.