2015-06-20 18:25:21 +02:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
2016-05-04 17:48:12 +02:00
|
|
|
"errors"
|
2015-06-20 18:25:21 +02:00
|
|
|
"fmt"
|
|
|
|
|
2016-05-04 17:48:12 +02:00
|
|
|
common "github.com/maximilien/softlayer-go/common"
|
2015-06-20 18:25:21 +02:00
|
|
|
datatypes "github.com/maximilien/softlayer-go/data_types"
|
|
|
|
softlayer "github.com/maximilien/softlayer-go/softlayer"
|
|
|
|
)
|
|
|
|
|
|
|
|
type softLayer_Billing_Item_Cancellation_Request_Service struct {
|
|
|
|
client softlayer.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSoftLayer_Billing_Item_Cancellation_Request_Service(client softlayer.Client) *softLayer_Billing_Item_Cancellation_Request_Service {
|
|
|
|
return &softLayer_Billing_Item_Cancellation_Request_Service{
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (slbicr *softLayer_Billing_Item_Cancellation_Request_Service) GetName() string {
|
|
|
|
return "SoftLayer_Billing_Item_Cancellation_Request"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (slbicr *softLayer_Billing_Item_Cancellation_Request_Service) CreateObject(request datatypes.SoftLayer_Billing_Item_Cancellation_Request) (datatypes.SoftLayer_Billing_Item_Cancellation_Request, error) {
|
|
|
|
parameters := datatypes.SoftLayer_Billing_Item_Cancellation_Request_Parameters{
|
|
|
|
Parameters: []datatypes.SoftLayer_Billing_Item_Cancellation_Request{
|
|
|
|
request,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
requestBody, err := json.Marshal(parameters)
|
|
|
|
if err != nil {
|
|
|
|
return datatypes.SoftLayer_Billing_Item_Cancellation_Request{}, err
|
|
|
|
}
|
|
|
|
|
2016-05-04 17:48:12 +02:00
|
|
|
responseBytes, errorCode, err := slbicr.client.GetHttpClient().DoRawHttpRequest(fmt.Sprintf("%s/createObject.json", slbicr.GetName()), "POST", bytes.NewBuffer(requestBody))
|
2015-06-20 18:25:21 +02:00
|
|
|
if err != nil {
|
|
|
|
return datatypes.SoftLayer_Billing_Item_Cancellation_Request{}, err
|
|
|
|
}
|
|
|
|
|
2016-05-04 17:48:12 +02:00
|
|
|
if common.IsHttpErrorCode(errorCode) {
|
|
|
|
errorMessage := fmt.Sprintf("softlayer-go: could not SoftLayer_Billing_Item_Cancellation_Request#createObject TTP error code: '%d'", errorCode)
|
|
|
|
return datatypes.SoftLayer_Billing_Item_Cancellation_Request{}, errors.New(errorMessage)
|
|
|
|
}
|
|
|
|
|
2015-06-20 18:25:21 +02:00
|
|
|
result := datatypes.SoftLayer_Billing_Item_Cancellation_Request{}
|
|
|
|
err = json.Unmarshal(responseBytes, &result)
|
|
|
|
if err != nil {
|
|
|
|
return datatypes.SoftLayer_Billing_Item_Cancellation_Request{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|