// Code generated by Fern. DO NOT EDIT.

package pushnotification

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"
	http "net/http"
)

type RawClient struct {
	baseURL string
	caller  *internal.Caller
	options *core.RequestOptions
}

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

func (r *RawClient) GetApnsProvider(
	ctx context.Context,
	opts ...option.RequestOption,
) (*core.Response[*management.GetGuardianFactorsProviderApnsResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/apns"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	var response *management.GetGuardianFactorsProviderApnsResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodGet,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.GetGuardianFactorsProviderApnsResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) SetApnsProvider(
	ctx context.Context,
	request *management.SetGuardianFactorsProviderPushNotificationApnsRequestContent,
	opts ...option.RequestOption,
) (*core.Response[*management.SetGuardianFactorsProviderPushNotificationApnsResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/apns"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	var response *management.SetGuardianFactorsProviderPushNotificationApnsResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodPatch,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Request:         request,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.SetGuardianFactorsProviderPushNotificationApnsResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) SetFcmProvider(
	ctx context.Context,
	request *management.SetGuardianFactorsProviderPushNotificationFcmRequestContent,
	opts ...option.RequestOption,
) (*core.Response[management.SetGuardianFactorsProviderPushNotificationFcmResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/fcm"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	var response management.SetGuardianFactorsProviderPushNotificationFcmResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodPatch,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Request:         request,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[management.SetGuardianFactorsProviderPushNotificationFcmResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) SetFcmv1Provider(
	ctx context.Context,
	request *management.SetGuardianFactorsProviderPushNotificationFcmv1RequestContent,
	opts ...option.RequestOption,
) (*core.Response[management.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/fcmv1"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	var response management.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodPatch,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Request:         request,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[management.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) GetSnsProvider(
	ctx context.Context,
	opts ...option.RequestOption,
) (*core.Response[*management.GetGuardianFactorsProviderSnsResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/sns"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	var response *management.GetGuardianFactorsProviderSnsResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodGet,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.GetGuardianFactorsProviderSnsResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) SetSnsProvider(
	ctx context.Context,
	request *management.SetGuardianFactorsProviderPushNotificationSnsRequestContent,
	opts ...option.RequestOption,
) (*core.Response[*management.SetGuardianFactorsProviderPushNotificationSnsResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/sns"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	headers.Add("Content-Type", "application/json")
	var response *management.SetGuardianFactorsProviderPushNotificationSnsResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodPut,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Request:         request,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.SetGuardianFactorsProviderPushNotificationSnsResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) UpdateSnsProvider(
	ctx context.Context,
	request *management.UpdateGuardianFactorsProviderPushNotificationSnsRequestContent,
	opts ...option.RequestOption,
) (*core.Response[*management.UpdateGuardianFactorsProviderPushNotificationSnsResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/providers/sns"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	headers.Add("Content-Type", "application/json")
	var response *management.UpdateGuardianFactorsProviderPushNotificationSnsResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodPatch,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Request:         request,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.UpdateGuardianFactorsProviderPushNotificationSnsResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) GetSelectedProvider(
	ctx context.Context,
	opts ...option.RequestOption,
) (*core.Response[*management.GetGuardianFactorsProviderPushNotificationResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/selected-provider"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	var response *management.GetGuardianFactorsProviderPushNotificationResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodGet,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.GetGuardianFactorsProviderPushNotificationResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}

func (r *RawClient) SetProvider(
	ctx context.Context,
	request *management.SetGuardianFactorsProviderPushNotificationRequestContent,
	opts ...option.RequestOption,
) (*core.Response[*management.SetGuardianFactorsProviderPushNotificationResponseContent], error) {
	options := core.NewRequestOptions(opts...)
	baseURL := internal.ResolveBaseURL(
		options.BaseURL,
		r.baseURL,
		"https://%7BTENANT%7D.auth0.com/api/v2",
	)
	endpointURL := baseURL + "/guardian/factors/push-notification/selected-provider"
	headers := internal.MergeHeaders(
		r.options.ToHeader(),
		options.ToHeader(),
	)
	headers.Add("Content-Type", "application/json")
	var response *management.SetGuardianFactorsProviderPushNotificationResponseContent
	raw, err := r.caller.Call(
		ctx,
		&internal.CallParams{
			URL:             endpointURL,
			Method:          http.MethodPut,
			Headers:         headers,
			MaxAttempts:     options.MaxAttempts,
			BodyProperties:  options.BodyProperties,
			QueryParameters: options.QueryParameters,
			Client:          options.HTTPClient,
			Request:         request,
			Response:        &response,
			ErrorDecoder:    internal.NewErrorDecoder(management.ErrorCodes),
		},
	)
	if err != nil {
		return nil, err
	}
	return &core.Response[*management.SetGuardianFactorsProviderPushNotificationResponseContent]{
		StatusCode: raw.StatusCode,
		Header:     raw.Header,
		Body:       response,
	}, nil
}
