Skip to content

Commit

Permalink
Merge pull request #20 from belong-inc/update-readme-and-minor-fixes
Browse files Browse the repository at this point in the history
Update README.md and add const for mimetype
  • Loading branch information
kk-no authored Apr 27, 2023
2 parents 74c46a1 + 625f19c commit e7c15ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ fmt.Println(customDeal.CustomA, customDeal.CustomB)
|-------------|---------------------|-----------------|
|CRM | Deal | Available |
|CRM | Contact | Available |
|CRM | Imports | Beta |
|CRM | Schemas | Beta |
|CRM | Properties | Beta |
|CMS | All | Not Implemented |
|Conversations| All | Not Implemented |
|Events | All | Not Implemented |
Expand All @@ -225,4 +228,4 @@ fmt.Println(customDeal.CustomA, customDeal.CustomB)
# Contributing

Contributions are generally welcome.
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) when making your contribution.
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) when making your contribution.
12 changes: 6 additions & 6 deletions gohubspot.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,30 +229,30 @@ func isErrorStatusCode(code int) bool {

// Get performs a GET request for the given path and saves the result in the given resource.
func (c *Client) Get(path string, resource interface{}, option interface{}) error {
return c.CreateAndDo(http.MethodGet, path, "application/json", nil, option, resource)
return c.CreateAndDo(http.MethodGet, path, MIMETypeJSON, nil, option, resource)
}

// Post performs a POST request for the given path and saves the result in the given resource.
func (c *Client) Post(path string, data, resource interface{}) error {
return c.CreateAndDo(http.MethodPost, path, "application/json", data, nil, resource)
return c.CreateAndDo(http.MethodPost, path, MIMETypeJSON, data, nil, resource)
}

// Put performs a PUT request for the given path and saves the result in the given resource.
func (c *Client) Put(path string, data, resource interface{}) error {
return c.CreateAndDo(http.MethodPut, path, "application/json", data, nil, resource)
return c.CreateAndDo(http.MethodPut, path, MIMETypeJSON, data, nil, resource)
}

// Patch performs a PATCH request for the given path and saves the result in the given resource.
func (c *Client) Patch(path string, data, resource interface{}) error {
return c.CreateAndDo(http.MethodPatch, path, "application/json", data, nil, resource)
return c.CreateAndDo(http.MethodPatch, path, MIMETypeJSON, data, nil, resource)
}

// Delete performs a DELETE request for the given path.
func (c *Client) Delete(path string, option interface{}) error {
return c.CreateAndDo(http.MethodDelete, path, "application/json", nil, option, nil)
return c.CreateAndDo(http.MethodDelete, path, MIMETypeJSON, nil, option, nil)
}

func (c *Client) PostMultipart(path, boundary string, data, resource interface{}) error {
mimeType := fmt.Sprintf("multipart/form-data; boundary=%s", boundary)
mimeType := fmt.Sprintf("%s; boundary=%s", MIMETypeFormData, boundary)
return c.CreateAndDo(http.MethodPost, path, mimeType, data, nil, resource)
}
8 changes: 8 additions & 0 deletions mimetype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package hubspot

const (
// MIMETypeJSON is the mimetype for JSON.
MIMETypeJSON = "application/json"
// MIMETypeFormData is the mimetype for multipart form data.
MIMETypeFormData = "multipart/form-data"
)

0 comments on commit e7c15ab

Please sign in to comment.