digiposte

package
v0.0.0-...-5b3ce24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: MPL-2.0 Imports: 18 Imported by: 5

Documentation

Overview

Example

ListFolders returns all folders at the root.

package main

import (
	"context"
	"embed"
	"fmt"
	"io"

	"github.com/holyhope/digiposte-go-sdk/v1"
)

//go:embed testdata/document.txt
var testData embed.FS

// ListFolders returns all folders at the root.
func main() { //nolint:funlen
	ctx := context.Background()

	/* Create a new authenticated HTTP client using the following environment variables:
	 * - DIGIPOSTE_API
	 * - DIGIPOSTE_URL
	 * - DIGIPOSTE_USERNAME
	 * - DIGIPOSTE_PASSWORD
	 * - DIGIPOSTE_OTP_SECRET
	 */

	client, err := DigiposteClient(ctx)
	if err != nil {
		panic(fmt.Errorf("new digiposte client: %w", err))
	}

	/* Handle the cleanup of the created folders and documents */

	var (
		folders   []digiposte.FolderID
		documents []digiposte.DocumentID
	)

	defer func(ctx context.Context) {
		if err := client.Delete(ctx, documents, folders); err != nil {
			panic(fmt.Errorf("cleanup (documents %+v, folders %+v): %w", documents, folders, err))
		}

		fmt.Printf("Permanently deleted %d document(s) and %d folder(s)\n", len(documents), len(folders))
	}(context.Background())

	defer func(ctx context.Context) {
		if err := client.Trash(ctx, documents, folders); err != nil {
			panic(fmt.Errorf("trash (documents %+v, folders %+v): %w", documents, folders, err))
		}

		fmt.Printf("Trashed %d document(s) and %d folder(s)\n", len(documents), len(folders))
	}(context.Background())

	/* Create a folder */

	folder, err := client.CreateFolder(ctx, digiposte.RootFolderID, "digiposte-go-sdk Example")
	if err != nil {
		panic(fmt.Errorf("create folder: %w", err))
	}

	folders = append(folders, folder.InternalID)

	fmt.Printf("Folder %q created\n", folder.Name)

	/* Create a document */

	document, err := testData.Open("testdata/document.txt")
	if err != nil {
		panic(fmt.Errorf("open testdata file: %w", err))
	}

	stat, err := document.Stat()
	if err != nil {
		panic(fmt.Errorf("stat testdata file: %w", err))
	}

	doc, err := client.CreateDocument(ctx, folder.InternalID, stat.Name(), document, digiposte.DocumentTypeBasic)
	if err != nil {
		panic(fmt.Errorf("create document: %w", err))
	}

	documents = append(documents, doc.InternalID)

	fmt.Printf("Document %q created\n", doc.Name)

	/* Get document content */

	contentReader, contentType, err := client.DocumentContent(ctx, doc.InternalID)
	if err != nil {
		panic(fmt.Errorf("get document content: %w", err))
	}

	fmt.Printf("Document content type: %s\n", contentType)

	content, err := io.ReadAll(contentReader)
	if err != nil {
		panic(fmt.Errorf("read document content: %w", err))
	}

	fmt.Printf("Document size: %d bytes\n", len(content))

}
Output:

Folder "digiposte-go-sdk Example" created
Document "document.txt" created
Document content type: text/plain;charset=UTF-8
Document size: 134 bytes
Trashed 1 document(s) and 1 folder(s)
Permanently deleted 1 document(s) and 1 folder(s)

Index

Examples

Constants

View Source
const JSONContentType = "application/json"
View Source
const TrashDirName = "trash"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	Token               string    `json:"access_token"`
	ExpiresAt           time.Time `json:"expires_at"`
	IsTokenConsolidated bool      `json:"is_token_consolidated"`
}

func (*AccessToken) MarshalJSON

func (t *AccessToken) MarshalJSON() ([]byte, error)

func (*AccessToken) UnmarshalJSON

func (t *AccessToken) UnmarshalJSON(data []byte) error

