add support to Owners request to server

This commit is contained in:
Zi Lin
2016-02-19 09:50:25 -08:00
parent 71ddc45764
commit a03c794895
2 changed files with 48 additions and 1 deletions

View File

@@ -106,6 +106,20 @@ func unmarshalResponseData(respBytes []byte) (*core.ResponseData, error) {
return response, nil
}
func unmarshalOwnersData(respBytes []byte) (*core.OwnersData, error) {
response := new(core.OwnersData)
err := json.Unmarshal(respBytes, response)
if err != nil {
return nil, err
}
if response.Status != "ok" {
return nil, errors.New(response.Status)
}
return response, nil
}
// Create creates an admin account at the remote server
func (c *RemoteServer) Create(req core.CreateRequest) (*core.ResponseData, error) {
reqBytes, err := json.Marshal(req)
@@ -284,6 +298,21 @@ func (c *RemoteServer) Password(req []byte) (*core.ResponseData, error) {
return unmarshalResponseData(respBytes)
}
// Owners issues an Owners request to the remote server
func (c *RemoteServer) Owners(req core.OwnersRequest) (*core.OwnersData, error) {
reqBytes, err := json.Marshal(req)
if err != nil {
return nil, err
}
respBytes, err := c.doAction("owners", reqBytes)
if err != nil {
return nil, err
}
return unmarshalOwnersData(respBytes)
}
// Order issues an order request to the remote server
func (c *RemoteServer) Order(req core.OrderRequest) (*core.ResponseData, error) {
reqBytes, err := json.Marshal(req)