Module: SdrClient::Login
- Defined in:
- lib/sdr_client/login.rb
Overview
The namespace for the “login” command
Constant Summary collapse
- LOGIN_PATH =
'/v1/auth/login'
Class Method Summary collapse
-
.run(url:, login_service: LoginPrompt, credential_store: Credentials) ⇒ Result
The status of the call.
Class Method Details
.run(url:, login_service: LoginPrompt, credential_store: Credentials) ⇒ Result
Returns the status of the call.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sdr_client/login.rb', line 10 def self.run(url:, login_service: LoginPrompt, credential_store: Credentials) request_json = JSON.generate(login_service.run) response = Faraday.post(url + LOGIN_PATH, request_json, 'Content-Type' => 'application/json') case response.status when 200 credential_store.write(response.body) Success() when 400 Failure('Email address is not a valid email') when 401 Failure('Invalid username or password') else Failure("Status: #{response.status}\n#{response.body}") end end |