Class: WeShipClient::TokenClient
- Defined in:
- lib/we_ship_client/token_client.rb
Constant Summary
Constants inherited from Client
Instance Attribute Summary
Attributes inherited from Client
Instance Method Summary collapse
-
#generate_access_token ⇒ String
The access token.
Methods inherited from Client
Constructor Details
This class inherits a constructor from WeShipClient::Client
Instance Method Details
#generate_access_token ⇒ String
Returns The access token.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/we_ship_client/token_client.rb', line 11 def generate_access_token response = http_client.post( "#{base_url}/token", data: { username: ENV['WE_SHIP_USERNAME'], password: ENV['WE_SHIP_PASSWORD'] } ) raise_token_generation_exception(response) unless response.status == 200 JSON.parse(response.body)['access_token'] end |