polargo

package module
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 13 Imported by: 2

README

github.com/polarsource/polar-go

Developer-friendly & type-safe Go SDK specifically catered to leverage github.com/polarsource/polar-go API.



[!IMPORTANT] This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.

Summary

Polar API: Polar HTTP and Webhooks API

Read the docs at https://docs.polar.sh/api-reference

Table of Contents

SDK Installation

To add the SDK as a dependency to your project:

go get github.com/polarsource/polar-go

SDK Example Usage

Example
package main

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

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

	s := polargo.New()

	res, err := s.EndpointcheckoutCreatedPost(ctx, components.WebhookCheckoutCreatedPayload{
		Data: components.Checkout{
			CreatedAt:              types.MustTimeFromString("2025-11-12T14:26:42.882Z"),
			ModifiedAt:             types.MustNewTimeFromString("2024-05-27T05:08:06.235Z"),
			ID:                     "<value>",
			PaymentProcessor:       components.PaymentProcessorStripe,
			Status:                 components.CheckoutStatusFailed,
			ClientSecret:           "<value>",
			URL:                    "https://heavy-beret.com/",
			ExpiresAt:              types.MustTimeFromString("2023-02-25T02:26:48.460Z"),
			SuccessURL:             "https://sardonic-final.info/",
			EmbedOrigin:            polargo.String("<value>"),
			Amount:                 polargo.Int64(962818),
			TaxAmount:              polargo.Int64(6400),
			Currency:               polargo.String("Yen"),
			SubtotalAmount:         polargo.Int64(648726),
			TotalAmount:            polargo.Int64(210702),
			ProductID:              "<value>",
			ProductPriceID:         "<value>",
			DiscountID:             polargo.String("<value>"),
			AllowDiscountCodes:     true,
			IsDiscountApplicable:   false,
			IsFreeProductPrice:     false,
			IsPaymentRequired:      false,
			IsPaymentSetupRequired: false,
			IsPaymentFormRequired:  false,
			CustomerID:             polargo.String("<value>"),
			CustomerName:           polargo.String("<value>"),
			CustomerEmail:          polargo.String("<value>"),
			CustomerIPAddress:      polargo.String("<value>"),
			CustomerBillingAddress: &components.Address{
				Country: "FR",
			},
			CustomerTaxID: polargo.String("<id>"),
			PaymentProcessorMetadata: map[string]string{
				"key":  "<value>",
				"key1": "<value>",
				"key2": "<value>",
			},
			Metadata: map[string]components.CheckoutMetadata{
				"key": components.CreateCheckoutMetadataStr(
					"<value>",
				),
			},
			CustomerExternalID: polargo.String("<id>"),
			Products: []components.CheckoutProduct{
				components.CheckoutProduct{
					CreatedAt:         types.MustTimeFromString("2024-05-27T05:08:06.235Z"),
					ModifiedAt:        types.MustNewTimeFromString("2025-11-19T15:59:15.588Z"),
					ID:                "<value>",
					Name:              "<value>",
					Description:       polargo.String("brr institute tired rotten relative"),
					RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
					IsRecurring:       false,
					IsArchived:        false,
					OrganizationID:    "<value>",
					Prices:            []components.CheckoutProductPrices{},
					Benefits: []components.BenefitBase{
						components.BenefitBase{
							CreatedAt:      types.MustTimeFromString("2023-04-26T22:34:57.487Z"),
							ModifiedAt:     types.MustNewTimeFromString("2023-08-07T19:57:51.694Z"),
							ID:             "<value>",
							Type:           components.BenefitTypeDiscord,
							Description:    "when waterlogged godparent pure solidly content sonar progress pacemaker",
							Selectable:     true,
							Deletable:      false,
							OrganizationID: "<value>",
						},
						components.BenefitBase{
							CreatedAt:      types.MustTimeFromString("2024-10-18T15:45:53.088Z"),
							ModifiedAt:     types.MustNewTimeFromString("2023-08-08T05:58:49.836Z"),
							ID:             "<value>",
							Type:           components.BenefitTypeLicenseKeys,
							Description:    "language traduce shrill minor hourly which yearly deeply but",
							Selectable:     false,
							Deletable:      false,
							OrganizationID: "<value>",
						},
					},
					Medias: []components.ProductMediaFileRead{
						components.ProductMediaFileRead{
							ID:                   "<value>",
							OrganizationID:       "<value>",
							Name:                 "<value>",
							Path:                 "/Applications",
							MimeType:             "<value>",
							Size:                 271748,
							StorageVersion:       polargo.String("<value>"),
							ChecksumEtag:         polargo.String("<value>"),
							ChecksumSha256Base64: polargo.String("<value>"),
							ChecksumSha256Hex:    polargo.String("<value>"),
							LastModifiedAt:       types.MustNewTimeFromString("2023-03-11T18:00:05.573Z"),
							Version:              polargo.String("<value>"),
							IsUploaded:           false,
							CreatedAt:            types.MustTimeFromString("2025-09-09T13:21:53.200Z"),
							SizeReadable:         "<value>",
							PublicURL:            "https://male-season.net/",
						},
						components.ProductMediaFileRead{
							ID:                   "<value>",
							OrganizationID:       "<value>",
							Name:                 "<value>",
							Path:                 "/bin",
							MimeType:             "<value>",
							Size:                 187532,
							StorageVersion:       polargo.String("<value>"),
							ChecksumEtag:         polargo.String("<value>"),
							ChecksumSha256Base64: polargo.String("<value>"),
							ChecksumSha256Hex:    polargo.String("<value>"),
							LastModifiedAt:       types.MustNewTimeFromString("2023-12-07T16:19:25.811Z"),
							Version:              polargo.String("<value>"),
							IsUploaded:           false,
							CreatedAt:            types.MustTimeFromString("2023-12-31T15:42:50.685Z"),
							SizeReadable:         "<value>",
							PublicURL:            "https://squeaky-editor.name",
						},
						components.ProductMediaFileRead{
							ID:                   "<value>",
							OrganizationID:       "<value>",
							Name:                 "<value>",
							Path:                 "/usr/bin",
							MimeType:             "<value>",
							Size:                 910846,
							StorageVersion:       polargo.String("<value>"),
							ChecksumEtag:         polargo.String("<value>"),
							ChecksumSha256Base64: polargo.String("<value>"),
							ChecksumSha256Hex:    polargo.String("<value>"),
							LastModifiedAt:       types.MustNewTimeFromString("2025-02-19T14:34:23.071Z"),
							Version:              polargo.String("<value>"),
							IsUploaded:           true,
							CreatedAt:            types.MustTimeFromString("2024-07-14T23:53:19.831Z"),
							SizeReadable:         "<value>",
							PublicURL:            "https://sad-pupil.info/",
						},
					},
				},
				components.CheckoutProduct{
					CreatedAt:         types.MustTimeFromString("2025-09-29T06:23:47.676Z"),
					ModifiedAt:        types.MustNewTimeFromString("2024-07-02T05:50:09.114Z"),
					ID:                "<value>",
					Name:              "<value>",
					Description:       polargo.String("as weekly drat nor why sparkling"),
					RecurringInterval: components.SubscriptionRecurringIntervalMonth.ToPointer(),
					IsRecurring:       false,
					IsArchived:        false,
					OrganizationID:    "<value>",
					Prices: []components.CheckoutProductPrices{
						components.CreateCheckoutProductPricesProductPrice(
							components.CreateProductPriceProductPriceFree(
								components.ProductPriceFree{
									CreatedAt:         types.MustTimeFromString("2023-09-19T22:46:24.110Z"),
									ModifiedAt:        types.MustNewTimeFromString("2024-10-23T17:16:18.939Z"),
									ID:                "<value>",
									IsArchived:        false,
									ProductID:         "<value>",
									Type:              components.ProductPriceTypeOneTime,
									RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
								},
							),
						),
						components.CreateCheckoutProductPricesProductPrice(
							components.CreateProductPriceProductPriceCustom(
								components.ProductPriceCustom{
									CreatedAt:         types.MustTimeFromString("2025-10-29T00:32:24.235Z"),
									ModifiedAt:        types.MustNewTimeFromString("2025-04-28T15:46:25.145Z"),
									ID:                "<value>",
									IsArchived:        false,
									ProductID:         "<value>",
									Type:              components.ProductPriceTypeRecurring,
									RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
									PriceCurrency:     "<value>",
									MinimumAmount:     polargo.Int64(634111),
									MaximumAmount:     polargo.Int64(482040),
									PresetAmount:      polargo.Int64(134),
								},
							),
						),
					},
					Benefits: []components.BenefitBase{
						components.BenefitBase{
							CreatedAt:      types.MustTimeFromString("2025-10-16T20:09:46.139Z"),
							ModifiedAt:     types.MustNewTimeFromString("2023-09-29T18:20:07.088Z"),
							ID:             "<value>",
							Type:           components.BenefitTypeGithubRepository,
							Description:    "pupil divine roundabout gah oh hm over equatorial",
							Selectable:     false,
							Deletable:      false,
							OrganizationID: "<value>",
						},
					},
					Medias: []components.ProductMediaFileRead{
						components.ProductMediaFileRead{
							ID:                   "<value>",
							OrganizationID:       "<value>",
							Name:                 "<value>",
							Path:                 "/lib",
							MimeType:             "<value>",
							Size:                 887018,
							StorageVersion:       polargo.String("<value>"),
							ChecksumEtag:         polargo.String("<value>"),
							ChecksumSha256Base64: polargo.String("<value>"),
							ChecksumSha256Hex:    polargo.String("<value>"),
							LastModifiedAt:       types.MustNewTimeFromString("2025-11-07T16:20:25.796Z"),
							Version:              polargo.String("<value>"),
							IsUploaded:           true,
							CreatedAt:            types.MustTimeFromString("2024-11-17T23:09:10.440Z"),
							SizeReadable:         "<value>",
							PublicURL:            "https://untimely-information.net/",
						},
						components.ProductMediaFileRead{
							ID:                   "<value>",
							OrganizationID:       "<value>",
							Name:                 "<value>",
							Path:                 "/usr/local/bin",
							MimeType:             "<value>",
							Size:                 75636,
							StorageVersion:       polargo.String("<value>"),
							ChecksumEtag:         polargo.String("<value>"),
							ChecksumSha256Base64: polargo.String("<value>"),
							ChecksumSha256Hex:    polargo.String("<value>"),
							LastModifiedAt:       types.MustNewTimeFromString("2023-02-06T03:34:19.712Z"),
							Version:              polargo.String("<value>"),
							IsUploaded:           true,
							CreatedAt:            types.MustTimeFromString("2023-03-25T12:20:31.544Z"),
							SizeReadable:         "<value>",
							PublicURL:            "https://immense-finer.com/",
						},
						components.ProductMediaFileRead{
							ID:                   "<value>",
							OrganizationID:       "<value>",
							Name:                 "<value>",
							Path:                 "/srv",
							MimeType:             "<value>",
							Size:                 544978,
							StorageVersion:       polargo.String("<value>"),
							ChecksumEtag:         polargo.String("<value>"),
							ChecksumSha256Base64: polargo.String("<value>"),
							ChecksumSha256Hex:    polargo.String("<value>"),
							LastModifiedAt:       types.MustNewTimeFromString("2024-09-24T17:52:13.602Z"),
							Version:              polargo.String("<value>"),
							IsUploaded:           false,
							CreatedAt:            types.MustTimeFromString("2023-09-28T13:20:26.690Z"),
							SizeReadable:         "<value>",
							PublicURL:            "https://pastel-character.info",
						},
					},
				},
				components.CheckoutProduct{
					CreatedAt:         types.MustTimeFromString("2023-09-09T06:37:57.046Z"),
					ModifiedAt:        types.MustNewTimeFromString("2024-12-25T00:01:30.412Z"),
					ID:                "<value>",
					Name:              "<value>",
					Description:       polargo.String("delectable ugh likewise than every how milestone"),
					RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
					IsRecurring:       true,
					IsArchived:        false,
					OrganizationID:    "<value>",
					Prices: []components.CheckoutProductPrices{
						components.CreateCheckoutProductPricesLegacyRecurringProductPrice(
							components.CreateLegacyRecurringProductPriceFree(
								components.LegacyRecurringProductPriceFree{
									CreatedAt:         types.MustTimeFromString("2023-10-21T11:52:11.842Z"),
									ModifiedAt:        types.MustNewTimeFromString("2023-10-09T19:13:38.530Z"),
									ID:                "<value>",
									IsArchived:        false,
									ProductID:         "<value>",
									RecurringInterval: components.SubscriptionRecurringIntervalYear,
								},
							),
						),
						components.CreateCheckoutProductPricesProductPrice(
							components.CreateProductPriceProductPriceCustom(
								components.ProductPriceCustom{
									CreatedAt:         types.MustTimeFromString("2024-12-10T06:44:06.426Z"),
									ModifiedAt:        types.MustNewTimeFromString("2025-11-05T18:06:37.266Z"),
									ID:                "<value>",
									IsArchived:        false,
									ProductID:         "<value>",
									Type:              components.ProductPriceTypeRecurring,
									RecurringInterval: components.SubscriptionRecurringIntervalMonth.ToPointer(),
									PriceCurrency:     "<value>",
									MinimumAmount:     polargo.Int64(102328),
									MaximumAmount:     polargo.Int64(332863),
									PresetAmount:      polargo.Int64(287633),
								},
							),
						),
						components.CreateCheckoutProductPricesProductPrice(
							components.CreateProductPriceProductPriceCustom(
								components.ProductPriceCustom{
									CreatedAt:         types.MustTimeFromString("2024-09-15T18:10:19.969Z"),
									ModifiedAt:        types.MustNewTimeFromString("2025-12-08T10:05:37.208Z"),
									ID:                "<value>",
									IsArchived:        false,
									ProductID:         "<value>",
									Type:              components.ProductPriceTypeRecurring,
									RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
									PriceCurrency:     "<value>",
									MinimumAmount:     polargo.Int64(674791),
									MaximumAmount:     polargo.Int64(138001),
									PresetAmount:      polargo.Int64(879649),
								},
							),
						),
					},
					Benefits: []components.BenefitBase{
						components.BenefitBase{
							CreatedAt:      types.MustTimeFromString("2024-04-20T16:45:08.626Z"),
							ModifiedAt:     types.MustNewTimeFromString("2025-10-27T21:24:45.236Z"),
							ID:             "<value>",
							Type:           components.BenefitTypeDiscord,
							Description:    "until tenderly chapel quantify optimistically excluding aw because amongst emulsify",
							Selectable:     false,
							Deletable:      false,
							OrganizationID: "<value>",
						},
						components.BenefitBase{
							CreatedAt:      types.MustTimeFromString("2023-12-28T12:56:50.963Z"),
							ModifiedAt:     types.MustNewTimeFromString("2023-07-08T17:24:16.616Z"),
							ID:             "<value>",
							Type:           components.BenefitTypeLicenseKeys,
							Description:    "denitrify um extremely scotch breed rebuild tighten poppy unwritten apostrophize",
							Selectable:     false,
							Deletable:      true,
							OrganizationID: "<value>",
						},
					},
					Medias: []components.ProductMediaFileRead{},
				},
			},
			Product: components.CheckoutProduct{
				CreatedAt:         types.MustTimeFromString("2024-11-17T19:11:13.132Z"),
				ModifiedAt:        types.MustNewTimeFromString("2024-02-27T04:46:39.621Z"),
				ID:                "<value>",
				Name:              "<value>",
				Description:       polargo.String("border opposite overload interior shady"),
				RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
				IsRecurring:       false,
				IsArchived:        true,
				OrganizationID:    "<value>",
				Prices:            []components.CheckoutProductPrices{},
				Benefits: []components.BenefitBase{
					components.BenefitBase{
						CreatedAt:      types.MustTimeFromString("2025-08-24T18:28:03.144Z"),
						ModifiedAt:     types.MustNewTimeFromString("2023-10-21T11:52:11.842Z"),
						ID:             "<value>",
						Type:           components.BenefitTypeCustom,
						Description:    "certainly these restfully geez who countess happily gym",
						Selectable:     false,
						Deletable:      false,
						OrganizationID: "<value>",
					},
				},
				Medias: []components.ProductMediaFileRead{
					components.ProductMediaFileRead{
						ID:                   "<value>",
						OrganizationID:       "<value>",
						Name:                 "<value>",
						Path:                 "/private/tmp",
						MimeType:             "<value>",
						Size:                 486328,
						StorageVersion:       polargo.String("<value>"),
						ChecksumEtag:         polargo.String("<value>"),
						ChecksumSha256Base64: polargo.String("<value>"),
						ChecksumSha256Hex:    polargo.String("<value>"),
						LastModifiedAt:       types.MustNewTimeFromString("2023-09-26T17:28:00.673Z"),
						Version:              polargo.String("<value>"),
						IsUploaded:           true,
						CreatedAt:            types.MustTimeFromString("2025-05-06T18:54:29.001Z"),
						SizeReadable:         "<value>",
						PublicURL:            "https://forsaken-underpants.biz",
					},
					components.ProductMediaFileRead{
						ID:                   "<value>",
						OrganizationID:       "<value>",
						Name:                 "<value>",
						Path:                 "/Users",
						MimeType:             "<value>",
						Size:                 796127,
						StorageVersion:       polargo.String("<value>"),
						ChecksumEtag:         polargo.String("<value>"),
						ChecksumSha256Base64: polargo.String("<value>"),
						ChecksumSha256Hex:    polargo.String("<value>"),
						LastModifiedAt:       types.MustNewTimeFromString("2023-09-05T18:42:07.313Z"),
						Version:              polargo.String("<value>"),
						IsUploaded:           false,
						CreatedAt:            types.MustTimeFromString("2025-10-05T11:55:07.194Z"),
						SizeReadable:         "<value>",
						PublicURL:            "https://quick-witted-markup.org/",
					},
				},
			},
			ProductPrice: components.CreateCheckoutProductPriceProductPrice(
				components.CreateProductPriceProductPriceFixed(
					components.ProductPriceFixed{
						CreatedAt:         types.MustTimeFromString("2025-01-07T06:19:30.216Z"),
						ModifiedAt:        types.MustNewTimeFromString("2025-12-22T08:06:55.176Z"),
						ID:                "<value>",
						IsArchived:        false,
						ProductID:         "<value>",
						Type:              components.ProductPriceTypeOneTime,
						RecurringInterval: components.SubscriptionRecurringIntervalYear.ToPointer(),
						PriceCurrency:     "<value>",
						PriceAmount:       449076,
					},
				),
			),
			Discount: polargo.Pointer(components.CreateCheckoutDiscountCheckoutDiscountPercentageOnceForeverDuration(
				components.CheckoutDiscountPercentageOnceForeverDuration{
					Duration:    components.DiscountDurationRepeating,
					Type:        components.DiscountTypePercentage,
					BasisPoints: 416143,
					ID:          "<value>",
					Name:        "<value>",
					Code:        polargo.String("<value>"),
				},
			)),
			SubscriptionID: polargo.String("<value>"),
			AttachedCustomFields: []components.AttachedCustomField{
				components.AttachedCustomField{
					CustomFieldID: "<value>",
					CustomField: components.CreateCustomFieldSelect(
						components.CustomFieldSelect{
							CreatedAt:  types.MustTimeFromString("2023-07-01T09:35:23.526Z"),
							ModifiedAt: types.MustNewTimeFromString("2023-09-05T11:14:58.018Z"),
							ID:         "<value>",
							Metadata: map[string]components.CustomFieldSelectMetadata{
								"key": components.CreateCustomFieldSelectMetadataBoolean(
									false,
								),
							},
							Slug:           "<value>",
							Name:           "<value>",
							OrganizationID: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
							Properties: components.CustomFieldSelectProperties{
								Options: []components.CustomFieldSelectOption{
									components.CustomFieldSelectOption{
										Value: "<value>",
										Label: "<value>",
									},
								},
							},
						},
					),
					Order:    169862,
					Required: true,
				},
				components.AttachedCustomField{
					CustomFieldID: "<value>",
					CustomField: components.CreateCustomFieldText(
						components.CustomFieldText{
							CreatedAt:  types.MustTimeFromString("2024-12-03T12:38:50.277Z"),
							ModifiedAt: types.MustNewTimeFromString("2024-05-21T13:41:47.986Z"),
							ID:         "<value>",
							Metadata: map[string]components.CustomFieldTextMetadata{
								"key": components.CreateCustomFieldTextMetadataInteger(
									473941,
								),
							},
							Slug:           "<value>",
							Name:           "<value>",
							OrganizationID: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
							Properties:     components.CustomFieldTextProperties{},
						},
					),
					Order:    918364,
					Required: true,
				},
				components.AttachedCustomField{
					CustomFieldID: "<value>",
					CustomField: components.CreateCustomFieldText(
						components.CustomFieldText{
							CreatedAt:  types.MustTimeFromString("2023-01-30T18:58:55.355Z"),
							ModifiedAt: types.MustNewTimeFromString("2024-12-15T18:35:30.312Z"),
							ID:         "<value>",
							Metadata: map[string]components.CustomFieldTextMetadata{
								"key": components.CreateCustomFieldTextMetadataInteger(
									143857,
								),
							},
							Slug:           "<value>",
							Name:           "<value>",
							OrganizationID: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
							Properties:     components.CustomFieldTextProperties{},
						},
					),
					Order:    187532,
					Required: true,
				},
			},
			CustomerMetadata: map[string]components.CheckoutCustomerMetadata{
				"key": components.CreateCheckoutCustomerMetadataStr(
					"<value>",
				),
				"key1": components.CreateCheckoutCustomerMetadataInteger(
					790078,
				),
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.Any != nil {
		// handle response
	}
}

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme Environment Variable
AccessToken http HTTP Bearer POLAR_ACCESS_TOKEN

You can configure it using the WithSecurity option when initializing the SDK client instance. For example:

package main

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

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

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

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.ListResourceExternalOrganization != nil {
		for {
			// handle items

			res, err = res.Next()

			if err != nil {
				// handle error
			}

			if res == nil {
				break
			}
		}
	}
}

Per-Operation Security Schemes

Some operations in this SDK require the security scheme to be specified at the request level. For example:

package main

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

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

	s := polargo.New()

	res, err := s.CustomerPortal.BenefitGrants.List(ctx, operations.CustomerPortalBenefitGrantsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateCustomerPortalBenefitGrantsListQueryParamOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	}, operations.CustomerPortalBenefitGrantsListSecurity{
		CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
	})
	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
			}
		}
	}
}

