Skip to content

Latest commit

 

History

History
134 lines (98 loc) · 8.78 KB

README.md

File metadata and controls

134 lines (98 loc) · 8.78 KB

PolarCustomerMeters

(CustomerPortal.CustomerMeters)

Overview

Available Operations

  • List - List Meters
  • Get - Get Customer Meter

List

List meters of the authenticated customer.

Scopes: customer_portal:read customer_portal:write

Example Usage

package main

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

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

    s := polargo.New()

    res, err := s.CustomerPortal.CustomerMeters.List(ctx, operations.CustomerPortalCustomerMetersListRequest{}, operations.CustomerPortalCustomerMetersListSecurity{
        CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceCustomerCustomerMeter != 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.CustomerPortalCustomerMetersListRequest ✔️ The request object to use for the request.
security operations.CustomerPortalCustomerMetersListSecurity ✔️ The security requirements to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CustomerPortalCustomerMetersListResponse, error

Errors

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

Get

Get a meter by ID for the authenticated customer.

Scopes: customer_portal:read customer_portal:write

Example Usage

package main

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

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

    s := polargo.New()

    res, err := s.CustomerPortal.CustomerMeters.Get(ctx, operations.CustomerPortalCustomerMetersGetSecurity{
        CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
    }, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.CustomerCustomerMeter != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CustomerPortalCustomerMetersGetResponse, error

Errors

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