<commit_before>package dropbox

import (
	"encoding/json"
	"time"
)

// Sharing client.
type Sharing struct {
	*Client
}

// NewSharing client.
func NewSharing(config *Config) *Sharing {
	return &Sharing{
		Client: &Client{
			Config: config,
		},
	}
}

// CreateSharedLinkInput request input.
type CreateSharedLinkInput struct {
	Path     string `json:"path"`
	ShortURL bool   `json:"short_url"`
}

// CreateSharedLinkOutput request output.
type CreateSharedLinkOutput struct {
	URL             string `json:"url"`
	Path            string `json:"path"`
	VisibilityModel struct {
		Tag VisibilityType `json:".tag"`
	} `json:"visibility"`
	Expires time.Time `json:"expires,omitempty"`
}

// VisibilityType determines who can access the link.
type VisibilityType string

// Visibility types supported.
const (
	Public           VisibilityType = "public"
	TeamOnly                        = "team_only"
	Password                        = "password"
	TeamAndPassword                 = "<PASSWORD>"
	SharedFolderOnly                = "shared_folder_only"
)

//CreateSharedLink creates a shared link for a file or folder
func (c *Sharing) CreateSharedLink(in *CreateSharedLinkInput) (out *CreateSharedLinkOutput, err error) {
	body, err := c.call("/sharing/create_shared_link_with_settings", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}

//ListShareLinksInput request input.
type ListShareLinksInput struct {
	Path string `json:"path"`
}

//ListShareLinksOutput request output.
type ListShareLinksOutput struct {
	Links []CreateSharedLinkOutput `json:"links"`
}

//ListSharedLinks gets shared links of the path
func (c *Sharing) ListSharedLinks(in *ListShareLinksInput) (out *ListShareLinksOutput, err error) {
	endpoint := "/sharing/list_shared_links"
	body, err := c.call(endpoint, in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}

// ListSharedFolderInput request input.
type ListSharedFolderInput struct {
	Limit   uint64         `json:"limit"`
	Actions []FolderAction `json:"actions,omitempty"`
}

// FolderAction defines actions that may be taken on shared folders.<commit_msg>Created exclusive type for ListSharedLinks output<commit_after>package dropbox

import (
	"encoding/json"
	"time"
)

// Sharing client.
type Sharing struct {
	*Client
}

// NewSharing client.
func NewSharing(config *Config) *Sharing {
	return &Sharing{
		Client: &Client{
			Config: config,
		},
	}
}

// CreateSharedLinkInput request input.
type CreateSharedLinkInput struct {
	Path     string `json:"path"`
	ShortURL bool   `json:"short_url"`
}

// CreateSharedLinkOutput request output.
type CreateSharedLinkOutput struct {
	URL             string `json:"url"`
	Path            string `json:"path"`
	VisibilityModel struct {
		Tag VisibilityType `json:".tag"`
	} `json:"visibility"`
	Expires time.Time `json:"expires,omitempty"`
}

// VisibilityType determines who can access the link.
type VisibilityType string

// Visibility types supported.
const (
	Public           VisibilityType = "public"
	TeamOnly                        = "team_only"
	Password                        = "password"
	TeamAndPassword                 = "<PASSWORD>and_password"
	SharedFolderOnly                = "shared_folder_only"
)

// CreateSharedLink returns a shared link for a file or folder
func (c *Sharing) CreateSharedLink(in *CreateSharedLinkInput) (out *CreateSharedLinkOutput, err error) {
	body, err := c.call("/sharing/create_shared_link_with_settings", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}

// ListShareLinksInput request input.
type ListShareLinksInput struct {
	Path string `json:"path"`
}

// SharedLinkOutput request output.
type SharedLinkOutput struct {
	URL             string `json:"url"`
	Path            string `json:"path"`
	VisibilityModel struct {
		Tag VisibilityType `json:".tag"`
	} `json:"visibility"`
	Expires time.Time `json:"expires,omitempty"`
}

// ListShareLinksOutput request output.
type ListShareLinksOutput struct {
	Links []SharedLinkOutput `json:"links"`
}

// ListSharedLinks gets shared links of input.
func (c *Sharing) ListSharedLinks(in *ListShareLinksInput) (out *ListShareLinksOutput, err error) {
	endpoint := "/sharing/list_shared_links"
	body, err := c.call(endpoint, in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}

// ListSharedFolderInput request input.
type ListSharedFolderInput struct {
	Limit   uint64         `json:"limit"`
	Actions []FolderAction `json:"actions,omitempty"`
}

// FolderAction defines actions that may be taken on shared folders.
{'fraction_non_alphanumeric': 0.10749946887614191, 'fraction_numerical': 0.0008497981729339282, 'mean_word_length': 3.652173913043478, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5160499', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1390, 'n_words': 392}