// 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 Wrike string

const (
	WrikeWrike Wrike = "wrike"
)

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

type SourceWrike struct {
	// Permanent access token. You can find documentation on how to acquire a permanent access token  <a href="https://developers.wrike.com/oauth-20-authorization/">here</a>
	AccessToken string `json:"access_token"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Only comments after this date will be replicated.
	StartDate *string `json:"start_date,omitempty"`
	// Wrike's instance such as `app-us2.wrike.com`
	WrikeInstance *string `default:"app-us2.wrike.com" json:"wrike_instance"`
	sourceType    Wrike   `const:"wrike" json:"sourceType"`
}

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

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

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

func (o *SourceWrike) GetStartDate() *string {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourceWrike) GetWrikeInstance() *string {
	if o == nil {
		return nil
	}
	return o.WrikeInstance
}

func (o *SourceWrike) GetSourceType() Wrike {
	return WrikeWrike
}
