Skip to content

Latest commit

 

History

History
181 lines (133 loc) · 7.39 KB

README.md

File metadata and controls

181 lines (133 loc) · 7.39 KB

Orders

(Orders)

Overview

Available Operations

List

List orders.

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{})
    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.

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.

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