Class: Gazette::Client
- Inherits:
-
Object
- Object
- Gazette::Client
- Defined in:
- lib/gazette/client.rb
Overview
The Client class interacts with the Instapaper API. Client hold user authentication information, as well as provide methods to authenticate user credentials and add URLs to their user’s Instapaper account.
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#add(url, options = {}) ⇒ Response::Success
Adds a URL to a user’s instapaper account.
-
#authenticate(options = {}) ⇒ Response::Success
Attempts to authenticate the client’s user credentials with Instapaper.
-
#initialize(username, options = {}) ⇒ Client
constructor
Create a new client.
Constructor Details
#initialize(username, options = {}) ⇒ Client
Create a new client. Instapaper requires a user username. Most Instapaper users don’t have a password, as such it is optional.
26 27 28 29 30 31 32 |
# File 'lib/gazette/client.rb', line 26 def initialize(username, = {}) raise ArgumentError.new("2nd parameter must be a Hash") unless .is_a?(Hash) @username = username @password = .delete(:password) @options = @https = !!(.delete(:https)) end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
16 17 18 |
# File 'lib/gazette/client.rb', line 16 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
15 16 17 |
# File 'lib/gazette/client.rb', line 15 def username @username end |
Instance Method Details
#add(url, options = {}) ⇒ Response::Success
Adds a URL to a user’s instapaper account.
62 63 64 |
# File 'lib/gazette/client.rb', line 62 def add(url, = {}) parse_response_for request(:add, .merge(:url => url)) end |
#authenticate(options = {}) ⇒ Response::Success
Attempts to authenticate the client’s user credentials with Instapaper.
43 44 45 |
# File 'lib/gazette/client.rb', line 43 def authenticate( = {}) parse_response_for request(:authenticate, ) end |