Class: KindleHighlights::Client
- Inherits:
-
Object
- Object
- KindleHighlights::Client
- Defined in:
- lib/kindle_highlights/client.rb
Defined Under Namespace
Classes: AsinNotFoundError, AuthenticationError, CaptchaError
Constant Summary collapse
- KINDLE_LOGIN_PAGE =
"https://read.amazon.com/notebook"
- SIGNIN_FORM_IDENTIFIER =
"signIn"
- MAX_AUTH_RETRIES =
2
Instance Attribute Summary collapse
-
#kindle_logged_in_page ⇒ Object
writeonly
Sets the attribute kindle_logged_in_page.
-
#mechanize_agent ⇒ Object
writeonly
Sets the attribute mechanize_agent.
Instance Method Summary collapse
- #books ⇒ Object
- #highlights_for(asin) ⇒ Object
-
#initialize(email_address:, password:, mechanize_options: {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(email_address:, password:, mechanize_options: {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 |
# File 'lib/kindle_highlights/client.rb', line 13 def initialize(email_address:, password:, mechanize_options: {}) @email_address = email_address @password = password @mechanize_options = @retries = 0 @kindle_logged_in_page = nil end |
Instance Attribute Details
#kindle_logged_in_page=(value) ⇒ Object
Sets the attribute kindle_logged_in_page
11 12 13 |
# File 'lib/kindle_highlights/client.rb', line 11 def kindle_logged_in_page=(value) @kindle_logged_in_page = value end |
#mechanize_agent=(value) ⇒ Object
Sets the attribute mechanize_agent
11 12 13 |
# File 'lib/kindle_highlights/client.rb', line 11 def mechanize_agent=(value) @mechanize_agent = value end |
Instance Method Details
#books ⇒ Object
21 22 23 |
# File 'lib/kindle_highlights/client.rb', line 21 def books @books ||= load_books_from_kindle_account end |
#highlights_for(asin) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/kindle_highlights/client.rb', line 25 def highlights_for(asin) if book = books.detect { |book| book.asin == asin } book.highlights_from_amazon else raise AsinNotFoundError, "Book with ASIN #{asin} not found." end end |