#132 Added some comments for API client (#9872)

* #132 Added some comments for API client

* #132 fixed godoc formatting

* #138 fixed go formatting
This commit is contained in:
Harshil Sharma
2018-11-26 16:13:56 +05:30
committed by George Goldberg
parent be8be3a6dc
commit 60393f1cad
2 changed files with 8 additions and 4 deletions

View File

@@ -3069,7 +3069,7 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
defer th.TearDown()
Client := th.Client
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, "st_1", true)
success, resp := Client.RegisterTermsOfServiceAction(th.BasicUser.Id, "st_1", true)
CheckErrorMessage(t, resp, "store.sql_terms_of_service_store.get.no_rows.app_error")
termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
@@ -3077,7 +3077,7 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
t.Fatal(err)
}
success, resp = Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
success, resp = Client.RegisterTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
CheckNoError(t, resp)
assert.True(t, *success)
@@ -3100,7 +3100,7 @@ func TestGetUserTermsOfService(t *testing.T) {
t.Fatal(err)
}
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
success, resp := Client.RegisterTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
CheckNoError(t, resp)
assert.True(t, *success)

View File

@@ -3919,7 +3919,8 @@ func (c *Client4) GetRedirectLocation(urlParam, etag string) (string, *Response)
return MapFromJson(r.Body)["location"], BuildResponse(r)
}
func (c *Client4) RegisteTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
// RegisterTermsOfServiceAction saves action performed by a user against a specific terms of service.
func (c *Client4) RegisterTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
url := c.GetUserTermsOfServiceRoute(userId)
data := map[string]interface{}{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
r, err := c.DoApiPost(url, StringInterfaceToJson(data))
@@ -3930,6 +3931,7 @@ func (c *Client4) RegisteTermsOfServiceAction(userId, termsOfServiceId string, a
return NewBool(CheckStatusOK(r)), BuildResponse(r)
}
// GetTermsOfService fetches the latest terms of service
func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
url := c.GetTermsOfServiceRoute()
r, err := c.DoApiGet(url, etag)
@@ -3940,6 +3942,7 @@ func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
return TermsOfServiceFromJson(r.Body), BuildResponse(r)
}
// GetUserTermsOfService fetches user's latest terms of service action if the latest action was for acceptance.
func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfService, *Response) {
url := c.GetUserTermsOfServiceRoute(userId)
r, err := c.DoApiGet(url, etag)
@@ -3950,6 +3953,7 @@ func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfServic
return UserTermsOfServiceFromJson(r.Body), BuildResponse(r)
}
// CreateTermsOfService creates new terms of service.
func (c *Client4) CreateTermsOfService(text, userId string) (*TermsOfService, *Response) {
url := c.GetTermsOfServiceRoute()
data := map[string]interface{}{"text": text}