type AppToken

type AppToken struct {
	Token     string    `json:"app_access_token"`
	ExpiresAt time.Time `json:"app_expires_at"`
}

func (*AppToken) UnmarshalJSON

func (t *AppToken) UnmarshalJSON(data []byte) error

type Capabilities

type Capabilities struct {
	ShareSpaceStatus            string `json:"share_space_status"`
	Show2ddoc                   bool   `json:"show2ddoc"`
	HasOfflineModeAbility       bool   `json:"has_offline_mode_ability"`
	HasFullContentSearchAbility bool   `json:"hasFullContentSearchAbility"`
	SupportAvailable            bool   `json:"support_available"`
	CanAddProCollectors         bool   `json:"canAddProCollectors"`
	SecretQuestionAvailable     bool   `json:"secret_question_available"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Digiposte client.

func NewAuthenticatedClient

func NewAuthenticatedClient(ctx context.Context, httpClient *http.Client, config *Config) (*Client, error)

NewAuthenticatedClient creates a new Digiposte client with the given credentials.

func NewClient

func NewClient(client *http.Client) *Client

NewClient creates a new Digiposte client.

func NewCustomClient

func NewCustomClient(apiURL, documentURL string, client *http.Client) *Client

NewClient creates a new Digiposte client.

func (*Client) AccessToken

func (c *Client) AccessToken(ctx context.Context) (*AccessToken, error)

AccessToken returns a new access token.

func (*Client) AppToken

func (c *Client) AppToken(ctx context.Context) (*AppToken, error)

AppToken returns a application token.

func (*Client) CopyDocuments

func (c *Client) CopyDocuments(ctx context.Context, documentIDs []DocumentID) (*SearchDocumentsResult, error)

CopyDocuments copies the given documents in the same folder.

func (*Client) CreateDocument

func (c *Client) CreateDocument(
	ctx context.Context,
	folderID FolderID,
	name string,
	data io.Reader,
	docType DocumentType,
) (document *Document, finalErr error)

CreateDocument creates a document.

func (*Client) CreateFolder

func (c *Client) CreateFolder(ctx context.Context, parentID FolderID, name string) (*Folder, error)

CreateFolder creates a folder.

Example
ctx := context.Background()

/* Create a new authenticated HTTP client using the following environment variables:
 * - DIGIPOSTE_API
 * - DIGIPOSTE_URL
 * - DIGIPOSTE_USERNAME
 * - DIGIPOSTE_PASSWORD
 * - DIGIPOSTE_OTP_SECRET
 */T
 */

client, err := DigiposteClient(ctx)
if err != nil {
	panic(fmt.Errorf("new digiposte client: %w", err))
}

/* Create folders */

folder, err := client.CreateFolder(ctx, digiposte.RootFolderID, "digiposte-go-sdk ExampleClient_CreateFolder")
if err != nil {
	panic(fmt.Errorf("create folder: %w", err))
}

fmt.Printf("Folder %q created\n", folder.Name)

if _, err := client.CreateFolder(ctx, folder.InternalID, "sub-folder"); err != nil {
	panic(fmt.Errorf("create folder: %w", err))
}

fmt.Print("Sub folder created\n")

/* Trash the top folder */

if err := client.Trash(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("trash: %w", err))
}

fmt.Printf("Folder %q trashed\n", folder.Name)

/* Delete the top folder */

if err := client.Delete(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("delete: %w", err))
}

fmt.Printf("Folder %q deleted\n", folder.Name)
Output:

Folder "digiposte-go-sdk ExampleClient_CreateFolder" created
Sub folder created
Folder "digiposte-go-sdk ExampleClient_CreateFolder" trashed
Folder "digiposte-go-sdk ExampleClient_CreateFolder" deleted

func (*Client) CreateShare

func (c *Client) CreateShare(ctx context.Context, startDate, endDate time.Time, title, code string) (*Share, error)

Share creates a share for a specific time period, with a title and a security code.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, documentIDs []DocumentID, folderIDs []FolderID) error

Delete deletes permanently the given documents and folders.

func (*Client) DeleteShare

func (c *Client) DeleteShare(ctx context.Context, shareID ShareID) error

DeleteShare deletes a share.

func (*Client) DocumentContent

func (c *Client) DocumentContent(ctx context.Context, internalID DocumentID) (
	contentBuffer io.ReadCloser,
	contentType string,
	finalErr error,
)

DocumentContent returns the content of a document.

func (*Client) GetProfile

func (c *Client) GetProfile(ctx context.Context, mode ProfileMode) (*Profile, error)

GetProfile returns the profile of the user.

func (*Client) GetProfileSafeSize

func (c *Client) GetProfileSafeSize(ctx context.Context) (*ProfileSafeSize, error)

GetProfileSafeSize returns the usage of the safe.

func (*Client) GetShare

func (c *Client) GetShare(ctx context.Context, shareID ShareID) (*Share, error)

GetShare returns a share.

func (*Client) GetShareDocuments

func (c *Client) GetShareDocuments(ctx context.Context, shareID ShareID) (*SearchDocumentsResult, error)

GetShareDocuments returns all documents of a share.

func (*Client) GetTrashedDocuments

func (c *Client) GetTrashedDocuments(ctx context.Context) (*SearchDocumentsResult, error)

GetTrashedDocuments returns all documents in the trash.

func (*Client) GetTrashedFolders

func (c *Client) GetTrashedFolders(ctx context.Context) (*SearchFoldersResult, error)

GetTrashedFolders returns all folders in the trash.

Example
ctx := context.Background()

/* Create a new authenticated HTTP client using the following environment variables:
 * - DIGIPOSTE_API
 * - DIGIPOSTE_URL
 * - DIGIPOSTE_USERNAME
 * - DIGIPOSTE_PASSWORD
 * - DIGIPOSTE_OTP_SECRET
 */T
 */

client, err := DigiposteClient(ctx)
if err != nil {
	panic(fmt.Errorf("new digiposte client: %w", err))
}

/* Create folders */

folder, err := client.CreateFolder(ctx, digiposte.RootFolderID, "digiposte-go-sdk ExampleClient_GetTrashedFolders")
if err != nil {
	panic(fmt.Errorf("create folder: %w", err))
}

fmt.Printf("Folder %q created\n", folder.Name)

/* Trash the folder */

if err := client.Trash(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("trash: %w", err))
}

fmt.Printf("Folder %q trashed\n", folder.Name)

/* Get trashed folders */

folders, err := client.GetTrashedFolders(ctx)
if err != nil {
	panic(fmt.Errorf("get trashed folders: %w", err))
}

for _, f := range folders.Folders {
	if f.InternalID == folder.InternalID {
		fmt.Print("Trashed folder found\n")
	}
}

/* Delete the folder */

if err := client.Delete(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("delete: %w", err))
}

fmt.Printf("Folder %q deleted\n", folder.Name)
Output:

Folder "digiposte-go-sdk ExampleClient_GetTrashedFolders" created
Folder "digiposte-go-sdk ExampleClient_GetTrashedFolders" trashed
Trashed folder found
Folder "digiposte-go-sdk ExampleClient_GetTrashedFolders" deleted

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context) (*SearchDocumentsResult, error)

ListDocuments returns all documents at the root.

func (*Client) ListFolders

func (c *Client) ListFolders(ctx context.Context) (*SearchFoldersResult, error)

ListFolders returns all folders at the root.

Example
ctx := context.Background()

// Create a new authenticated HTTP client using the following environment variables:
// - DIGIPOSTE_API
// - DIGIPOSTE_URL
// - DIGIPOSTE_USERNAME
// - DIGIPOSTE_PASSWORD
// - DIGIPOSTE_OTP_SECRET
client, err := DigiposteClient(ctx)
if err != nil {
	panic(fmt.Errorf("new digiposte client: %w", err))
}

/* Create folders */

folder, err := client.CreateFolder(ctx, digiposte.RootFolderID, "digiposte-go-sdk ExampleClient_ListFolders")
if err != nil {
	panic(fmt.Errorf("create folder: %w", err))
}

fmt.Printf("Folder %q created\n", folder.Name)

/* List folders */

folders, err := client.ListFolders(ctx)
if err != nil {
	panic(fmt.Errorf("list folders: %w", err))
}

for _, f := range folders.Folders {
	if f.InternalID == folder.InternalID {
		fmt.Print("Folder found\n")
	}
}

/* Trash the folder */

if err := client.Trash(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("trash: %w", err))
}

fmt.Printf("Folder %q trashed\n", folder.Name)

/* Delete the folder */

if err := client.Delete(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("delete: %w", err))
}

fmt.Printf("Folder %q deleted\n", folder.Name)
Output:

Folder "digiposte-go-sdk ExampleClient_ListFolders" created
Folder found
Folder "digiposte-go-sdk ExampleClient_ListFolders" trashed
Folder "digiposte-go-sdk ExampleClient_ListFolders" deleted

func (*Client) ListShares

func (c *Client) ListShares(ctx context.Context) (*ShareResult, error)

ListShares returns all shares.

func (*Client) ListSharesWithDocuments

func (c *Client) ListSharesWithDocuments(ctx context.Context) (*ShareResultWithDocuments, error)

ListSharesWithDocuments returns all shares with documents.

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

Logout logs out the user.

func (*Client) Move

func (c *Client) Move(ctx context.Context, destID FolderID, documentIDs []DocumentID, folderIDs []FolderID) error

Move moves the given documents and folders to the given destination.

func (*Client) MultiTag

func (c *Client) MultiTag(ctx context.Context, tags map[DocumentID][]DocumentTag) error

MultiTag adds the given tags to the given documents.

func (*Client) RenameDocument

func (c *Client) RenameDocument(ctx context.Context, internalID DocumentID, name string) (*Document, error)

RenameDocument renames a document.

func (*Client) RenameFolder

func (c *Client) RenameFolder(ctx context.Context, internalID FolderID, name string) (*Folder, error)

RenameFolder renames a folder.

Example
ctx := context.Background()

/* Create a new authenticated HTTP client using the following environment variables:
 * - DIGIPOSTE_API
 * - DIGIPOSTE_URL
 * - DIGIPOSTE_USERNAME
 * - DIGIPOSTE_PASSWORD
 * - DIGIPOSTE_OTP_SECRET
 */T
 */

client, err := DigiposteClient(ctx)
if err != nil {
	panic(fmt.Errorf("new digiposte client: %w", err))
}

/* Create folders */

folder, err := client.CreateFolder(ctx, digiposte.RootFolderID, "digiposte-go-sdk ExampleClient_R3n4m4F0ld3r")
if err != nil {
	panic(fmt.Errorf("create folder: %w", err))
}

fmt.Printf("Folder %q created\n", folder.Name)

folder, err = client.RenameFolder(ctx, folder.InternalID, "digiposte-go-sdk ExampleClient_RenameFolder")
if err != nil {
	panic(fmt.Errorf("rename folder: %w", err))
}

fmt.Printf("Folder renamed to %q\n", folder.Name)

/* Trash the folder */

if err := client.Trash(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("trash: %w", err))
}

fmt.Printf("Folder %q trashed\n", folder.Name)

/* Delete the folder */

if err := client.Delete(ctx, nil, []digiposte.FolderID{folder.InternalID}); err != nil {
	panic(fmt.Errorf("delete: %w", err))
}

fmt.Printf("Folder %q deleted\n", folder.Name)
Output:

Folder "digiposte-go-sdk ExampleClient_R3n4m4F0ld3r" created
Folder renamed to "digiposte-go-sdk ExampleClient_RenameFolder"
Folder "digiposte-go-sdk ExampleClient_RenameFolder" trashed
Folder "digiposte-go-sdk ExampleClient_RenameFolder" deleted

func (*Client) SearchDocuments

func (c *Client) SearchDocuments(ctx context.Context, internalID FolderID, options ...DocumentSearchOption) (
	*SearchDocumentsResult,
	error,
)

SearchDocuments searches for documents in the given locations.

func (*Client) SetShareDocuments

func (c *Client) SetShareDocuments(ctx context.Context, shareID ShareID, documentIDs []DocumentID) error

SetShareDocuments adds a document to a share.

func (*Client) Trash

func (c *Client) Trash(ctx context.Context, documentIDs []DocumentID, folderIDs []FolderID) error

Trash move trashes the given documents and folders to the trash.

func (*Client) UserTags

func (c *Client) UserTags(ctx context.Context) (*UserTags, error)

type CloseBodyError

type CloseBodyError struct {
	Err           error
	OriginalError error
}

CloseBodyError is an error returned when the body of a response cannot be closed.

func (*CloseBodyError) Error

func (e *CloseBodyError) Error() string

func (*CloseBodyError) Unwrap

func (e *CloseBodyError) Unwrap() error

type CloseWriterError

type CloseWriterError struct {
	Err           error
	OriginalError error
}

CloseWriterError represents an error during the closing of a writer.

func (*CloseWriterError) Error

func (e *CloseWriterError) Error() string

func (*CloseWriterError) Unwrap

func (e *CloseWriterError) Unwrap() error

type Config

type Config struct {
	APIURL      string
	DocumentURL string

	LoginMethod login.Method
	Credentials *login.Credentials

	SessionListener func(session *Session)

	PreviousSession *Session
}

Config is the configuration of a Digiposte client.

func (*Config) SetupDefault

func (c *Config) SetupDefault(ctx context.Context) error

SetupDefault sets up the default values of the configuration.

type Contracts

type Contracts struct {
	TOS struct {
		Version   string `json:"tos_version"`
		UpdatedAt string `json:"tos_updated_at"`
	} `json:",inline"`
	Offer struct {
		PID        string `json:"offer_pid"`
		UpdatedAt  string `json:"offer_updated_at"`
		NewOffer   bool   `json:"new_offer"`
		OtherOffer string `json:"other_offer"`
	} `json:",inline"`
	CCU struct {
		User   bool   `json:"ccu_user"`
		UserID string `json:"ccu_user_id"`
	} `json:",inline"`
}

type Document

type Document struct {
	InternalID     DocumentID `json:"id"`
	Name           string     `json:"filename"`
	CreatedAt      time.Time  `json:"creation_date"`
	Size           int64      `json:"size"`
	MimeType       string     `json:"mimetype"`
	FolderID       string     `json:"folder_id"`
	Location       string     `json:"location"`
	Shared         bool       `json:"shared"`
	Read           bool       `json:"read"`
	HealthDocument bool       `json:"health_document"`
	UserTags       []string   `json:"user_tags"`
}

Document represents a document.

type DocumentID

type DocumentID digiposteID

type DocumentSearchOption

type DocumentSearchOption func(map[string]interface{})

DocumentSearchOption represents an option for searching documents.

func CertifiedDocuments

func CertifiedDocuments() DocumentSearchOption

CertifiedDocuments returns only certified documents.

func DocumentTaggedWith

func DocumentTaggedWith(tags ...DocumentTag) DocumentSearchOption

DocumentTaggedWith returns only documents tagged with the given tags.

func FavoriteDocuments

func FavoriteDocuments() DocumentSearchOption

FavoriteDocuments returns only favorite documents.

func HealthDocuments

func HealthDocuments() DocumentSearchOption

HealthDocuments returns only health documents.

func NotCertifiedDocuments

func NotCertifiedDocuments() DocumentSearchOption

NotCertifiedDocuments returns only non-certified documents.

func NotFavoriteDocuments

func NotFavoriteDocuments() DocumentSearchOption

NotFavoriteDocuments returns only non-favorite documents.

func NotHealthDocuments

func NotHealthDocuments() DocumentSearchOption

NotHealthDocuments returns only non-health documents.

func NotSharedDocuments

func NotSharedDocuments() DocumentSearchOption

NotSharedDocuments returns only non-shared documents.

func OnlyDocumentLocatedAt

func OnlyDocumentLocatedAt(locations ...Location) DocumentSearchOption

OnlyDocumentLocatedAt returns only documents located at the given locations.

func ReadDocuments

func ReadDocuments() DocumentSearchOption

ReadDocuments returns only read documents.

func SharedDocuments

func SharedDocuments() DocumentSearchOption

SharedDocuments returns only shared documents.

func UnreadDocuments

func UnreadDocuments() DocumentSearchOption

UnreadDocuments returns only unread documents.

type DocumentTag

type DocumentTag string

type DocumentType

type DocumentType int8

DocumentType represents the type of a document.

const (
	// DocumentTypeBasic represents a basic document.
	DocumentTypeBasic DocumentType = iota
	// DocumentTypeHealth represents a health document.
	DocumentTypeHealth
)

func (DocumentType) String

func (i DocumentType) String() string

type Folder

type Folder struct {
	InternalID    FolderID  `json:"id"`
	Name          string    `json:"name"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	DocumentCount int64     `json:"document_count"`
	Folders       []*Folder `json:"folders"`
}

