Class: KindleHighlights::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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 = 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

Parameters:

  • value

    the value to set the attribute kindle_logged_in_page to.


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

Parameters:

  • value

    the value to set the attribute mechanize_agent to.


11
12
13
# File 'lib/kindle_highlights/client.rb', line 11

def mechanize_agent=(value)
  @mechanize_agent = value
end

Instance Method Details

#booksObject


21
22
23
# File 'lib/kindle_highlights/client.rb', line 21

def books
  @books ||= 
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