- List - List Attachments
- Upload - Upload attachment
- Get - Get Attachment
- Delete - Delete Attachment
- Download - Download Attachment
List Attachments
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"github.com/apideck-libraries/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Accounting.Attachments.List(ctx, operations.AccountingAttachmentsAllRequest{
ReferenceType: components.AttachmentReferenceTypeInvoice,
ReferenceID: "123456",
ServiceID: sdkgo.Pointer("salesforce"),
CompanyID: sdkgo.Pointer("12345"),
Fields: sdkgo.Pointer("id,updated_at"),
})
if err != nil {
log.Fatal(err)
}
if res.GetAttachmentsResponse != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.AccountingAttachmentsAllRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AccountingAttachmentsAllResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Upload attachment
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"github.com/apideck-libraries/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
example, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
res, err := s.Accounting.Attachments.Upload(ctx, operations.AccountingAttachmentsUploadRequest{
ReferenceType: components.AttachmentReferenceTypeInvoice,
ReferenceID: "12345",
XApideckMetadata: sdkgo.Pointer("{\"name\":\"document.pdf\",\"description\":\"Invoice attachment\"}"),
ServiceID: sdkgo.Pointer("salesforce"),
RequestBody: example,
})
if err != nil {
log.Fatal(err)
}
if res.CreateAttachmentResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.AccountingAttachmentsUploadRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AccountingAttachmentsUploadResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Get Attachment
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"github.com/apideck-libraries/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Accounting.Attachments.Get(ctx, operations.AccountingAttachmentsOneRequest{
ReferenceType: components.AttachmentReferenceTypeInvoice,
ReferenceID: "123456",
ID: "<id>",
ServiceID: sdkgo.Pointer("salesforce"),
CompanyID: sdkgo.Pointer("12345"),
Fields: sdkgo.Pointer("id,updated_at"),
})
if err != nil {
log.Fatal(err)
}
if res.GetAttachmentResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.AccountingAttachmentsOneRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AccountingAttachmentsOneResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Delete Attachment
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"github.com/apideck-libraries/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Accounting.Attachments.Delete(ctx, operations.AccountingAttachmentsDeleteRequest{
ReferenceType: components.AttachmentReferenceTypeInvoice,
ReferenceID: "123456",
ID: "<id>",
ServiceID: sdkgo.Pointer("salesforce"),
})
if err != nil {
log.Fatal(err)
}
if res.DeleteAttachmentResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.AccountingAttachmentsDeleteRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AccountingAttachmentsDeleteResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Download Attachment
package main
import(
"context"
"os"
sdkgo "github.com/apideck-libraries/sdk-go"
"github.com/apideck-libraries/sdk-go/models/components"
"github.com/apideck-libraries/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithConsumerID("test-consumer"),
sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
)
res, err := s.Accounting.Attachments.Download(ctx, operations.AccountingAttachmentsDownloadRequest{
ReferenceType: components.AttachmentReferenceTypeInvoice,
ReferenceID: "123456",
ID: "<id>",
ServiceID: sdkgo.Pointer("salesforce"),
CompanyID: sdkgo.Pointer("12345"),
Fields: sdkgo.Pointer("id,updated_at"),
})
if err != nil {
log.Fatal(err)
}
if res.GetAttachmentDownloadResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.AccountingAttachmentsDownloadRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AccountingAttachmentsDownloadResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.BadRequestResponse | 400 | application/json |
| apierrors.UnauthorizedResponse | 401 | application/json |
| apierrors.PaymentRequiredResponse | 402 | application/json |
| apierrors.NotFoundResponse | 404 | application/json |
| apierrors.UnprocessableResponse | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |