Skip to content

Latest commit

 

History

History
615 lines (539 loc) · 31.9 KB

README.md

File metadata and controls

615 lines (539 loc) · 31.9 KB

Payments

(Accounting.Payments)

Overview

Available Operations

List

List Payments

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/types"
	"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.WithSecurity(os.Getenv("APIDECK_API_KEY")),
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
    )

    res, err := s.Accounting.Payments.List(ctx, operations.AccountingPaymentsAllRequest{
        ServiceID: sdkgo.String("salesforce"),
        Filter: &components.PaymentsFilter{
            UpdatedSince: types.MustNewTimeFromString("2020-09-30T07:43:32.000Z"),
        },
        Sort: &components.PaymentsSort{
            By: components.PaymentsSortByUpdatedAt.ToPointer(),
        },
        PassThrough: map[string]any{
            "search": "San Francisco",
        },
        Fields: sdkgo.String("id,updated_at"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetPaymentsResponse != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Parameters

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

Response

*operations.AccountingPaymentsAllResponse, error

Errors

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 */*

Create

Create Payment

Example Usage

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/types"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
    )

    res, err := s.Accounting.Payments.Create(ctx, operations.AccountingPaymentsAddRequest{
        ServiceID: sdkgo.String("salesforce"),
        Payment: components.PaymentInput{
            Currency: components.CurrencyUsd.ToPointer(),
            CurrencyRate: sdkgo.Float64(0.69),
            TotalAmount: sdkgo.Float64(49.99),
            Reference: sdkgo.String("123456"),
            PaymentMethod: sdkgo.String("cash"),
            PaymentMethodReference: sdkgo.String("123456"),
            PaymentMethodID: sdkgo.String("12345"),
            Account: &components.LinkedLedgerAccountInput{
                ID: sdkgo.String("123456"),
                NominalCode: sdkgo.String("N091"),
                Code: sdkgo.String("453"),
            },
            TransactionDate: types.MustNewTimeFromString("2021-05-01T12:00:00.000Z"),
            Customer: &components.LinkedCustomerInput{
                ID: sdkgo.String("12345"),
                DisplayName: sdkgo.String("Windsurf Shop"),
                Email: sdkgo.String("[email protected]"),
            },
            CompanyID: sdkgo.String("12345"),
            Reconciled: sdkgo.Bool(true),
            Status: components.PaymentStatusAuthorised.ToPointer(),
            Type: components.PaymentTypeAccountsReceivable.ToPointer(),
            Allocations: []components.AllocationInput{
                components.AllocationInput{
                    ID: sdkgo.String("123456"),
                    Amount: sdkgo.Float64(49.99),
                    AllocationID: sdkgo.String("123456"),
                },
                components.AllocationInput{
                    ID: sdkgo.String("123456"),
                    Amount: sdkgo.Float64(49.99),
                    AllocationID: sdkgo.String("123456"),
                },
            },
            Note: sdkgo.String("Some notes about this transaction"),
            Number: sdkgo.String("123456"),
            TrackingCategories: []*components.LinkedTrackingCategory{
                &components.LinkedTrackingCategory{
                    ID: sdkgo.String("123456"),
                    Name: sdkgo.String("New York"),
                },
                &components.LinkedTrackingCategory{
                    ID: sdkgo.String("123456"),
                    Name: sdkgo.String("New York"),
                },
            },
            CustomFields: []components.CustomField{
                components.CustomField{
                    ID: sdkgo.String("2389328923893298"),
                    Name: sdkgo.String("employee_level"),
                    Description: sdkgo.String("Employee Level"),
                    Value: sdkgo.Pointer(components.CreateValueStr(
                        "Uses Salesforce and Marketo",
                    )),
                },
                components.CustomField{
                    ID: sdkgo.String("2389328923893298"),
                    Name: sdkgo.String("employee_level"),
                    Description: sdkgo.String("Employee Level"),
                    Value: sdkgo.Pointer(components.CreateValueStr(
                        "Uses Salesforce and Marketo",
                    )),
                },
            },
            RowVersion: sdkgo.String("1-12345"),
            DisplayID: sdkgo.String("123456"),
            PassThrough: []components.PassThroughBody{
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CreatePaymentResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.AccountingPaymentsAddResponse, error

Errors

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

Get Payment

Example Usage

package main

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

func main() {
    ctx := context.Background()
    
    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
    )

    res, err := s.Accounting.Payments.Get(ctx, operations.AccountingPaymentsOneRequest{
        ID: "<id>",
        ServiceID: sdkgo.String("salesforce"),
        Fields: sdkgo.String("id,updated_at"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetPaymentResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.AccountingPaymentsOneResponse, error

Errors

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 */*

Update

Update Payment

Example Usage

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/types"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
    )

    res, err := s.Accounting.Payments.Update(ctx, operations.AccountingPaymentsUpdateRequest{
        ID: "<id>",
        ServiceID: sdkgo.String("salesforce"),
        Payment: components.PaymentInput{
            Currency: components.CurrencyUsd.ToPointer(),
            CurrencyRate: sdkgo.Float64(0.69),
            TotalAmount: sdkgo.Float64(49.99),
            Reference: sdkgo.String("123456"),
            PaymentMethod: sdkgo.String("cash"),
            PaymentMethodReference: sdkgo.String("123456"),
            PaymentMethodID: sdkgo.String("12345"),
            Account: &components.LinkedLedgerAccountInput{
                ID: sdkgo.String("123456"),
                NominalCode: sdkgo.String("N091"),
                Code: sdkgo.String("453"),
            },
            TransactionDate: types.MustNewTimeFromString("2021-05-01T12:00:00.000Z"),
            Customer: &components.LinkedCustomerInput{
                ID: sdkgo.String("12345"),
                DisplayName: sdkgo.String("Windsurf Shop"),
                Email: sdkgo.String("[email protected]"),
            },
            CompanyID: sdkgo.String("12345"),
            Reconciled: sdkgo.Bool(true),
            Status: components.PaymentStatusAuthorised.ToPointer(),
            Type: components.PaymentTypeAccountsReceivable.ToPointer(),
            Allocations: []components.AllocationInput{
                components.AllocationInput{
                    ID: sdkgo.String("123456"),
                    Amount: sdkgo.Float64(49.99),
                    AllocationID: sdkgo.String("123456"),
                },
                components.AllocationInput{
                    ID: sdkgo.String("123456"),
                    Amount: sdkgo.Float64(49.99),
                    AllocationID: sdkgo.String("123456"),
                },
                components.AllocationInput{
                    ID: sdkgo.String("123456"),
                    Amount: sdkgo.Float64(49.99),
                    AllocationID: sdkgo.String("123456"),
                },
            },
            Note: sdkgo.String("Some notes about this transaction"),
            Number: sdkgo.String("123456"),
            TrackingCategories: []*components.LinkedTrackingCategory{
                &components.LinkedTrackingCategory{
                    ID: sdkgo.String("123456"),
                    Name: sdkgo.String("New York"),
                },
                &components.LinkedTrackingCategory{
                    ID: sdkgo.String("123456"),
                    Name: sdkgo.String("New York"),
                },
            },
            CustomFields: []components.CustomField{
                components.CustomField{
                    ID: sdkgo.String("2389328923893298"),
                    Name: sdkgo.String("employee_level"),
                    Description: sdkgo.String("Employee Level"),
                    Value: sdkgo.Pointer(components.CreateValueArrayOf6(
                        []components.Six{
                            components.Six{},
                            components.Six{},
                        },
                    )),
                },
                components.CustomField{
                    ID: sdkgo.String("2389328923893298"),
                    Name: sdkgo.String("employee_level"),
                    Description: sdkgo.String("Employee Level"),
                    Value: sdkgo.Pointer(components.CreateValueBoolean(
                        true,
                    )),
                },
            },
            RowVersion: sdkgo.String("1-12345"),
            DisplayID: sdkgo.String("123456"),
            PassThrough: []components.PassThroughBody{
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
                components.PassThroughBody{
                    ServiceID: "<id>",
                    ExtendPaths: []components.ExtendPaths{
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                        components.ExtendPaths{
                            Path: "$.nested.property",
                            Value: map[string]any{
                                "TaxClassificationRef": map[string]any{
                                    "value": "EUC-99990201-V1-00020000",
                                },
                            },
                        },
                    },
                },
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.UpdatePaymentResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.AccountingPaymentsUpdateResponse, error

Errors

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

Delete Payment

Example Usage

package main

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

func main() {
    ctx := context.Background()
    
    s := sdkgo.New(
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
    )

    res, err := s.Accounting.Payments.Delete(ctx, operations.AccountingPaymentsDeleteRequest{
        ID: "<id>",
        ServiceID: sdkgo.String("salesforce"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.DeletePaymentResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.AccountingPaymentsDeleteResponse, error

Errors

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 */*