Folder represents a Digiposte folder.

type FolderID

type FolderID digiposteID
const RootFolderID FolderID = ""

type Location

type Location int8

Location represents a location of a document.

const (
	LocationInbox      Location = iota // INBOX
	LocationSafe                       // SAFE
	LocationTrashInbox                 // TRASH_INBOX
	LocationTrashSafe                  // TRASH_SAFE
)

func (Location) String

func (i Location) String() string

type Offer

type Offer struct {
	Serializable `json:",inline"`

	PID                         string    `json:"pid"`
	Type                        string    `json:"type"`
	MaxSafeSize                 int64     `json:"max_safe_size"`
	MaxCollectorsCount          int       `json:"max_nb_collectors"`
	ActualSafeSize              int64     `json:"actual_safe_size"`
	ActualCollectorsCount       int       `json:"actual_nb_collectors"`
	SubscriptionDate            time.Time `json:"subscription_date"`
	Price                       int64     `json:"price"`
	Frequency                   string    `json:"frequency"`
	CommercialName              string    `json:"commercial_name"`
	CanAddProCollectors         bool      `json:"canAddProCollectors"`
	CanStartProProcedures       bool      `json:"canStartProProcedures"`
	HasFullContentSearchAbility bool      `json:"hasFullContentSearchAbility"`
	HasOfflineModeAbility       bool      `json:"has_offline_mode_ability"`
	IsAssistanceEnabled         bool      `json:"is_assistance_enabled"`
}

