// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
)

type Gitbook string

const (
	GitbookGitbook Gitbook = "gitbook"
)

func (e Gitbook) ToPointer() *Gitbook {
	return &e
}
func (e *Gitbook) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "gitbook":
		*e = Gitbook(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Gitbook: %v", v)
	}
}

type SourceGitbook struct {
	// Personal access token for authenticating with the GitBook API. You can view and manage your access tokens in the Developer settings of your GitBook user account.
	AccessToken string  `json:"access_token"`
	SpaceID     string  `json:"space_id"`
	sourceType  Gitbook `const:"gitbook" json:"sourceType"`
}

func (s SourceGitbook) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

func (s *SourceGitbook) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *SourceGitbook) GetAccessToken() string {
	if o == nil {
		return ""
	}
	return o.AccessToken
}

func (o *SourceGitbook) GetSpaceID() string {
	if o == nil {
		return ""
	}
	return o.SpaceID
}

func (o *SourceGitbook) GetSourceType() Gitbook {
	return GitbookGitbook
}
