mirror of
https://github.com/retailcrm/api-client-go.git
synced 2025-02-16 21:03:13 +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
|
var resp FileResponse
|
||||||
|
|
||||||
req, _ := json.Marshal(file)
|
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() != "" {
|
if err != nil && err.Error() != "" {
|
||||||
return resp, status, err
|
return resp, status, err
|
||||||
|
@ -4764,16 +4764,7 @@ func TestClient_Files(t *testing.T) {
|
|||||||
MatchParam("limit", "20").
|
MatchParam("limit", "20").
|
||||||
MatchParam("page", "1").
|
MatchParam("page", "1").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
BodyString(`{
|
BodyString(`{"success": true,"pagination": {"limit": 20,"totalCount": 0,"currentPage": 1,"totalPageCount": 0},"files": []}`)
|
||||||
"success": true,
|
|
||||||
"pagination": {
|
|
||||||
"limit": 20,
|
|
||||||
"totalCount": 0,
|
|
||||||
"currentPage": 1,
|
|
||||||
"totalPageCount": 0
|
|
||||||
},
|
|
||||||
"files": []
|
|
||||||
}`)
|
|
||||||
|
|
||||||
_, status, err := c.Files(FilesRequest{
|
_, status, err := c.Files(FilesRequest{
|
||||||
Limit: 20,
|
Limit: 20,
|
||||||
@ -4826,7 +4817,7 @@ func TestClient_FileUploadFail(t *testing.T) {
|
|||||||
gock.New(crmURL).
|
gock.New(crmURL).
|
||||||
Post("/files/upload").
|
Post("/files/upload").
|
||||||
Reply(400).
|
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)
|
_, status, err := c.FileUpload(file)
|
||||||
if err.Error() != "" {
|
if err.Error() != "" {
|
||||||
|
@ -371,7 +371,7 @@ type CostResponse struct {
|
|||||||
type FilesResponse struct {
|
type FilesResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
Pagination *Pagination `json:"pagination,omitempty"`
|
Pagination *Pagination `json:"pagination,omitempty"`
|
||||||
Files []File `json:"files,omitempty,brackets"`
|
Files []File `json:"files,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileUpload response
|
// FileUpload response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user