Class: SI::CopyscapeAPI
- Inherits:
-
Object
- Object
- SI::CopyscapeAPI
- Defined in:
- lib/copyscape_api.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username:, api_key:, api_url:) ⇒ CopyscapeAPI
constructor
A new instance of CopyscapeAPI.
- #request(operation:, params: {}, postdata: nil) ⇒ Object
Constructor Details
#initialize(username:, api_key:, api_url:) ⇒ CopyscapeAPI
Returns a new instance of CopyscapeAPI.
6 7 8 9 10 |
# File 'lib/copyscape_api.rb', line 6 def initialize username:, api_key:, api_url: @username ||= username @api_key ||= api_key @api_url ||= api_url end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/copyscape_api.rb', line 4 def api_key @api_key end |
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
4 5 6 |
# File 'lib/copyscape_api.rb', line 4 def api_url @api_url end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/copyscape_api.rb', line 4 def response @response end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/copyscape_api.rb', line 4 def username @username end |
Instance Method Details
#request(operation:, params: {}, postdata: nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/copyscape_api.rb', line 12 def request operation:, params: {}, postdata: nil uri_hash = { u: username, k: api_key, o: operation } uri_string = api_url + '?' + params.merge(uri_hash).map{|k,v| "#{k}=#{v}"}.join('&') uri = URI.parse(URI.encode(uri_string)) @response = _respond_to _call_api(uri, postdata) end |