gumroad

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 11 Imported by: 0

README

go-gumroad

Build Status Coverage Status

Easily check licenses against Gumroad's API.

Usage

package main

import "github.com/caarlos0/go-gumroad"

func check(key string) error {
	prod, err := gumroad.NewProduct("my-product-permalink")
	if err != nil {
		return err
	}
	return prod.Verify(key)
}

Documentation

Overview

Package gumroad provides license checking using gumroad.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GumroadResponse

type GumroadResponse struct {
	Success  bool     `json:"success"`
	Uses     int      `json:"uses"`
	Purchase Purchase `json:"purchase"`
	Message  string   `json:"message"`
}

GumroadResponse is an API response.

type Product added in v0.2.0

type Product struct {
	API     string
	Product string
	Client  *http.Client
}

Product represents a product in Gumroad on which license keys can be verified.

func NewProduct added in v0.2.0

func NewProduct(product string) (Product, error)

NewProduct returns a new GumroadProduct with reasonable defaults.

func (Product) Verify added in v0.2.0

func (gp Product) Verify(key string) error

Verify returns the result of VerifyWithContext with the background context.

func (Product) VerifyWithContext added in v0.2.0

func (gp Product) VerifyWithContext(ctx context.Context, key string) error

CheckWithContext verifies a license key against a product in Gumroad.

type Purchase

type Purchase struct {
	Email                   string    `json:"email"`
	Refunded                bool      `json:"refunded"`
	SaleTimestamp           time.Time `json:"sale_timestamp"`
	SubscriptionCancelledAt time.Time `json:"subscription_cancelled_at"`
	SubscriptionFailedAt    time.Time `json:"subscription_failed_at"`
	SubscriptionID          string    `json:"subscription_id"`
}

Purchase is Purchase from the GumRoad API

Jump to

Keyboard shortcuts

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