Skip to content

Commit

Permalink
chore: pass query params in delete (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 authored Dec 11, 2024
1 parent ea68910 commit 8e35712
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (c *Client) SendRequest(method string, rawURL string, data url.Values,
// are added as information in the url itself. Also while Content-Type is json, we are sending
// json body. In that case, data variable contains all other parameters than body, which is the
//same case as GET method. In that case as well all parameters will be added to url
if method == http.MethodGet || contentType == jsonContentType {
if method == http.MethodGet || method == http.MethodDelete || contentType == jsonContentType {
if data != nil {
v, _ := form.EncodeToStringWith(data, delimiter, escapee, keepZeros)
s := delimitingRegex.ReplaceAllString(v, "")
Expand All @@ -164,20 +164,20 @@ func (c *Client) SendRequest(method string, rawURL string, data url.Values,
} else {
//Here the HTTP POST methods which is not having json content type are processed
//All the values will be added in data and encoded (all body, query, path parameters)
if method == http.MethodPost {
if method == http.MethodPost || method == http.MethodPut {
valueReader = strings.NewReader(data.Encode())
}
credErr := c.validateCredentials()
if credErr != nil {
return nil, credErr
}
req, err = http.NewRequest(method, u.String(), valueReader)
if err != nil {
return nil, err
}

}

credErr := c.validateCredentials()
if credErr != nil {
return nil, credErr
}
req.SetBasicAuth(c.basicAuth())

// E.g. "User-Agent": "twilio-go/1.0.0 (darwin amd64) go/go1.17.8"
Expand Down
4 changes: 2 additions & 2 deletions client/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ func (c *RequestHandler) Get(path string, queryData url.Values, headers map[stri
return c.sendRequest(http.MethodGet, path, queryData, headers)
}

func (c *RequestHandler) Delete(path string, nothing url.Values, headers map[string]interface{}) (*http.Response, error) {
return c.sendRequest(http.MethodDelete, path, nil, headers)
func (c *RequestHandler) Delete(path string, queryData url.Values, headers map[string]interface{}) (*http.Response, error) {
return c.sendRequest(http.MethodDelete, path, queryData, headers)
}

0 comments on commit 8e35712

Please sign in to comment.