whop-client

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT

README

Installation

go get github.com/ssbanjo/whop-client

Introduction

With this client you can interact with the Whop API without needing to prepare the requests yourself. It provides a clean and easy way to build client calls.

Example

package main

import (
	"fmt"

	"github.com/ssbanjo/whop-client/client"
)

func main() {

	// Initialize the Whop client.

	apiKey := "YOUR_API_KEY"

	whopClient := client.NewClient(apiKey)

	// Validate a license key.

	licenseId := "LICENSE_ID"

	metadata := map[string]interface{}{
		"metadata": map[string]string{
			"hwid": "HARDWARE_ID",
		},
	}

	membership, err := whopClient.ValidateLicenseKey(
		licenseId,
		client.ValidateLicenseKeyParams{
			Metadata: metadata,
		},
	)

	if err != nil {
		panic(fmt.Errorf("Invalid or already in use license key: %v", err))
	}

	fmt.Printf("Member %s has a valid license key!", membership.Discord.Username)


	// List your customers.

	customers, err := whopClient.ListCustomers(
		client.ListCustomersParams{
			PageNumber: 1,
			PageSize:   10,
		},
	)

	if err != nil {
		panic(fmt.Errorf("Failed to get customers: %v", err))
	}

	for _, customer := range customers.Data {

		fmt.Printf("Found customer: %s\n", customer.Username)
	}

}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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