Sha256: d00b8362b847ac3342454f8a8fc1b16329bbdb740e7bb14eeebc26d25bb34d6e

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

class Rhapsody::Client
  attr_accessor :api_key,
                :api_secret,
                :redirect_uri,
                :username,
                :password,
                :state,
                :auth_code,
                :authentication

  def initialize(options)
    # TODO: verify options
    options.each do |name, value|
      instance_variable_set("@#{name}", value)
    end
  end

  def password_grant
    @authentication = Rhapsody::Authentication.new({ client: self })
    @authentication.password_grant
  end

  def authorization_url
    default = Rhapsody::Request::HOST_URL + "/oauth/authorize?client_id=#{@api_key}&redirect_uri=#{@redirect_uri}&response_type=code"

    if @state
      default + "&state=#{@state}"
    else
      default
    end
  end

  def connect
    @authentication = Rhapsody::Authentication.new({ client: self })
    @authentication.connect
  end

  def renew
    if @authentication
      @authentication.renew
    end
    # TODO Need to handle, authentication
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rhapsody-0.1.1 lib/rhapsody/client.rb