Skip to content

Latest commit

 

History

History
193 lines (142 loc) · 7.67 KB

README.md

File metadata and controls

193 lines (142 loc) · 7.67 KB

Orders

(Orders)

Overview

Available Operations

List

List orders.

Scopes: orders:read

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/operations"
	"log"
)

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

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Orders.List(ctx, operations.OrdersListRequest{
        OrganizationID: polargo.Pointer(operations.CreateOrdersListQueryParamOrganizationIDFilterArrayOfStr(
            []string{
                "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
            },
        )),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceOrder != 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.OrdersListRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.OrdersListResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Get

Get an order by ID.

Scopes: orders:read

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"log"
)

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

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Orders.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Order != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The order ID.
opts []operations.Option The options for this request.

Response

*operations.OrdersGetResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Invoice

Get an order's invoice data.

Scopes: orders:read

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"log"
)

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

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Orders.Invoice(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.OrderInvoice != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The order ID.
opts []operations.Option The options for this request.

Response

*operations.OrdersInvoiceResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*