~samwhited/paddle

666247b6068340384e52793a1ed67e6712291148 — Sam Whited 2 years ago c4f67c3
paddle, license: move license code to new package
1 files changed, 11 insertions(+), 4 deletions(-)

R license.go => license/license.go
R license.go => license/license.go +11 -4
@@ 1,4 1,5 @@
package paddle
// Package license provides the /product/*_license APIs.
package license

import (
	"encoding/json"


@@ 6,13 7,19 @@ import (
	"strconv"
	"time"

	"soquee.net/paddle"
	"soquee.net/paddle/internal"
)

const createLicenseURL = "/product/generate_license"

// Client performs operations related to licenses.
type Client struct {
	*paddle.Client
}

// CreateLicense generates a new license code for a given SDK product.
func (c *Client) CreateLicense(productID int64, allowedUses int, expiresAt time.Time) (*License, error) {
func (c Client) Create(productID int64, allowedUses int, expiresAt time.Time) (*License, error) {
	v := url.Values{}
	v.Add("product_id", strconv.FormatInt(productID, 10))
	v.Add("allowed_uses", strconv.Itoa(allowedUses))


@@ 31,6 38,6 @@ func (c *Client) CreateLicense(productID int64, allowedUses int, expiresAt time.

// License represents a license for an SDK product.
type License struct {
	Code      string `json:"license_code"`
	ExpiresAt Time   `json:"expires_at"`
	Code      string      `json:"license_code"`
	ExpiresAt paddle.Time `json:"expires_at"`
}