Skip to content

Commit

Permalink
merge P&R from @hantmac
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeiminds authored Nov 16, 2018
2 parents 628514e + 44c44ec commit d223288
Show file tree
Hide file tree
Showing 10 changed files with 487 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ core.*
debug
debug.test
.vscode
*.*~
.*

# Executable
bin/
Expand All @@ -17,4 +19,4 @@ bin/
coverage.out

# Test Data
# autotest/set_*
# autotest/set_*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func loadConfig()(*sdk.Config, *auth.Credential){

func main(){
cfg, credentail := loadConfig()
uhostClient := uhost.Newclient(cfg, credential)
uhostClient := uhost.NewClient(cfg, credential)
}
```

Expand Down
19 changes: 19 additions & 0 deletions services/ubill/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ubill

import (
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
)

// UBillClient is the client of UBill
type UBillClient struct {
client *ucloud.Client
}

// NewClient will return a instance of UBillClient
func NewClient(config *ucloud.Config, credential *auth.Credential) *UBillClient {
client := ucloud.NewClient(config, credential)
return &UBillClient{
client: client,
}
}
81 changes: 81 additions & 0 deletions services/ubill/describe_order_detail_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ubill

import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

type DescribeOrderDetailInfoRequest struct {
request.CommonBase

//开始时间,UNIX time format
BeginTime *int `required:"true"`

//结束时间,时间跨度不超过3个月
EndTime *int `required:"true"`

Regions []string `required:"true"`

//产品类型,默认全部的产品类型
ResourceTypes []string `required:"false"`

//订单类型,默认全部订单类型
OrderTypes []string `required:"false"`

//付费类型,默认全部的计费方式
ChargeTypes []string

//订单状态,默认选中全部的可选参数
OrderStates []string `required:"false"`

//是否开过发票,默认选中全部的可选参数
Invoiceds []string `required:"false"`

//返回数据长度,默认25
Limit *int `required:"false"`

//数据偏移量,默认0
Offset *int `required:"false"`

//资源ID
ResourceIds []string `required:"false"`

//交易单号,该字段存在时,可以不传BeginTime和EndTime
TradeNos []string `required:"false"`

//true表示查询全部,默认全部,其他选项按照项目自查询
QueryAll *string `required:"false"`
}

// DescribeOrderDetailInfoResponse is response schema for DescribeOrderDetailInfo action
type DescribeOrderDetailInfoResponse struct {
response.CommonBase

//json格式的订单信息
OrderInfos []OrderInfo
}

// NewDescribeOrderDetailInfoRequest will create request of DescribeOrderDetailInfo action.
func (c *UBillClient) NewDescribeOrderDetailInfoRequest() *DescribeOrderDetailInfoRequest {
req := &DescribeOrderDetailInfoRequest{}

//设置client请求配置config
c.client.SetupRequest(req)

//设置默认重试
req.SetRetryable(true)
return req
}

// DescribeOrderDetailInfo - 获取订单信息
func (c *UBillClient) DescribeOrderDetailInfo(req *DescribeOrderDetailInfoRequest) (*DescribeOrderDetailInfoResponse, error) {
var err error
var res DescribeOrderDetailInfoResponse

err = c.client.InvokeAction("DescribeOrderDetailInfo", req, &res)
if err != nil {
return &res, err
}

return &res, nil
}
6 changes: 6 additions & 0 deletions services/ubill/types_order_detail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ubill

type OrderDetail struct {
ProductName string
Value string
}
26 changes: 26 additions & 0 deletions services/ubill/types_ubill_order_infos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ubill

type OrderInfo struct {
OrderNo string `json:"OrderNo"`
OrderType string
ChargeType string
ResourceId string
ResourceTag []ResourceTag
OrderState string
CreateTime int
Amount string //订单总金额
AmountReal string //现金账户金额
AmountFree string //赠送账户金额(元)
AmountCoupon string //优惠金额
CouponCode string //如果AmountCoupon不为0,显示代金券号码
ResourceType string
UpdateTime int
Quantity string //计费周期数
Count int //资源数量
Invoiced string //是否开过发票
StartTime int //开始时间
EndTime int //结束时间
OrderDetails []OrderDetail
RegionId string //region
TradeNo string //交易号
}
15 changes: 15 additions & 0 deletions services/ubill/types_ubill_resource_tag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ubill

type ResourceTag struct {
KeyId string //标识名,见下表
Value string //标识信息
}

/*KeyId Description
name 名称(eg. “hello_vm”)
hostname 主机名(eg. “uhost-0zjhzf”)
domain 域名(高防, eg. “www.qq.com”)
private_ip 内网IP
public_ip 外网IP
remark 备注
tag 标签 */
Loading

0 comments on commit d223288

Please sign in to comment.