type Profile

type Profile struct {
	UserInfo     `json:",inline"`
	Offer        `json:"offer"`
	Capabilities `json:",inline"`
	Storage      `json:",inline"`
	Serializable `json:",inline"`

	Status                  string        `json:"status"`
	AuthorName              string        `json:"author_name"`
	LastConnexionDate       string        `json:"last_connexion_date"`
	VerifyProfile           string        `json:"verify_profile"`
	Completion              int           `json:"completion"`
	VerifiedDocuments       []interface{} `json:"verified_documents"`
	PartialAccount          bool          `json:"partial_account"`
	IDNumeriqueValid        bool          `json:"idn_valid"`
	BasicUser               bool          `json:"basic_user"`
	SecretQuestionAvailable bool          `json:"secret_question_available"`
	FirstConnection         bool          `json:"first_connection"`
	Salaried                bool          `json:"salaried"`
	IndexationConsent       bool          `json:"indexation_consent"`
}

type ProfileMode

type ProfileMode int
const (
	ProfileModeDefault            ProfileMode = iota // default
	ProfileModeNoSpaceConsumption                    // without_space_consumption
)

func (ProfileMode) String

func (i ProfileMode) String() string

type ProfileSafeSize

type ProfileSafeSize struct {
	ActualSafeSize int64 `json:"actual_safe_size"`
}

