Skip to content
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
45 changes: 45 additions & 0 deletions service/qingcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,48 @@ type DescribeZonesOutput struct {
TotalCount *int `json:"total_count" name:"total_count" location:"elements"`
ZoneSet []*Zone `json:"zone_set" name:"zone_set" location:"elements"`
}
type GetBalanceInput struct {

}

func (v *GetBalanceInput) Validate() error {

return nil
}

type GetBalanceOutput struct {
Action string `json:"action" name:"action" location:"elements"`
UserID string `json:"user_id" name:"user_id" location:"elements"`
Balance string `json:"balance" name:"balance" location:"elements"`
Bonus string `json:"bonus" name:"onus" location:"elements"`
Coupons []*string `json:"coupons" name:"coupons" location:"elements"`
RetCode *int `json:"ret_code" name:"ret_code" location:"elements"`
}



// Documentation URL: https://docsv4.qingcloud.com/user_guide/development_docs/api/api_list/billing/get_balance/
func (s *QingCloudService) GetBalance(i *GetBalanceInput) (*DescribeZonesOutput, error) {
if i == nil {
i = &GetBalanceInput{}
}
o := &data.Operation{
Config: s.Config,
Properties: s.Properties,
APIName: "GetBalance",
RequestMethod: "GET",
}

x := &DescribeZonesOutput{}
r, err := request.New(o, i, x)
if err != nil {
return nil, err
}

err = r.Send()
if err != nil {
return nil, err
}

return x, err
}
17 changes: 17 additions & 0 deletions test/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func QingCloudServiceFeatureContext(s *godog.Suite) {
s.Step(`^describe zones$`, describeZones)
s.Step(`^describe zones should get (\d+) zone at least$`, describeZonesShouldGetZoneAtLeast)
s.Step(`^describe zones should have the zone I\'m using$`, describeZonesShouldHaveTheZoneIamUsing)

s.Step(`^get balance$`, getBalance())
s.Step(`^get balance should not error$`, getBalanceShouldNotError)
}

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -72,3 +75,17 @@ func describeZonesShouldHaveTheZoneIamUsing() error {

return fmt.Errorf("DescribeZones dosen't have zone \"%s\"", tc.Zone)
}

// --------------------------------------------------------------------------
var getBalanceOutput *qc.GetBalanceOutput

func getBalance() error {
describeZonesOutput, err = qcService.GetBalance(nil)
return err
}
func getBalanceShouldNotError() error {
if *getBalanceOutput.RetCode == 0 {
return nil
}
return fmt.Errorf("DescribeZones dosen't have zone \"%s\"", tc.Zone)
}