lib/setsuzoku/api_strategy.rb in setsuzoku-0.11.9 vs lib/setsuzoku/api_strategy.rb in setsuzoku-0.12.54
- old
+ new
@@ -1,18 +1,20 @@
-# typed: false
+# typed: ignore
# frozen_string_literal: true
module Setsuzoku
# The API Type Interface definition.
# Any ApiStrategy that implements this interface must implement all abstract methods defined by ApiStrategy.
#
# Defines all necessary methods for handling interfacing with an external API/Service for any authentication strategy.
module ApiStrategy
-
extend Forwardable
extend T::Sig
extend T::Helpers
+
+ include HasConfigContext
+
abstract!
attr_accessor :current_action
attr_accessor :service
def_delegators :@service, :plugin, :auth_strategy, :external_api_handler
@@ -33,12 +35,12 @@
Setsuzoku::Service::WebService::ApiStrategies::RestStrategy,
T.untyped
))
end
def initialize(service:, **args)
- #TODO: here we need to assign credentials etc, I think.
self.service = service
+ self.config_context = args
self
end
# Perform the external call for the external API.
# Each ApiStrategy must define how this works.
@@ -69,10 +71,10 @@
formatted_response = T.let(nil, T.nilable(T::Hash[Symbol, T.untyped]))
success = T.let(false, T::Boolean)
exception = T.let(nil, T.nilable(Setsuzoku::Exception))
action_details = case strategy
when :auth
- { actions: self.plugin.auth_actions, url: self.plugin.auth_base_url }
+ { actions: self.auth_strategy.credential.auth_actions, url: self.auth_strategy.credential.auth_base_url }
when :webhook
{ actions: self.plugin.api_actions, url: self.plugin.webhook_base_url }
else
{ actions: self.plugin.api_actions, url: self.plugin.api_base_url }
end