ProfileSafeSize represents the usage of the safe.

type RedirectionError

type RedirectionError struct {
	Location string
}

func (*RedirectionError) Error

func (e *RedirectionError) Error() string

type RequestErrors

type RequestErrors []struct {
	ErrorCode string                 `json:"error"`
	ErrorDesc string                 `json:"error_description,omitempty"`
	Context   map[string]interface{} `json:"context,omitempty"`
}

RequestError is an error returned when the API returns an error.

func (*RequestErrors) Error

func (e *RequestErrors) Error() string

type SearchDocumentsResult

type SearchDocumentsResult struct {
	Count      int64       `json:"count"`
	Index      int64       `json:"index"`
	MaxResults int64       `json:"max_results"`
	Documents  []*Document `json:"documents"`
}

SearchDocumentsResult represents the result of a search for documents.

type SearchFoldersResult

type SearchFoldersResult struct {
	Count      int64     `json:"count"`
	Index      int64     `json:"index"`
	MaxResults int64     `json:"max_results"`
	Folders    []*Folder `json:"folders"`
}

SearchFoldersResult represents a search result for folders.

type Serializable

type Serializable struct {
	Serializer   interface{} `json:"serializer"`
	Deserializer interface{} `json:"deserializer"`
}

type Session

type Session struct {
	Token   *oauth2.Token
	Cookies []*http.Cookie
}