Available Resources and Operations

Available methods
Benefits
  • List - List Checkout Links
  • Create - Create Checkout Link
  • Get - Get Checkout Link
  • Update - Update Checkout Link
  • Delete - Delete Checkout Link
Checkouts
  • List - List Checkout Sessions
  • Create - Create Checkout Session
  • Get - Get Checkout Session
  • Update - Update Checkout Session
  • ClientGet - Get Checkout Session from Client
  • ClientUpdate - Update Checkout Session from Client
  • ClientConfirm - Confirm Checkout Session from Client
CustomerPortal
CustomerPortal.BenefitGrants
  • List - List Benefit Grants
  • Get - Get Benefit Grant
  • Update - Update Benefit Grant
CustomerPortal.Customers
CustomerPortal.Downloadables
  • List - List Downloadables
  • Get - Get Downloadable
CustomerPortal.LicenseKeys
CustomerPortal.Orders
CustomerPortal.Organizations
  • Get - Get Organization
CustomerPortal.Subscriptions
  • List - List Subscriptions
  • Get - Get Subscription
  • Update - Update Subscription
  • Cancel - Cancel Subscription
Customers
CustomerSessions
  • Create - Create Customer Session
CustomFields
  • List - List Custom Fields
  • Create - Create Custom Field
  • Get - Get Custom Field
  • Update - Update Custom Field
  • Delete - Delete Custom Field
