Class: Instapaper::Client

Inherits:
Object
  • Object
show all
Includes:
API, HTTP::Utils
Defined in:
lib/instapaper/client.rb

Overview

Wrapper for the Instapaper REST API

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from API::OAuth

#access_token

Methods included from API::Highlights

#add_highlight, #delete_highlight, #highlights

Methods included from API::Folders

#add_folder, #delete_folder, #folders, #set_order

Methods included from API::Bookmarks

#add_bookmark, #archive_bookmark, #bookmarks, #delete_bookmark, #get_text, #move_bookmark, #star_bookmark, #unarchive_bookmark, #unstar_bookmark, #update_read_progress

Methods included from API::Accounts

#verify_credentials

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Instapaper::Client

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
23
24
25
# File 'lib/instapaper/client.rb', line 18

def initialize(options = {})
  @oauth_token = options[:oauth_token]
  @oauth_token_secret = options[:oauth_token_secret]
  @consumer_key = options[:consumer_key]
  @consumer_secret = options[:consumer_secret]
  @proxy = options[:proxy]
  yield(self) if block_given?
end

Instance Attribute Details

#consumer_keyObject

Returns the value of attribute consumer_key.



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

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret.



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

def consumer_secret
  @consumer_secret
end

#oauth_tokenObject

Returns the value of attribute oauth_token.



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

def oauth_token
  @oauth_token
end

#oauth_token_secretObject

Returns the value of attribute oauth_token_secret.



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

def oauth_token_secret
  @oauth_token_secret
end

#proxyObject

Returns the value of attribute proxy.



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

def proxy
  @proxy
end

#user_agentString

Returns:

  • (String)


28
29
30
# File 'lib/instapaper/client.rb', line 28

def user_agent
  @user_agent ||= "InstapaperRubyGem/#{Instapaper::VERSION}"
end

Instance Method Details

#consumer_credentialsHash

Returns:

  • (Hash)


45
46
47
48
49
50
# File 'lib/instapaper/client.rb', line 45

def consumer_credentials
  {
    consumer_key: @consumer_key,
    consumer_secret: @consumer_secret,
  }
end

#credentialsHash

Authentication hash

Returns:

  • (Hash)


35
36
37
38
39
40
41
42
# File 'lib/instapaper/client.rb', line 35

def credentials
  {
    consumer_key: @consumer_key,
    consumer_secret: @consumer_secret,
    oauth_token: @oauth_token,
    oauth_token_secret: @oauth_token_secret,
  }
end

#credentials?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/instapaper/client.rb', line 53

def credentials?
  credentials.values.all?
end