Sha256: 9ba9fae49f9e80f9d6d265ac0331ccd8bfbcc8b1a24e46b8663b4fc07d1d0f2b

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'instapaper/api'
require 'instapaper/http/utils'
require 'instapaper/version'

module Instapaper
  # Wrapper for the Instapaper REST API
  class Client
    include Instapaper::API
    include Instapaper::HTTP::Utils

    attr_accessor :oauth_token, :oauth_token_secret, :consumer_key, :consumer_secret, :proxy
    attr_writer :user_agent

    # Initializes a new Client object
    #
    # @param options [Hash]
    # @return [Instapaper::Client]
    def initialize(options = {})
      options.each do |key, value|
        instance_variable_set("@#{key}", value)
      end
      yield(self) if block_given?
    end

    # @return [String]
    def user_agent
      @user_agent ||= "InstapaperRubyGem/#{Instapaper::VERSION}"
    end

    # Authentication hash
    #
    # @return [Hash]
    def credentials
      {
        consumer_key: @consumer_key,
        consumer_secret: @consumer_secret,
        oauth_token: @oauth_token,
        oauth_token_secret: @oauth_token_secret,
      }
    end

    # @return [Hash]
    def consumer_credentials
      {
        consumer_key: @consumer_key,
        consumer_secret: @consumer_secret,
      }
    end

    # @return [Boolean]
    def credentials?
      credentials.values.all?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
instapaper-1.0.0 lib/instapaper/client.rb
instapaper-1.0.0.pre3 lib/instapaper/client.rb
instapaper-1.0.0.pre2 lib/instapaper/client.rb