Session represents a Digiposte session.

type Share

type Share struct {
	InternalID     ShareID   `json:"id"`
	ShortID        string    `json:"short_id"`
	SecurityCode   string    `json:"security_code"`
	ShortURL       string    `json:"short_url"`
	Title          string    `json:"title"`
	StartDate      time.Time `json:"start_date"`
	EndDate        time.Time `json:"end_date"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	RecipientMails []string  `json:"recipient_mails"`
}

Share represents a share.

type ShareID

type ShareID digiposteID

type ShareResult

type ShareResult struct {
	SenderShares []Share `json:"senderShares"`
	ShareDatas   []Share `json:"shareDatas"`
}

ShareResult represents a share.

type ShareResultWithDocuments

type ShareResultWithDocuments struct {
	ShareDataAndDocuments []struct {
		ShareData Share      `json:"share_data"`
		Documents []Document `json:"documents"`
	} `json:"share_data_and_documents"`
}

ShareResultWithDocuments represents a share with documents.

type Storage

type Storage struct {
	SpaceUsed        int64 `json:"space_used"`
	SpaceFree        int64 `json:"space_free"`
	SpaceMax         int64 `json:"space_max"`
	SpaceNotComputed int64 `json:"space_not_computed"`
}

type TokenSource

type TokenSource struct {
	DocumentURL string

	GetContext func() context.Context
	// contains filtered or unexported fields
}

TokenSource is a token source that uses a the client to get the oauth token.

func NewTokenSource

func NewTokenSource(c *http.Client, documentURL string, getContext func() context.Context) *TokenSource

func (*TokenSource) Token

func (ts *TokenSource) Token() (*oauth2.Token, error)

Token returns a new oauth token.

type UploadError

type UploadError struct {
	Err           error
	OriginalError error
}

UploadError represents an error during an upload.

func (*UploadError) Error

func (e *UploadError) Error() string

func (*UploadError) Unwrap

func (e *UploadError) Unwrap() error

type UserInfo

type UserInfo struct {
	InternalID string      `json:"id"`
	Title      string      `json:"title"`
	FirstName  string      `json:"first_name"`
	LastName   string      `json:"last_name"`
	IDXiti     interface{} `json:"id_xiti"`
	Login      string      `json:"login"`
	Type       string      `json:"user_type"`
	Locale     string      `json:"locale"`
	Email      string      `json:"primaryEmail"`
}

type UserTags

type UserTags struct {
	Tags map[DocumentTag]int `json:"tags"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL