~samwhited/paddle

b2c09c13f624b247ee94468130083d6fb2b0ddba — Sam Whited 2 years ago c8abffc
paddle: use consts from internal
2 files changed, 6 insertions(+), 7 deletions(-)

M license.go
M time.go
M license.go => license.go +3 -1
@@ 5,6 5,8 @@ import (
	"net/url"
	"strconv"
	"time"

	"soquee.net/paddle/internal"
)

const createLicenseURL = "/product/generate_license"


@@ 14,7 16,7 @@ func (c *Client) CreateLicense(productID int64, allowedUses int, expiresAt time.
	v := url.Values{}
	v.Add("product_id", strconv.FormatInt(productID, 10))
	v.Add("allowed_uses", strconv.Itoa(allowedUses))
	v.Add("expires_at", expiresAt.Format(dateFmt))
	v.Add("expires_at", expiresAt.Format(internal.DateFmt))
	msg, err := c.Do(createLicenseURL, v)
	if err != nil {
		return nil, err

M time.go => time.go +3 -6
@@ 3,11 3,8 @@ package paddle
import (
	"encoding/json"
	"time"
)

const (
	dateFmt     = "2006-01-02"
	dateTimeFmt = "2006-01-02 15:04:05"
	"soquee.net/paddle/internal"
)

// Time is a custom time type that supports marshaling and unmarshaling Paddle's


@@ 18,9 15,9 @@ var _ json.Unmarshaler = (*Time)(nil)

// UnmarshalJSON satisfies the json.Unmarshaler interface for Time.
func (t *Time) UnmarshalJSON(b []byte) error {
	newTime, err := time.Parse(dateFmt, string(b))
	newTime, err := time.Parse(internal.DateFmt, string(b))
	if err != nil {
		newTime, err = time.Parse(dateTimeFmt, string(b))
		newTime, err = time.Parse(internal.DateTimeFmt, string(b))
		if err != nil {
			return err
		}