# typed: false # frozen_string_literal: true require 'active_support/core_ext/numeric/time' module Setsuzoku module Service module WebService module Credentials module OAuthCredential extend T::Sig extend T::Helpers include Setsuzoku::Credential include UsesTokenCredential abstract! # # auth_actions sig { override.returns(T::Hash[T.untyped, T.untyped]) } # # All auth actions that are implemented. # # @return [Hash] all auth endpoint definitions for the API. def auth_actions { new_token: { 'POST' => 'token', request_type: :json, response_type: :json }, refresh_token: { 'POST' => 'token', request_type: :json, response_type: :json } } end # The application's client_id to o_auth with. # # @return [String] the client_id for o_auth. sig { abstract.returns(T.nilable(String)) } def client_id; end # The application's client_secret to o_auth with. # # @return [String] the client_secret for o_auth. sig { abstract.returns(T.nilable(String)) } def client_secret; end # The application's redirect url to handle an o_auth redirect # # @return [String] the redirect url. sig { abstract.returns(T.nilable(String)) } def redirect_url; end # Stub an o_auth_credential-like instance. # # @return [Struct] a stubbed o_auth_credential-like struct. sig { returns(Struct) } def self.stub_credential s = Struct.new(:auth_strategy, :status, :settings, :client_id, :client_secret, :redirect_url, :token, :refresh_token, :expires_on) s.new(nil, 'active', {'extension': 'test'}, 'stubbed_client_id', 'stubbed_client_secret', 'stubbed_redirect_url', 'stubbed_token', 'stubbed_refresh_token', (Time.now + 30.days)) end end end end end end