// Code generated by Fern. DO NOT EDIT.

package ssoticket

import (
	context "context"
	management "github.com/auth0/go-auth0/v2/management"
	core "github.com/auth0/go-auth0/v2/management/core"
	internal "github.com/auth0/go-auth0/v2/management/internal"
	option "github.com/auth0/go-auth0/v2/management/option"
)

type Client struct {
	WithRawResponse *RawClient

	options *core.RequestOptions
	baseURL string
	caller  *internal.Caller
}

func NewClient(options *core.RequestOptions) *Client {
	return &Client{
		WithRawResponse: NewRawClient(options),
		options:         options,
		baseURL:         options.BaseURL,
		caller: internal.NewCaller(
			&internal.CallerParams{
				Client:      options.HTTPClient,
				MaxAttempts: options.MaxAttempts,
			},
		),
	}
}

// Creates an SSO access ticket to initiate the Self Service SSO Flow using a self-service profile.
func (c *Client) Create(
	ctx context.Context,
	// The id of the self-service profile to retrieve
	id string,
	request *management.CreateSelfServiceProfileSSOTicketRequestContent,
	opts ...option.RequestOption,
) (*management.CreateSelfServiceProfileSSOTicketResponseContent, error) {
	response, err := c.WithRawResponse.Create(
		ctx,
		id,
		request,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	return response.Body, nil
}

// Revokes an SSO access ticket and invalidates associated sessions. The ticket will no longer be accepted to initiate a Self-Service SSO session. If any users have already started a session through this ticket, their session will be terminated. Clients should expect a `202 Accepted` response upon successful processing, indicating that the request has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. If the specified ticket does not exist, a `202 Accepted` response is also returned, signaling that no further action is required.
// Clients should treat these `202` responses as an acknowledgment that the request has been accepted and is in progress, even if the ticket was not found.
func (c *Client) Revoke(
	ctx context.Context,
	// The id of the self-service profile
	profileID string,
	// The id of the ticket to revoke
	id string,
	opts ...option.RequestOption,
) error {
	_, err := c.WithRawResponse.Revoke(
		ctx,
		profileID,
		id,
		opts...,
	)
	if err != nil {
		return err
	}
	return nil
}
