From 60393f1cad6ed0a70932460e5f91571fcff39cfc Mon Sep 17 00:00:00 2001 From: Harshil Sharma Date: Mon, 26 Nov 2018 16:13:56 +0530 Subject: [PATCH] #132 Added some comments for API client (#9872) * #132 Added some comments for API client * #132 fixed godoc formatting * #138 fixed go formatting --- api4/user_test.go | 6 +++--- model/client4.go | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api4/user_test.go b/api4/user_test.go index 3962d4ed94..4af6a31360 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -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) diff --git a/model/client4.go b/model/client4.go index 9e1856ec55..d064794dba 100644 --- a/model/client4.go +++ b/model/client4.go @@ -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}