Class: Heroku::Postgres::Client
- Inherits:
-
Object
- Object
- Heroku::Postgres::Client
- Defined in:
- lib/heroku/postgres/client.rb
Overview
Client for interacting with Heroku & Heroku’s Postgres API.
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'User-Agent' => 'Heroku-Postgres/v' \ "#{Heroku::Postgres::VERSION}" }
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
-
#login ⇒ String
Login on behalf of the user.
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/heroku/postgres/client.rb', line 10 def initialize(opts = {}) @url = opts.fetch(:url, 'https://api.heroku.com') @username = opts.fetch(:username, {}) @password = opts.fetch(:password, {}) end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/heroku/postgres/client.rb', line 8 def password @password end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/heroku/postgres/client.rb', line 8 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/heroku/postgres/client.rb', line 8 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/heroku/postgres/client.rb', line 8 def username @username end |
Instance Method Details
#login ⇒ String
Login on behalf of the user.
This is necessary to setup the class correctly so that the API key can be used.
22 23 24 25 26 27 |
# File 'lib/heroku/postgres/client.rb', line 22 def login response = login_request(username, password) hash = JSON.parse(response.body) @token = hash['api_key'] end |