[MM-29157] Cloud invoices logic (#16056)
* Cloud invoices logic This commit includes all the code needed to get and print invoices from CWS
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8f895908fc
Коммит
b68f171162
@@ -5702,6 +5702,19 @@ func (c *Client4) GetSubscription() (*Subscription, *Response) {
|
||||
return subscription, BuildResponse(r)
|
||||
}
|
||||
|
||||
func (c *Client4) GetInvoicesForSubscription() ([]*Invoice, *Response) {
|
||||
r, appErr := c.DoApiGet(c.GetCloudRoute()+"/subscription/invoices", "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
var invoices []*Invoice
|
||||
json.NewDecoder(r.Body).Decode(&invoices)
|
||||
|
||||
return invoices, BuildResponse(r)
|
||||
}
|
||||
|
||||
func (c *Client4) UpdateCloudCustomer(customerInfo *CloudCustomerInfo) (*CloudCustomer, *Response) {
|
||||
customerBytes, _ := json.Marshal(customerInfo)
|
||||
|
||||
|
||||
@@ -84,3 +84,29 @@ type Subscription struct {
|
||||
DNS string `json:"dns"`
|
||||
IsPaidTier string `json:"is_paid_tier"`
|
||||
}
|
||||
|
||||
// Invoice model represents a cloud invoice
|
||||
type Invoice struct {
|
||||
ID string `json:"id"`
|
||||
Number string `json:"number"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
Total int64 `json:"total"`
|
||||
Tax int64 `json:"tax"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
PeriodStart int64 `json:"period_start"`
|
||||
PeriodEnd int64 `json:"period_end"`
|
||||
SubscriptionID string `json:"subscription_id"`
|
||||
Items []*InvoiceLineItem `json:"line_items"`
|
||||
}
|
||||
|
||||
// InvoiceLineItem model represents a cloud invoice lineitem tied to an invoice.
|
||||
type InvoiceLineItem struct {
|
||||
PriceID string `json:"price_id"`
|
||||
Total int64 `json:"total"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
PricePerUnit int64 `json:"price_per_unit"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user