class Alloy::KYC::Backends::Remote
Attributes
bearer_token[R]
Public Instance Methods
conn()
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 8 def conn if @conn.nil? @conn = Faraday.new(url: "#{Alloy::KYC.configuration.api_endpoint}") @conn.options.open_timeout = Alloy::KYC.configuration.open_timeout @conn.options.timeout = Alloy::KYC.configuration.read_timeout end @conn end
create_evaluation(params)
click to toggle source
domain methods
# File lib/alloy/kyc/backends/remote.rb, line 35 def create_evaluation(params) post("evaluations", params) end
fork_evaluation(path)
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 43 def fork_evaluation(path) post(path) end
get(url, options={})
click to toggle source
http-level methods
# File lib/alloy/kyc/backends/remote.rb, line 48 def get(url, options={}) set_auth_header conn.get(url, options) end
get_bearer_token()
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 17 def get_bearer_token conn.basic_auth(Alloy::KYC.configuration.application_token, Alloy::KYC.configuration.application_secret) response = conn.post("oauth/bearer") token_info = JSON.parse(response.body) @bearer_token = BearerToken.new(token_info["access_token"], token_info["expires_in"]) end
patch(url, params={})
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 58 def patch(url, params={}) set_auth_header conn.patch(url, params) end
post(url, params={})
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 53 def post(url, params={}) set_auth_header conn.post(url, params) end
requires_bearer_token?()
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 24 def requires_bearer_token? bearer_token.nil? || bearer_token.expired? end
set_auth_header()
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 28 def set_auth_header if requires_bearer_token? conn.authorization("Bearer", get_bearer_token.token) end end
submit_oow_responses(path, responses)
click to toggle source
# File lib/alloy/kyc/backends/remote.rb, line 39 def submit_oow_responses(path, responses) patch(path, responses) end