Discounts
Events
ExternalOrganizations
  • List - List External Organizations
Files
LicenseKeys
Meters
Metrics
  • Get - Get Metrics
  • Limits - Get Metrics Limits
Oauth2
Oauth2.Clients
Orders
Organizations
  • List - List Organizations
  • Create - Create Organization
  • Get - Get Organization
  • Update - Update Organization
Products
Refunds
Repositories
  • List - List Repositories
  • Get - Get Repository
  • Update - Update Repository
Subscriptions
  • List - List Subscriptions
  • Export - Export Subscriptions
  • Get - Get Subscription
  • Update - Update Subscription
  • Revoke - Revoke Subscription

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will have a Next method that can be called to pull down the next group of results. If the return value of Next is nil, then there are no more pages to be fetched.

Here's an example of one such pagination call:

package main

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

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

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

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.ListResourceExternalOrganization != nil {
		for {
			// handle items

			res, err = res.Next()

			if err != nil {
				// handle error
			}

			if res == nil {
				break
			}
		}
	}
}

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retry.Config object to the call by using the WithRetries option:

package main

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

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

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

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	}, operations.WithRetries(
		retry.Config{
			Strategy: "backoff",
			Backoff: &retry.BackoffStrategy{
				InitialInterval: 1,
				MaxInterval:     50,
				Exponent:        1.1,
				MaxElapsedTime:  100,
			},
			RetryConnectionErrors: false,
		}))
	if err != nil {
		log.Fatal(err)
	}
	if res.ListResourceExternalOrganization != nil {
		for {
			// handle items

			res, err = res.Next()

			if err != nil {
				// handle error
			}

			if res == nil {
				break
			}
		}
	}
}

