Skip to content

Latest commit

 

History

History
252 lines (193 loc) · 16 KB

File metadata and controls

252 lines (193 loc) · 16 KB

Documents.Attachments

Overview

Available Operations

Create

Create a new attachment for a document

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/documenso/sdk-go"
	"github.com/documenso/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
    )

    res, err := s.Documents.Attachments.Create(ctx, operations.DocumentAttachmentCreateRequest{
        DocumentID: 7014.36,
        Data: operations.DocumentAttachmentCreateData{
            Label: "<value>",
            Data: "https://cheerful-bourgeoisie.org/",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.DocumentAttachmentCreateRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.DocumentAttachmentCreateResponse, error

Errors

Error Type Status Code Content Type
apierrors.DocumentAttachmentCreateBadRequestError 400 application/json
apierrors.DocumentAttachmentCreateUnauthorizedError 401 application/json
apierrors.DocumentAttachmentCreateForbiddenError 403 application/json
apierrors.DocumentAttachmentCreateInternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

Update

Update an existing attachment

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/documenso/sdk-go"
	"github.com/documenso/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
    )

    res, err := s.Documents.Attachments.Update(ctx, operations.DocumentAttachmentUpdateRequest{
        ID: "<id>",
        Data: operations.DocumentAttachmentUpdateData{
            Label: "<value>",
            Data: "https://tinted-ceramics.biz",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.DocumentAttachmentUpdateRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.DocumentAttachmentUpdateResponse, error

Errors

Error Type Status Code Content Type
apierrors.DocumentAttachmentUpdateBadRequestError 400 application/json
apierrors.DocumentAttachmentUpdateUnauthorizedError 401 application/json
apierrors.DocumentAttachmentUpdateForbiddenError 403 application/json
apierrors.DocumentAttachmentUpdateInternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

Delete

Delete an attachment from a document

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/documenso/sdk-go"
	"github.com/documenso/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
    )

    res, err := s.Documents.Attachments.Delete(ctx, operations.DocumentAttachmentDeleteRequest{
        ID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.DocumentAttachmentDeleteRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.DocumentAttachmentDeleteResponse, error

Errors

Error Type Status Code Content Type
apierrors.DocumentAttachmentDeleteBadRequestError 400 application/json
apierrors.DocumentAttachmentDeleteUnauthorizedError 401 application/json
apierrors.DocumentAttachmentDeleteForbiddenError 403 application/json
apierrors.DocumentAttachmentDeleteInternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*

Find

Find all attachments for a document

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/documenso/sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
    )

    res, err := s.Documents.Attachments.Find(ctx, 965.17)
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
documentID float64 ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.DocumentAttachmentFindResponse, error

Errors

Error Type Status Code Content Type
apierrors.DocumentAttachmentFindBadRequestError 400 application/json
apierrors.DocumentAttachmentFindUnauthorizedError 401 application/json
apierrors.DocumentAttachmentFindForbiddenError 403 application/json
apierrors.DocumentAttachmentFindNotFoundError 404 application/json
apierrors.DocumentAttachmentFindInternalServerError 500 application/json
apierrors.APIError 4XX, 5XX */*