Sha256: 96d99afe26a3284c31047a88bfa05b7311cdb66091e7a27f8d11e273334be285
Contents?: true
Size: 831 Bytes
Versions: 3
Compression:
Stored size: 831 Bytes
Contents
# frozen_string_literal: true module SdrClient class RedesignedClient # Fetch a token from the SDR API using user credentials class Authenticator def self.token new.token end # Request an access_token def token response = connection.post(path, request_body) UnexpectedResponse.call(response) unless response.success? JSON.parse(response.body)['token'] end private def request_body JSON.generate( { email: SdrClient::RedesignedClient.config.email, password: SdrClient::RedesignedClient.config.password } ) end def path '/v1/auth/login' end def connection Faraday.new(url: SdrClient::RedesignedClient.config.url) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems