Mm 49495 Show past invoices for prior self-hosted purchases (#22397)

* future proof license queries
* add client method for fetching self-hosted invoices
Этот коммит содержится в:
Nathaniel Allred
2023-02-28 15:39:23 -06:00
коммит произвёл GitHub
родитель 552ca6fb0b
Коммит 7a8c1f587b
2 изменённых файлов: 27 добавлений и 3 удалений

Просмотреть файл

@@ -8677,6 +8677,30 @@ func (c *Client4) SelfHostedSignupConfirm(form *SelfHostedConfirmPaymentMethodRe
return BuildResponse(r), &response, nil
}
func (c *Client4) GetSelfHostedInvoices() (*Response, []*Invoice, error) {
r, err := c.DoAPIGet(c.hostedCustomerRoute()+"/invoices", "")
if err != nil {
return BuildResponse(r), nil, err
}
data, err := io.ReadAll(r.Body)
if err != nil {
return BuildResponse(r), nil, err
}
defer closeBody(r)
invoices := []*Invoice{}
err = json.Unmarshal(data, &invoices)
if err != nil {
return BuildResponse(r), nil, err
}
defer closeBody(r)
return BuildResponse(r), invoices, nil
}
func (c *Client4) GetPostInfo(postId string) (*PostInfo, *Response, error) {
r, err := c.DoAPIGet(c.postRoute(postId)+"/info", "")
if err != nil {

Просмотреть файл

@@ -33,7 +33,7 @@ func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseReco
return nil, err
}
query := ls.getQueryBuilder().
Select("*").
Select("Id, CreateAt, Bytes").
From("Licenses").
Where(sq.Eq{"Id": license.Id})
queryString, args, err := query.ToSql()
@@ -64,7 +64,7 @@ func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseReco
// http.StatusNotFound in the StatusCode field.
func (ls SqlLicenseStore) Get(id string) (*model.LicenseRecord, error) {
query := ls.getQueryBuilder().
Select("*").
Select("Id, CreateAt, Bytes").
From("Licenses").
Where(sq.Eq{"Id": id})
@@ -82,7 +82,7 @@ func (ls SqlLicenseStore) Get(id string) (*model.LicenseRecord, error) {
func (ls SqlLicenseStore) GetAll() ([]*model.LicenseRecord, error) {
query := ls.getQueryBuilder().
Select("*").
Select("Id, CreateAt, Bytes").
From("Licenses")
queryString, _, err := query.ToSql()