keymint

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivateKeyParams

type ActivateKeyParams struct {
	// ProductID is the unique identifier of the product.
	ProductID string `json:"productId"`
	// LicenseKey is the license key to activate.
	LicenseKey string `json:"licenseKey"`
	// HostID is an optional unique identifier for the device.
	HostID *string `json:"hostId,omitempty"`
	// DeviceTag is an optional user-friendly name for the device.
	DeviceTag *string `json:"deviceTag,omitempty"`
}

ActivateKeyParams represents parameters for the activateKey API endpoint.

type ActivateKeyResponse

type ActivateKeyResponse struct {
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
	// Message is the activation status message (e.g., "License valid").
	Message string `json:"message"`
	// LicenseeName is the optional name of the licensee.
	LicenseeName *string `json:"licenseeName,omitempty"`
	// LicenseeEmail is the optional email of the licensee.
	LicenseeEmail *string `json:"licenseeEmail,omitempty"`
}

ActivateKeyResponse represents response structure for a successful activateKey API call.

type ApiError

type ApiError struct {
	// Message is a descriptive error message.
	Message string `json:"message"`
	// Code is the API specific error code.
	Code int `json:"code"`
	// Status is the optional HTTP status code.
	Status *int `json:"status,omitempty"`
}

ApiError represents standard error response structure from the KeyMint API.

func (*ApiError) Error

func (e *ApiError) Error() string

Error implements the error interface for ApiError.

type BlockKeyParams

type BlockKeyParams struct {
	// ProductID is the unique identifier of the product.
	ProductID string `json:"productId"`
	// LicenseKey is the license key to block.
	LicenseKey string `json:"licenseKey"`
}

BlockKeyParams represents parameters for the blockKey API endpoint.

type BlockKeyResponse

