lib/lithic/resources/auth_stream_enrollment.rb



# frozen_string_literal: true

module Lithic
  module Resources
    class AuthStreamEnrollment
      # Retrieve the ASA HMAC secret key. If one does not exist for your program yet,
      # calling this endpoint will create one for you. The headers (which you can use to
      # verify webhooks) will begin appearing shortly after calling this endpoint for
      # the first time. See
      # [this page](https://docs.lithic.com/docs/auth-stream-access-asa#asa-webhook-verification)
      # for more detail about verifying ASA webhooks.
      #
      # @overload retrieve_secret(request_options: {})
      #
      # @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil]
      #
      # @return [Lithic::AuthStreamSecret]
      #
      # @see Lithic::Models::AuthStreamEnrollmentRetrieveSecretParams
      def retrieve_secret(params = {})
        @client.request(
          method: :get,
          path: "v1/auth_stream/secret",
          model: Lithic::AuthStreamSecret,
          options: params[:request_options]
        )
      end

      # Generate a new ASA HMAC secret key. The old ASA HMAC secret key will be
      # deactivated 24 hours after a successful request to this endpoint. Make a
      # [`GET /auth_stream/secret`](https://docs.lithic.com/reference/getauthstreamsecret)
      # request to retrieve the new secret key.
      #
      # @overload rotate_secret(request_options: {})
      #
      # @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil]
      #
      # @return [nil]
      #
      # @see Lithic::Models::AuthStreamEnrollmentRotateSecretParams
      def rotate_secret(params = {})
        @client.request(
          method: :post,
          path: "v1/auth_stream/secret/rotate",
          model: NilClass,
          options: params[:request_options]
        )
      end

      # @api private
      #
      # @param client [Lithic::Client]
      def initialize(client:)
        @client = client
      end
    end
  end
end