Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bill support. #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions services/bill/bill.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package bill

import (
"fmt"

"github.com/baidubce/bce-sdk-go/bce"
"github.com/baidubce/bce-sdk-go/http"
)

func (c *Client) GetResourceMonthBill(args *GetResourceMonthBillArgs) (list *GetResourceMonthBillResult, err error) {
err = bce.NewRequestBuilder(c).
WithMethod(http.GET).
WithBody(args).
WithURL(bce.URI_PREFIX+"v1/bill/resource/month").
WithQueryParamFilter("month", args.Month).
WithQueryParamFilter("productType", args.ProductType).
WithQueryParamFilter("serviceType", args.ServiceType).
WithQueryParamFilter("queryAccountId", args.QueryAccountId).
WithQueryParamFilter("pageNo", fmt.Sprintf("%d", args.PageNo)).
WithQueryParamFilter("pageSize", fmt.Sprintf("%d", args.PageSize)).
WithResult(&list).
Do()
return
}
27 changes: 27 additions & 0 deletions services/bill/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package bill

import (
"github.com/baidubce/bce-sdk-go/bce"
)

const (
// DefaultEndpoint -- xx
DefaultEndpoint = "billing.baidubce.com"
)

// Client used for client
type Client struct {
*bce.BceClient
}

// NewClient return a client
func NewClient(ak, sk, endPoint string) (ret *Client, err error) {
if len(endPoint) == 0 {
endPoint = DefaultEndpoint
}
client, err := bce.NewBceClientWithAkSk(ak, sk, endPoint)
if err != nil {
return nil, err
}
return &Client{client}, nil
}
63 changes: 63 additions & 0 deletions services/bill/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package bill

import "math/big"

type GetResourceMonthBillArgs struct {
Month string `json:"month"`
ProductType string `json:"ProductType"`
ServiceType string `json:"serviceType"`
QueryAccountId string `json:"queryAccountId"`
PageNo int `json:"pageNo"`
PageSize int `json:"pageSize"`
}

type GetResourceMonthBillResult struct {
BillMonth string
AccountId string
LoginName string
SubAccountId string
SubLoginName string
OuName string
PageNo int
PageSize int
TotalCount int
Bills []ResourceMonthInstanceBill
}
type ResourceMonthInstanceBill struct {
Vendor string
AccountId string
ServiceType string
ServiceTypeName string
ProductType string
Region string
InstanceId string
OrderId string
OrderType string
OrderTypeDesc string
OrderPurchaseTime string
StartTime string
EndTime string
ConfigurationCH string
Tag string
Duration string
ChargeItem string
ChargeItemDesc string
Amount string
AmountUnit string
UnitPrice string
PricingUnit string
DiscountUnit string
Tex big.Float
OriginPrice big.Float
FinancePrice big.Float
Cash big.Float
Rebate big.Float
CreditCost big.Float
CreditRefund big.Float
Debt big.Float
NoPaidPrice big.Float
CouponPrice big.Float
DiscountCouponPrice big.Float
DiscountPrice big.Float
SysGold big.Float
}