type BlockKeyResponse struct {
	// Message is the confirmation message (e.g., "Key blocked").
	Message string `json:"message"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

BlockKeyResponse represents response structure for a successful blockKey API call.

type Client

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

Client is the main entry point for the KeyMint API client Client provides methods to interact with the KeyMint API for license and customer management.

func New

func New(accessToken string, baseURL string) (*Client, error)

New creates a new KeyMint API client instance. accessToken: Your KeyMint API access token (required). baseURL: Optional API base URL (defaults to https://api.keymint.dev). Returns a new Client instance or an error if accessToken is missing.

func (*Client) ActivateKey

func (c *Client) ActivateKey(params ActivateKeyParams) (*ActivateKeyResponse, error)

ActivateKey activates a license key for a specific device. params: Parameters for activating the key. Returns the activation status or an error.

func (*Client) BlockKey

func (c *Client) BlockKey(params BlockKeyParams) (*BlockKeyResponse, error)

BlockKey blocks a specific license key. params: Parameters for blocking the key. Returns the block confirmation or an error.

func (*Client) CreateCustomer

func (c *Client) CreateCustomer(params CreateCustomerParams) (*CreateCustomerResponse, error)

CreateCustomer creates a new customer. params: Parameters for creating the customer. Returns the created customer information or an error.

func (*Client) CreateKey

func (c *Client) CreateKey(params CreateKeyParams) (*CreateKeyResponse, error)

CreateKey creates a new license key. params: Parameters for creating the key. Returns the created key information or an error.

func (*Client) DeactivateKey

func (c *Client) DeactivateKey(params DeactivateKeyParams) (*DeactivateKeyResponse, error)

DeactivateKey deactivates a device from a license key. params: Parameters for deactivating the key. Returns the deactivation confirmation or an error.

func (*Client) DeleteCustomer

func (c *Client) DeleteCustomer(params DeleteCustomerParams) (*DeleteCustomerResponse, error)

DeleteCustomer deletes a customer and all associated license keys permanently. params: Parameters containing the customer ID. Returns the deletion confirmation or an error.

func (*Client) GetAllCustomers

func (c *Client) GetAllCustomers() (*GetAllCustomersResponse, error)

GetAllCustomers retrieves all customers. Returns a list of all customers or an error.

func (*Client) GetCustomerById

func (c *Client) GetCustomerById(params GetCustomerByIdParams) (*GetCustomerByIdResponse, error)

GetCustomerById retrieves detailed information about a specific customer by ID. params: Parameters containing the customer ID. Returns the customer information or an error.

func (*Client) GetCustomerWithKeys

func (c *Client) GetCustomerWithKeys(params GetCustomerWithKeysParams) (*GetCustomerWithKeysResponse, error)

GetCustomerWithKeys retrieves a customer along with their associated license keys. params: Parameters containing the customer ID. Returns the customer information with associated license keys or an error.

func (*Client) GetKey

func (c *Client) GetKey(params GetKeyParams) (*GetKeyResponse, error)

GetKey retrieves detailed information about a specific license key. params: Parameters for fetching the key details. Returns the license key details or an error.

func (*Client) ToggleCustomerStatus

func (c *Client) ToggleCustomerStatus(params ToggleCustomerStatusParams) (*ToggleCustomerStatusResponse, error)

ToggleCustomerStatus toggles the status of a customer (active/inactive). params: Parameters containing the customer ID. Returns the status toggle confirmation or an error.

func (*Client) UnblockKey

func (c *Client) UnblockKey(params UnblockKeyParams) (*UnblockKeyResponse, error)

UnblockKey unblocks a previously blocked license key. params: Parameters for unblocking the key. Returns the unblock confirmation or an error.

func (*Client) UpdateCustomer

func (c *Client) UpdateCustomer(params UpdateCustomerParams) (*UpdateCustomerResponse, error)

UpdateCustomer updates an existing customer. params: Parameters for updating the customer. Returns the update confirmation or an error.

type CreateCustomerParams

type CreateCustomerParams struct {
	// Name is the required customer name.
	Name string `json:"name"`
	// Email is the required customer email.
	Email string `json:"email"`
}

CreateCustomerParams represents parameters for the createCustomer API endpoint.

type CreateCustomerResponse

type CreateCustomerResponse struct {
	// ID is the customer ID.
	ID string `json:"id"`
	// Action is the action performed (e.g., "createCustomer").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Message is the success message.
	Message string `json:"message"`
	// Data contains the created customer details.
	Data struct {
		// ID is the customer ID.
		ID string `json:"id"`
		// Name is the customer name.
		Name string `json:"name"`
		// Email is the customer email.
		Email string `json:"email"`
	} `json:"data"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

CreateCustomerResponse represents response structure for a successful createCustomer API call.

type CreateKeyParams

type CreateKeyParams struct {
	// ProductID is the unique identifier of the product.
	ProductID string `json:"productId"`
	// MaxActivations is the optional maximum number of times the key can be activated.
	MaxActivations *string `json:"maxActivations,omitempty"`
	// ExpiryDate is the optional expiration date of the key in ISO 8601 format.
	ExpiryDate *string `json:"expiryDate,omitempty"`
	// CustomerID is the optional ID of an existing customer to associate with the key.
	CustomerID *string `json:"customerId,omitempty"`
	// NewCustomer is an optional object to create and associate a new customer with the key.
	NewCustomer *NewCustomer `json:"newCustomer,omitempty"`
}

CreateKeyParams represents parameters for the createKey API endpoint.

type CreateKeyResponse

type CreateKeyResponse struct {
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
	// Key is the generated license key.
	Key string `json:"key"`
}

CreateKeyResponse represents response structure for a successful createKey API call.

type Customer

type Customer struct {
	// ID is the customer ID.
	ID string `json:"id"`
	// Name is the customer name.
	Name string `json:"name"`
	// Email is the customer email.
	Email string `json:"email"`
	// Active indicates if the customer is active.
	Active bool `json:"active"`
	// CreatedAt is the timestamp when the customer was created.
	CreatedAt string `json:"createdAt"`
	// UpdatedAt is the timestamp when the customer was last updated.
	UpdatedAt string `json:"updatedAt"`
	// CreatedBy is the identifier of the user who created the customer.
	CreatedBy string `json:"createdBy"`
}

Customer represents customer information in the getAllCustomers response.

type CustomerDetails

type CustomerDetails struct {
	// ID is the customer ID.
	ID string `json:"id"`
	// Name is the optional updated customer name.
	Name *string `json:"name,omitempty"`
	// Email is the optional updated customer email.
	Email *string `json:"email,omitempty"`
	// Active indicates if the customer is active.
	Active bool `json:"active"`
}

CustomerDetails represents customer details included in the GetKeyResponse.

type CustomerLicenseKey

type CustomerLicenseKey struct {
	// ID is the license key ID.
	ID string `json:"id"`
	// Key is the license key.
	Key string `json:"key"`
	// ProductID is the product ID associated with the license key.
	ProductID string `json:"productId"`
	// MaxActivations is the maximum number of activations for the license key.
	MaxActivations int `json:"maxActivations"`
	// Activations is the number of times the license key has been activated.
	Activations int `json:"activations"`
	// Activated indicates if the license key is activated.
	Activated bool `json:"activated"`
	// ExpirationDate is the expiration date of the license key.
	ExpirationDate *string `json:"expirationDate,omitempty"`
}

CustomerLicenseKey represents license key information in customer with keys response.

type DeactivateKeyParams

type DeactivateKeyParams struct {
	// ProductID is the unique identifier of the product.
	ProductID string `json:"productId"`
	// LicenseKey is the license key to deactivate.
	LicenseKey string `json:"licenseKey"`
	// HostID is an optional unique identifier of the device to deactivate. If omitted, all devices are deactivated.
	HostID *string `json:"hostId,omitempty"`
}

DeactivateKeyParams represents parameters for the deactivateKey API endpoint.

type DeactivateKeyResponse

type DeactivateKeyResponse struct {
	// Message is the confirmation message (e.g., "Device deactivated").
	Message string `json:"message"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

DeactivateKeyResponse represents response structure for a successful deactivateKey API call.

type DeleteCustomerParams

type DeleteCustomerParams struct {
	// CustomerID is the required customer ID.
	CustomerID string `json:"customerId"`
}

DeleteCustomerParams represents parameters for the deleteCustomer API endpoint.

type DeleteCustomerResponse

type DeleteCustomerResponse struct {
	// Action is the action performed (e.g., "deleteCustomer").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Message is the status message (e.g., "Customer deleted").
	Message string `json:"message"`
	// Code is the API response code.
	Code int `json:"code"`
}

DeleteCustomerResponse represents response structure for a successful deleteCustomer API call.

type DeviceDetails

type DeviceDetails struct {
	// HostID is the updated field name.
	HostID string `json:"hostId"`
	// DeviceTag is the updated field name.
	DeviceTag *string `json:"deviceTag,omitempty"`
	// IPAddress is the updated field name.
	IPAddress *string `json:"ipAddress,omitempty"`
	// ActivationTime is the updated field name.
	ActivationTime string `json:"activationTime"`
}

DeviceDetails represents device details included in the GetKeyResponse.

type GetAllCustomersResponse

type GetAllCustomersResponse struct {
	// Action is the action performed (e.g., "getCustomers").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Data is the array of customer objects.
	Data []Customer `json:"data"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

GetAllCustomersResponse represents response structure for a successful getAllCustomers API call.

type GetCustomerByIdParams

type GetCustomerByIdParams struct {
	// CustomerID is the required customer ID.
	CustomerID string `json:"customerId"`
}

GetCustomerByIdParams represents parameters for the getCustomerById API endpoint.

type GetCustomerByIdResponse

type GetCustomerByIdResponse struct {
	// Action is the action performed (e.g., "getCustomerById").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Data is the array containing the customer object.
	Data []Customer `json:"data"`
	// Code is the API response code.
	Code int `json:"code"`
}

GetCustomerByIdResponse represents response structure for a successful getCustomerById API call.

type GetCustomerWithKeysParams

type GetCustomerWithKeysParams struct {
	// CustomerID is the required customer ID.
	CustomerID string `json:"customerId"`
}

GetCustomerWithKeysParams represents parameters for the getCustomerWithKeys API endpoint.

type GetCustomerWithKeysResponse

type GetCustomerWithKeysResponse struct {
	// Action is the action performed (e.g., "getCustomerWithKeys").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Data contains the customer and license keys information.
	Data struct {
		// Customer contains the customer details.
		Customer Customer `json:"customer"`
		// LicenseKeys contains the array of license keys associated with the customer.
		LicenseKeys []CustomerLicenseKey `json:"licenseKeys"`
	} `json:"data"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

GetCustomerWithKeysResponse represents response structure for a successful getCustomerWithKeys API call.

type GetKeyParams

type GetKeyParams struct {
	// ProductID is the unique identifier of the product.
	ProductID string `json:"productId"`
	// LicenseKey is the license key to retrieve.
	LicenseKey string `json:"licenseKey"`
}

GetKeyParams represents parameters for the getKey API endpoint.

type GetKeyResponse

type GetKeyResponse struct {
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
	// Data contains the license and optional customer details.
	Data struct {
		// License contains the license details.
		License LicenseDetails `json:"license"`
		// Customer contains the optional customer details.
		Customer *CustomerDetails `json:"customer,omitempty"`
	} `json:"data"`
}

GetKeyResponse represents response structure for a successful getKey API call.

type LicenseDetails

type LicenseDetails struct {
	// ID is the license ID.
	ID string `json:"id"`
	// Key is the license key.
	Key string `json:"key"`
	// ProductID is the updated field name.
	ProductID string `json:"productId"`
	// MaxActivations is the updated field name.
	MaxActivations int `json:"maxActivations"`
	// Activations is the number of times the license has been activated.
	Activations int `json:"activations"`
	// Devices is the list of devices associated with the license.
	Devices []DeviceDetails `json:"devices"`
	// Activated indicates if the license is activated.
	Activated bool `json:"activated"`
	// ExpirationDate is the updated field name.
	ExpirationDate *string `json:"expirationDate,omitempty"`
}

LicenseDetails represents license details included in the GetKeyResponse.

type NewCustomer

type NewCustomer struct {
	// Name is the name of the new customer.
	Name string `json:"name"`
	// Email is the optional email of the new customer.
	Email *string `json:"email,omitempty"`
}

NewCustomer represents the structure for creating a new customer when creating a license key.

type ToggleCustomerStatusParams

type ToggleCustomerStatusParams struct {
	// CustomerID is the required customer ID.
	CustomerID string `json:"customerId"`
}

ToggleCustomerStatusParams represents parameters for the toggleCustomerStatus API endpoint.

type ToggleCustomerStatusResponse

type ToggleCustomerStatusResponse struct {
	// Action is the action performed (e.g., "toggleActive").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Message is the status message (e.g., "Customer disabled").
	Message string `json:"message"`
	// Code is the API response code.
	Code int `json:"code"`
}

ToggleCustomerStatusResponse represents response structure for a successful toggleCustomerStatus API call.

type UnblockKeyParams

type UnblockKeyParams struct {
	// ProductID is the unique identifier of the product.
	ProductID string `json:"productId"`
	// LicenseKey is the license key to unblock.
	LicenseKey string `json:"licenseKey"`
}

UnblockKeyParams represents parameters for the unblockKey API endpoint.

type UnblockKeyResponse

type UnblockKeyResponse struct {
	// Message is the confirmation message (e.g., "Key unblocked").
	Message string `json:"message"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

UnblockKeyResponse represents response structure for a successful unblockKey API call.

type UpdateCustomerParams

type UpdateCustomerParams struct {
	// CustomerID is the required customer ID.
	CustomerID string `json:"customerId"`
	// Name is the optional updated customer name.
	Name *string `json:"name,omitempty"`
	// Email is the optional updated customer email.
	Email *string `json:"email,omitempty"`
	// Active is the optional customer active status.
	Active *bool `json:"active,omitempty"`
}

UpdateCustomerParams represents parameters for the updateCustomer API endpoint.

type UpdateCustomerResponse

type UpdateCustomerResponse struct {
	// Action is the action performed (e.g., "updateCustomer").
	Action string `json:"action"`
	// Status indicates the success status.
	Status bool `json:"status"`
	// Message is the status message.
	Message string `json:"message"`
	// Data contains the updated customer details.
	Data Customer `json:"data"`
	// Code is the API response code (e.g., 0 for success).
	Code int `json:"code"`
}

UpdateCustomerResponse represents response structure for a successful updateCustomer API call.

Jump to

Keyboard shortcuts

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