Skip to content

Latest commit

 

History

History
186 lines (138 loc) · 10 KB

README.md

File metadata and controls

186 lines (138 loc) · 10 KB

BenefitGrants

(CustomerPortal.BenefitGrants)

Overview

Available Operations

  • List - List Benefit Grants
  • Get - Get Benefit Grant
  • Update - Update Benefit Grant

List

List benefits grants of the authenticated customer or user.

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.CustomerPortal.BenefitGrants.List(ctx, operations.CustomerPortalBenefitGrantsListRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceCustomerBenefitGrant != 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.CustomerPortalBenefitGrantsListRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CustomerPortalBenefitGrantsListResponse, error

Errors

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

Get

Get a benefit grant by ID for the authenticated customer or user.

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.CustomerPortal.BenefitGrants.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.CustomerBenefitGrant != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CustomerPortalBenefitGrantsGetResponse, error

Errors

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

Update

Update a benefit grant for the authenticated customer or user.

Example Usage

package main

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

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.CustomerPortal.BenefitGrants.Update(ctx, "<value>", components.CreateCustomerBenefitGrantUpdateCustomerBenefitGrantDownloadablesUpdate(
        components.CustomerBenefitGrantDownloadablesUpdate{},
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.CustomerBenefitGrant != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The benefit grant ID.
customerBenefitGrantUpdate components.CustomerBenefitGrantUpdate ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.CustomerPortalBenefitGrantsUpdateResponse, error

Errors

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