mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
FileEdit fix, remove reduntant struct tag, improved test data
This commit is contained in:
parent
2f06836bd4
commit
446e9a0e54
@ -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
|
||||
|
@ -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() != "" {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user