FileEdit fix, remove reduntant struct tag, improved test data

This commit is contained in:
Pavel 2019-09-09 14:57:58 +03:00
parent 2f06836bd4
commit 446e9a0e54
3 changed files with 6 additions and 13 deletions

View File

@ -4173,7 +4173,9 @@ func (c *Client) FileEdit(id int, file File) (FileResponse, int, *errs.Failure)
var resp FileResponse
req, _ := json.Marshal(file)
data, status, err := c.PostRequest(fmt.Sprintf("/files/%d/edit", id), bytes.NewReader(req))
data, status, err := c.PostRequest(fmt.Sprintf("/files/%d/edit", id), url.Values{
"file": {string(req)},
})
if err != nil && err.Error() != "" {
return resp, status, err

View File

@ -4764,16 +4764,7 @@ func TestClient_Files(t *testing.T) {
MatchParam("limit", "20").
MatchParam("page", "1").
Reply(200).
BodyString(`{
"success": true,
"pagination": {
"limit": 20,
"totalCount": 0,
"currentPage": 1,
"totalPageCount": 0
},
"files": []
}`)
BodyString(`{"success": true,"pagination": {"limit": 20,"totalCount": 0,"currentPage": 1,"totalPageCount": 0},"files": []}`)
_, status, err := c.Files(FilesRequest{
Limit: 20,
@ -4826,7 +4817,7 @@ func TestClient_FileUploadFail(t *testing.T) {
gock.New(crmURL).
Post("/files/upload").
Reply(400).
BodyString(`{"success": false, "errorMsg": "error"}`)
BodyString(`{"success":false,"errorMsg":"Your account doesn't have enough money to upload files."}`)
_, status, err := c.FileUpload(file)
if err.Error() != "" {

View File

@ -371,7 +371,7 @@ type CostResponse struct {
type FilesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Files []File `json:"files,omitempty,brackets"`
Files []File `json:"files,omitempty"`
}
// FileUpload response