If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:

package main

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

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

	s := polargo.New(
		polargo.WithRetryConfig(
			retry.Config{
				Strategy: "backoff",
				Backoff: &retry.BackoffStrategy{
					InitialInterval: 1,
					MaxInterval:     50,
					Exponent:        1.1,
					MaxElapsedTime:  100,
				},
				RetryConnectionErrors: false,
			}),
		polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
	)

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.ListResourceExternalOrganization != nil {
		for {
			// handle items

			res, err = res.Next()

			if err != nil {
				// handle error
			}

			if res == nil {
				break
			}
		}
	}
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.

By Default, an API error will return apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.

For example, the List function may return the following errors:

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

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

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

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

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	})
	if err != nil {

		var e *apierrors.HTTPValidationError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *apierrors.APIError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Select Server by Name

You can override the default server globally using the WithServer(server string) option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:

Name Server Description
production https://api.polar.sh Production environment
sandbox https://sandbox-api.polar.sh Sandbox environment
Example
package main

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

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

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

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.ListResourceExternalOrganization != nil {
		for {
			// handle items

			res, err = res.Next()

			if err != nil {
				// handle error
			}

			if res == nil {
				break
			}
		}
	}
}

Override Server URL Per-Client

The default server can also be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:

package main

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

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

	s := polargo.New(
		polargo.WithServerURL("https://api.polar.sh"),
		polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
	)

	res, err := s.ExternalOrganizations.List(ctx, operations.ExternalOrganizationsListRequest{
		OrganizationID: polargo.Pointer(operations.CreateOrganizationIDFilterArrayOfStr(
			[]string{
				"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
			},
		)),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.ListResourceExternalOrganization != nil {
		for {
			// handle items

			res, err = res.Next()

			if err != nil {
				// handle error
			}

			if res == nil {
				break
			}
		}
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"
	"github.com/myorg/your-go-sdk"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = sdk.New(sdk.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Special Types

This SDK defines the following custom types to assist with marshalling and unmarshalling data.

Date

types.Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02".

Usage
d1 := types.NewDate(time.Now()) // returns *types.Date

d2 := types.DateFromTime(time.Now()) // returns types.Date

d3, err := types.NewDateFromString("2019-01-01") // returns *types.Date, error

d4, err := types.DateFromString("2019-01-01") // returns types.Date, error

d5 := types.MustNewDateFromString("2019-01-01") // returns *types.Date and panics on error

d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on error

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

Documentation

Index

Constants

View Source
const (
	// Production environment
	ServerProduction string = "production"
	// Sandbox environment
	ServerSandbox string = "sandbox"
)

Variables

View Source
var ServerList = map[string]string{
	ServerProduction: "https://api.polar.sh",
	ServerSandbox:    "https://sandbox-api.polar.sh",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func Pointer

func Pointer[T any](v T) *T

Pointer provides a helper function to return a pointer to a type

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type BenefitGrants

type BenefitGrants struct {
	// contains filtered or unexported fields
}

func (*BenefitGrants) Get

Get Benefit Grant Get a benefit grant by ID for the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*BenefitGrants) List

List Benefit Grants List benefits grants of the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*BenefitGrants) Update

Update Benefit Grant Update a benefit grant for the authenticated customer.

**Scopes**: `customer_portal:write`

type Benefits

type Benefits struct {
	// contains filtered or unexported fields
}

func (*Benefits) Create

Create Benefit Create a benefit.

**Scopes**: `benefits:write`

func (*Benefits) Delete

Delete Benefit Delete a benefit.

> [!WARNING] > Every grants associated with the benefit will be revoked. > Users will lose access to the benefit.

**Scopes**: `benefits:write`

func (*Benefits) Get

Get Benefit Get a benefit by ID.

**Scopes**: `benefits:read` `benefits:write`

func (*Benefits) Grants

Grants - List Benefit Grants List the individual grants for a benefit.

It's especially useful to check if a user has been granted a benefit.

**Scopes**: `benefits:read` `benefits:write`

func (*Benefits) List

List Benefits List benefits.

**Scopes**: `benefits:read` `benefits:write`

func (*Benefits) Update

Update Benefit Update a benefit.

**Scopes**: `benefits:write`

type CheckoutLinks struct {
	// contains filtered or unexported fields
}

func (*CheckoutLinks) Create

Create Checkout Link Create a checkout link.

**Scopes**: `checkout_links:write`

func (*CheckoutLinks) Delete

Delete Checkout Link Delete a checkout link.

**Scopes**: `checkout_links:write`

func (*CheckoutLinks) Get

Get Checkout Link Get a checkout link by ID.

**Scopes**: `checkout_links:read` `checkout_links:write`

func (*CheckoutLinks) List

List Checkout Links List checkout links.

**Scopes**: `checkout_links:read` `checkout_links:write`

func (*CheckoutLinks) Update

Update Checkout Link Update a checkout link.

**Scopes**: `checkout_links:write`

type Checkouts

type Checkouts struct {
	// contains filtered or unexported fields
}

func (*Checkouts) ClientConfirm added in v0.2.0

func (s *Checkouts) ClientConfirm(ctx context.Context, clientSecret string, checkoutConfirmStripe components.CheckoutConfirmStripe, opts ...operations.Option) (*operations.CheckoutsClientConfirmResponse, error)

ClientConfirm - Confirm Checkout Session from Client Confirm a checkout session by client secret.

Orders and subscriptions will be processed.

func (*Checkouts) ClientGet added in v0.2.0

func (s *Checkouts) ClientGet(ctx context.Context, clientSecret string, opts ...operations.Option) (*operations.CheckoutsClientGetResponse, error)

ClientGet - Get Checkout Session from Client Get a checkout session by client secret.

func (*Checkouts) ClientUpdate added in v0.2.0

func (s *Checkouts) ClientUpdate(ctx context.Context, clientSecret string, checkoutUpdatePublic components.CheckoutUpdatePublic, opts ...operations.Option) (*operations.CheckoutsClientUpdateResponse, error)

ClientUpdate - Update Checkout Session from Client Update a checkout session by client secret.

func (*Checkouts) Create

Create Checkout Session Create a checkout session.

**Scopes**: `checkouts:write`

func (*Checkouts) Get

Get Checkout Session Get a checkout session by ID.

**Scopes**: `checkouts:read` `checkouts:write`

func (*Checkouts) List added in v0.2.0

List Checkout Sessions List checkout sessions.

**Scopes**: `checkouts:read` `checkouts:write`

func (*Checkouts) Update added in v0.2.0

Update Checkout Session Update a checkout session.

**Scopes**: `checkouts:write`

type Clients

type Clients struct {
	// contains filtered or unexported fields
}

func (*Clients) Create

Create Client Create an OAuth2 client.

func (*Clients) Delete

Delete Client Delete an OAuth2 client.

func (*Clients) Get

Get Client Get an OAuth2 client by Client ID.

func (*Clients) List

func (s *Clients) List(ctx context.Context, page *int64, limit *int64, opts ...operations.Option) (*operations.Oauth2ClientsListResponse, error)

List Clients List OAuth2 clients.

func (*Clients) Update

Update Client Update an OAuth2 client.

type CustomFields

type CustomFields struct {
	// contains filtered or unexported fields
}

func (*CustomFields) Create

Create Custom Field Create a custom field.

**Scopes**: `custom_fields:write`

func (*CustomFields) Delete

Delete Custom Field Delete a custom field.

**Scopes**: `custom_fields:write`

func (*CustomFields) Get

Get Custom Field Get a custom field by ID.

**Scopes**: `custom_fields:read` `custom_fields:write`

func (*CustomFields) List

List Custom Fields List custom fields.

**Scopes**: `custom_fields:read` `custom_fields:write`

func (*CustomFields) Update

Update Custom Field Update a custom field.

**Scopes**: `custom_fields:write`

type CustomerPortal

type CustomerPortal struct {
	BenefitGrants *BenefitGrants
	Customers     *PolarCustomers
	Downloadables *Downloadables
	LicenseKeys   *PolarLicenseKeys
	Orders        *PolarOrders
	Organizations *PolarOrganizations
	Subscriptions *PolarSubscriptions
	// contains filtered or unexported fields
}

type CustomerSessions

type CustomerSessions struct {
	// contains filtered or unexported fields
}

func (*CustomerSessions) Create

Create Customer Session Create a customer session.

**Scopes**: `customer_sessions:write`

type Customers

type Customers struct {
	// contains filtered or unexported fields
}

func (*Customers) Create

Create Customer Create a customer.

**Scopes**: `customers:write`

func (*Customers) Delete

Delete Customer Delete a customer.

Immediately cancels any active subscriptions and revokes any active benefits.

**Scopes**: `customers:write`

func (*Customers) DeleteExternal added in v0.4.1

func (s *Customers) DeleteExternal(ctx context.Context, externalID string, opts ...operations.Option) (*operations.CustomersDeleteExternalResponse, error)

DeleteExternal - Delete Customer by External ID Delete a customer by external ID.

Immediately cancels any active subscriptions and revokes any active benefits.

**Scopes**: `customers:write`

func (*Customers) Get

Get Customer Get a customer by ID.

**Scopes**: `customers:read` `customers:write`

func (*Customers) GetExternal added in v0.4.1

func (s *Customers) GetExternal(ctx context.Context, externalID string, opts ...operations.Option) (*operations.CustomersGetExternalResponse, error)

GetExternal - Get Customer by External ID Get a customer by external ID.

**Scopes**: `customers:read` `customers:write`

func (*Customers) GetState added in v0.4.3

GetState - Get Customer State Get a customer state by ID.

The customer state includes information about the customer's active subscriptions and benefits.

It's the ideal endpoint to use when you need to get a full overview of a customer's status.

**Scopes**: `customers:read` `customers:write`

func (*Customers) GetStateExternal added in v0.4.3

func (s *Customers) GetStateExternal(ctx context.Context, externalID string, opts ...operations.Option) (*operations.CustomersGetStateExternalResponse, error)

GetStateExternal - Get Customer State by External ID Get a customer state by external ID.

The customer state includes information about the customer's active subscriptions and benefits.

It's the ideal endpoint to use when you need to get a full overview of a customer's status.

**Scopes**: `customers:read` `customers:write`

func (*Customers) List

List Customers List customers.

**Scopes**: `customers:read` `customers:write`

func (*Customers) Update

Update Customer Update a customer.

**Scopes**: `customers:write`

func (*Customers) UpdateExternal added in v0.4.1

func (s *Customers) UpdateExternal(ctx context.Context, externalID string, customerUpdate components.CustomerUpdate, opts ...operations.Option) (*operations.CustomersUpdateExternalResponse, error)

UpdateExternal - Update Customer by External ID Update a customer by external ID.

**Scopes**: `customers:write`

type Discounts

type Discounts struct {
	// contains filtered or unexported fields
}

func (*Discounts) Create

Create Discount Create a discount.

**Scopes**: `discounts:write`

func (*Discounts) Delete

Delete Discount Delete a discount.

**Scopes**: `discounts:write`

func (*Discounts) Get

Get Discount Get a discount by ID.

**Scopes**: `discounts:read` `discounts:write`

func (*Discounts) List

List Discounts List discounts.

**Scopes**: `discounts:read` `discounts:write`

func (*Discounts) Update

Update Discount Update a discount.

**Scopes**: `discounts:write`

type Downloadables

type Downloadables struct {
	// contains filtered or unexported fields
}

func (*Downloadables) Get

Get Downloadable

func (*Downloadables) List

List Downloadables **Scopes**: `customer_portal:read` `customer_portal:write`

type Events added in v0.1.8

type Events struct {
	// contains filtered or unexported fields
}

func (*Events) Get added in v0.1.8

Get Event Get an event by ID.

**Scopes**: `events:read` `events:write`

func (*Events) Ingest added in v0.1.8

Ingest Events Ingest batch of events.

**Scopes**: `events:write`

func (*Events) List added in v0.1.8

List Events List events.

**Scopes**: `events:read` `events:write`

type ExternalOrganizations

type ExternalOrganizations struct {
	// contains filtered or unexported fields
}

func (*ExternalOrganizations) List

List External Organizations List external organizations.

**Scopes**: `external_organizations:read`

type Files

type Files struct {
	// contains filtered or unexported fields
}

func (*Files) Create

Create File Create a file.

**Scopes**: `files:write`

func (*Files) Delete

Delete File Delete a file.

**Scopes**: `files:write`

func (*Files) List

func (s *Files) List(ctx context.Context, organizationID *string, ids []string, page *int64, limit *int64, opts ...operations.Option) (*operations.FilesListResponse, error)

List Files List files.

**Scopes**: `files:read` `files:write`

func (*Files) Update

Update File Update a file.

**Scopes**: `files:write`

func (*Files) Uploaded

func (s *Files) Uploaded(ctx context.Context, id string, fileUploadCompleted components.FileUploadCompleted, opts ...operations.Option) (*operations.FilesUploadedResponse, error)

Uploaded - Complete File Upload Complete a file upload.

**Scopes**: `files:write`

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for suplying the SDK with a custom HTTP client

type LicenseKeys

type LicenseKeys struct {
	// contains filtered or unexported fields
}

func (*LicenseKeys) Get

Get License Key Get a license key.

**Scopes**: `license_keys:read` `license_keys:write`

func (*LicenseKeys) GetActivation

func (s *LicenseKeys) GetActivation(ctx context.Context, id string, activationID string, opts ...operations.Option) (*operations.LicenseKeysGetActivationResponse, error)

GetActivation - Get Activation Get a license key activation.

**Scopes**: `license_keys:read` `license_keys:write`

func (*LicenseKeys) List

List License Keys Get license keys connected to the given organization & filters.

**Scopes**: `license_keys:read` `license_keys:write`

func (*LicenseKeys) Update

Update License Key Update a license key.

**Scopes**: `license_keys:write`

type Meters added in v0.1.8

type Meters struct {
	// contains filtered or unexported fields
}

func (*Meters) Create added in v0.1.8

Create Meter Create a meter.

**Scopes**: `meters:write`

func (*Meters) Events added in v0.1.8

func (s *Meters) Events(ctx context.Context, id string, page *int64, limit *int64, opts ...operations.Option) (*operations.MetersEventsResponse, error)

Events - Get Meter Events Get events matching the filter of a meter.

**Scopes**: `meters:read` `meters:write`

func (*Meters) Get added in v0.1.8

Get Meter Get a meter by ID.

**Scopes**: `meters:read` `meters:write`

func (*Meters) List added in v0.1.8

List Meters List meters.

**Scopes**: `meters:read` `meters:write`

func (*Meters) Quantities added in v0.1.8

Quantities - Get Meter Quantities Get quantities of a meter over a time period.

**Scopes**: `meters:read` `meters:write`

func (*Meters) Update added in v0.1.8

Update Meter Update a meter.

**Scopes**: `meters:write`

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func (*Metrics) Get

Get Metrics Get metrics about your orders and subscriptions.

Currency values are output in cents.

**Scopes**: `metrics:read`

func (*Metrics) Limits

Limits - Get Metrics Limits Get the interval limits for the metrics endpoint.

**Scopes**: `metrics:read`

type Oauth2

type Oauth2 struct {
	Clients *Clients
	// contains filtered or unexported fields
}

func (*Oauth2) Authorize

Authorize

func (*Oauth2) Introspect

Introspect Token Get information about an access token.

func (*Oauth2) Revoke

Revoke Token Revoke an access token or a refresh token.

func (*Oauth2) Token

Request Token Request an access token using a valid grant.

func (*Oauth2) Userinfo

Userinfo - Get User Info Get information about the authenticated user.

type Orders

type Orders struct {
	// contains filtered or unexported fields
}

func (*Orders) Get

Get Order Get an order by ID.

**Scopes**: `orders:read`

func (*Orders) Invoice

Invoice - Get Order Invoice Get an order's invoice data.

**Scopes**: `orders:read`

func (*Orders) List

List Orders List orders.

**Scopes**: `orders:read`

type Organizations

type Organizations struct {
	// contains filtered or unexported fields
}

func (*Organizations) Create

Create Organization Create an organization.

**Scopes**: `organizations:write`

func (*Organizations) Get

Get Organization Get an organization by ID.

**Scopes**: `organizations:read` `organizations:write`

func (*Organizations) List

List Organizations List organizations.

**Scopes**: `organizations:read` `organizations:write`

func (*Organizations) Update

Update Organization Update an organization.

**Scopes**: `organizations:write`

type Polar

type Polar struct {
	ExternalOrganizations *ExternalOrganizations
	Repositories          *Repositories
	Organizations         *Organizations
	Subscriptions         *Subscriptions
	Oauth2                *Oauth2
	Benefits              *Benefits
	Products              *Products
	Orders                *Orders
	Refunds               *Refunds
	Checkouts             *Checkouts
	Files                 *Files
	Metrics               *Metrics
	LicenseKeys           *LicenseKeys
	CheckoutLinks         *CheckoutLinks
	CustomFields          *CustomFields
	Discounts             *Discounts
	Customers             *Customers
	CustomerPortal        *CustomerPortal
	CustomerSessions      *CustomerSessions
	Events                *Events
	Meters                *Meters
	// contains filtered or unexported fields
}

Polar API: Polar HTTP and Webhooks API Read the docs at https://docs.polar.sh/api-reference

func New

func New(opts ...SDKOption) *Polar

New creates a new instance of the SDK with the provided options

type PolarCustomers

type PolarCustomers struct {
	// contains filtered or unexported fields
}

func (*PolarCustomers) AddPaymentMethod added in v0.4.0

AddPaymentMethod - Add Customer Payment Method Add a payment method to the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarCustomers) DeletePaymentMethod added in v0.4.0

DeletePaymentMethod - Delete Customer Payment Method Delete a payment method from the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarCustomers) Get

Get Customer Get authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarCustomers) GetPaymentMethods added in v0.4.0

