// Code generated by Fern. DO NOT EDIT.

package management

import (
	json "encoding/json"
	core "github.com/auth0/go-auth0/v2/management/core"
)

// Invalid request URI. The message will vary depending on the cause.
type BadRequestError struct {
	*core.APIError
	Body interface{}
}

func (b *BadRequestError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	b.StatusCode = 400
	b.Body = body
	return nil
}

func (b *BadRequestError) MarshalJSON() ([]byte, error) {
	return json.Marshal(b.Body)
}

func (b *BadRequestError) Unwrap() error {
	return b.APIError
}

// Custom phone provider conflict.
type ConflictError struct {
	*core.APIError
	Body interface{}
}

func (c *ConflictError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	c.StatusCode = 409
	c.Body = body
	return nil
}

func (c *ConflictError) MarshalJSON() ([]byte, error) {
	return json.Marshal(c.Body)
}

func (c *ConflictError) Unwrap() error {
	return c.APIError
}

// Payload content length greater than maximum allowed: 512000.
type ContentTooLargeError struct {
	*core.APIError
	Body interface{}
}

func (c *ContentTooLargeError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	c.StatusCode = 413
	c.Body = body
	return nil
}

func (c *ContentTooLargeError) MarshalJSON() ([]byte, error) {
	return json.Marshal(c.Body)
}

func (c *ContentTooLargeError) Unwrap() error {
	return c.APIError
}

// Insufficient scope, expected: read:actions.
type ForbiddenError struct {
	*core.APIError
	Body interface{}
}

func (f *ForbiddenError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	f.StatusCode = 403
	f.Body = body
	return nil
}

func (f *ForbiddenError) MarshalJSON() ([]byte, error) {
	return json.Marshal(f.Body)
}

func (f *ForbiddenError) Unwrap() error {
	return f.APIError
}

// Internal error.
type InternalServerError struct {
	*core.APIError
	Body interface{}
}

func (i *InternalServerError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	i.StatusCode = 500
	i.Body = body
	return nil
}

func (i *InternalServerError) MarshalJSON() ([]byte, error) {
	return json.Marshal(i.Body)
}

func (i *InternalServerError) Unwrap() error {
	return i.APIError
}

// The action version does not exist.
type NotFoundError struct {
	*core.APIError
	Body interface{}
}

func (n *NotFoundError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	n.StatusCode = 404
	n.Body = body
	return nil
}

func (n *NotFoundError) MarshalJSON() ([]byte, error) {
	return json.Marshal(n.Body)
}

func (n *NotFoundError) Unwrap() error {
	return n.APIError
}

// A paid subscription is required for this feature.
type PaymentRequiredError struct {
	*core.APIError
	Body interface{}
}

func (p *PaymentRequiredError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	p.StatusCode = 402
	p.Body = body
	return nil
}

func (p *PaymentRequiredError) MarshalJSON() ([]byte, error) {
	return json.Marshal(p.Body)
}

func (p *PaymentRequiredError) Unwrap() error {
	return p.APIError
}

// The query exceeded the timeout. Please try refining your search criteria. See https://auth0.com/docs/best-practices/search-best-practices.
type ServiceUnavailableError struct {
	*core.APIError
	Body interface{}
}

func (s *ServiceUnavailableError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	s.StatusCode = 503
	s.Body = body
	return nil
}

func (s *ServiceUnavailableError) MarshalJSON() ([]byte, error) {
	return json.Marshal(s.Body)
}

func (s *ServiceUnavailableError) Unwrap() error {
	return s.APIError
}

// Too many requests. Check the X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers.
type TooManyRequestsError struct {
	*core.APIError
	Body interface{}
}

func (t *TooManyRequestsError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	t.StatusCode = 429
	t.Body = body
	return nil
}

func (t *TooManyRequestsError) MarshalJSON() ([]byte, error) {
	return json.Marshal(t.Body)
}

func (t *TooManyRequestsError) Unwrap() error {
	return t.APIError
}

// Invalid token.
type UnauthorizedError struct {
	*core.APIError
	Body interface{}
}

func (u *UnauthorizedError) UnmarshalJSON(data []byte) error {
	var body interface{}
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	u.StatusCode = 401
	u.Body = body
	return nil
}

func (u *UnauthorizedError) MarshalJSON() ([]byte, error) {
	return json.Marshal(u.Body)
}

func (u *UnauthorizedError) Unwrap() error {
	return u.APIError
}