GetPaymentMethods - Get Customer Payment Methods Get saved payment methods of the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarCustomers) Update added in v0.4.0

Update Customer Update authenticated customer.

**Scopes**: `customer_portal:write`

type PolarLicenseKeys

type PolarLicenseKeys struct {
	// contains filtered or unexported fields
}

func (*PolarLicenseKeys) Activate

Activate License Key Activate a license key instance.

func (*PolarLicenseKeys) Deactivate

Deactivate License Key Deactivate a license key instance.

func (*PolarLicenseKeys) Get

Get License Key Get a license key.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarLicenseKeys) List

List License Keys **Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarLicenseKeys) Validate

Validate License Key Validate a license key.

type PolarOrders

type PolarOrders struct {
	// contains filtered or unexported fields
}

func (*PolarOrders) Get

Get Order Get an order by ID for the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarOrders) Invoice

Invoice - Get Order Invoice Get an order's invoice data.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarOrders) List

List Orders List orders of the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

type PolarOrganizations

type PolarOrganizations struct {
	// contains filtered or unexported fields
}

func (*PolarOrganizations) Get

Get Organization Get a customer portal's organization by slug.

type PolarSubscriptions

type PolarSubscriptions struct {
	// contains filtered or unexported fields
}

func (*PolarSubscriptions) Cancel

Cancel Subscription Cancel a subscription of the authenticated customer.

**Scopes**: `customer_portal:write`

func (*PolarSubscriptions) Get

Get Subscription Get a subscription for the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarSubscriptions) List

List Subscriptions List subscriptions of the authenticated customer.

**Scopes**: `customer_portal:read` `customer_portal:write`

func (*PolarSubscriptions) Update

Update Subscription Update a subscription of the authenticated customer.

**Scopes**: `customer_portal:write`

type Products

type Products struct {
	// contains filtered or unexported fields
}

func (*Products) Create

Create Product Create a product.

**Scopes**: `products:write`

func (*Products) Get

Get Product Get a product by ID.

**Scopes**: `products:read` `products:write`

func (*Products) List

List Products List products.

**Scopes**: `products:read` `products:write`

func (*Products) Update

Update Product Update a product.

**Scopes**: `products:write`

func (*Products) UpdateBenefits

func (s *Products) UpdateBenefits(ctx context.Context, id string, productBenefitsUpdate components.ProductBenefitsUpdate, opts ...operations.Option) (*operations.ProductsUpdateBenefitsResponse, error)

UpdateBenefits - Update Product Benefits Update benefits granted by a product.

**Scopes**: `products:write`

type Refunds added in v0.1.5

type Refunds struct {
	// contains filtered or unexported fields
}

func (*Refunds) Create added in v0.1.5

Create Refund Create a refund.

**Scopes**: `refunds:write`

func (*Refunds) List added in v0.1.5

List Refunds List products.

**Scopes**: `refunds:read` `refunds:write`

type Repositories

type Repositories struct {
	// contains filtered or unexported fields
}

func (*Repositories) Get

Get Repository Get a repository by ID.

**Scopes**: `repositories:read` `repositories:write`

func (*Repositories) List

List Repositories List repositories.

**Scopes**: `repositories:read` `repositories:write`

func (*Repositories) Update

Update Repository Update a repository.

**Scopes**: `repositories:write`

type SDKOption

type SDKOption func(*Polar)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithRetryConfig

func WithRetryConfig(retryConfig retry.Config) SDKOption

func WithSecurity

func WithSecurity(accessToken string) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithSecuritySource

func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

func WithServer

func WithServer(server string) SDKOption

WithServer allows the overriding of the default server by name

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

func WithTimeout

func WithTimeout(timeout time.Duration) SDKOption

WithTimeout Optional request timeout applied to each operation

type Subscriptions

type Subscriptions struct {
	// contains filtered or unexported fields
}

func (*Subscriptions) Export

Export Subscriptions Export subscriptions as a CSV file.

**Scopes**: `subscriptions:read` `subscriptions:write`

func (*Subscriptions) Get added in v0.1.7

Get Subscription Get a subscription by ID.

**Scopes**: `subscriptions:write`

func (*Subscriptions) List

List Subscriptions List subscriptions.

**Scopes**: `subscriptions:read` `subscriptions:write`

func (*Subscriptions) Revoke added in v0.1.1

Revoke Subscription Revoke a subscription, i.e cancel immediately.

**Scopes**: `subscriptions:write`

func (*Subscriptions) Update added in v0.1.1

Update Subscription Update a subscription.

**Scopes**: `subscriptions:write`

Directories

Path Synopsis
internal
models

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL