@@ -30,39 +30,72 @@ type User struct {
3030IsYou bool `json:"is_you"`
3131}
3232
33- type Users struct {
33+ type UsersResponse struct {
3434Success bool `json:"success"`
3535Error string `json:"error,omitempty"`
3636ErrorInfo string `json:"error_info,omitempty"`
3737Data []User `json:"data"`
3838AdditionalData AdditionalData `json:"additional_data"`
3939}
4040
41- type SingleUser struct {
41+ type UserSingleResponse struct {
4242Success bool `json:"success"`
4343Data User `json:"data"`
4444AdditionalData AdditionalData `json:"additional_data"`
4545}
4646
47+ type UserFollowersResponse struct {
48+ Success bool `json:"success"`
49+ Data []int `json:"data"`
50+ AdditionalData AdditionalData `json:"additional_data"`
51+ }
52+
4753type UsersFindByNameOptions struct {
4854Term string `url:"term,omitempty"`
4955SearchByEmail int `url:"search_by_email,omitempty"`
5056}
5157
58+ type UsersUpdateUserDetailsOptions struct {
59+ ActiveFlag uint8 `url:"active_flag,omitempty"`
60+ }
61+
62+ type DeletePermissionSetAssignmentOptions struct {
63+ PermissionSetId uint `url:"permission_set_id,omitempty"`
64+ }
65+
5266type DeleteRoleAssignmentOptions struct {
5367RoleId uint `url:"role_id,omitempty"`
5468}
5569
56- // Returns data about all users within the company.
5770// Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users/get_users
58- func (s * UsersService ) List () (* Users , * Response , error ) {
71+ func (s * UsersService ) List () (* UsersResponse , * Response , error ) {
5972req , err := s .client .NewRequest (http .MethodGet , "/users" , nil , nil )
6073
6174if err != nil {
6275return nil , nil , err
6376}
6477
65- var record * Users
78+ var record * UsersResponse
79+
80+ resp , err := s .client .Do (req , & record )
81+
82+ if err != nil {
83+ return nil , resp , err
84+ }
85+
86+ return record , resp , nil
87+ }
88+
89+ // https://developers.pipedrive.com/docs/api/v1/#!/Users/get_users_id_followers
90+ func (s * UsersService ) ListFollowers (id int ) (* UserFollowersResponse , * Response , error ) {
91+ uri := fmt .Sprintf ("/users/%v/followers" , id )
92+ req , err := s .client .NewRequest (http .MethodGet , uri , nil , nil )
93+
94+ if err != nil {
95+ return nil , nil , err
96+ }
97+
98+ var record * UserFollowersResponse
6699
67100resp , err := s .client .Do (req , & record )
68101
@@ -73,16 +106,15 @@ func (s *UsersService) List() (*Users, *Response, error) {
73106return record , resp , nil
74107}
75108
76- // Finds users by their name.
77109// Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users/get_users_find
78- func (s * UsersService ) FindByName (opt * UsersFindByNameOptions ) (* Users , * Response , error ) {
110+ func (s * UsersService ) FindByName (opt * UsersFindByNameOptions ) (* UsersResponse , * Response , error ) {
79111req , err := s .client .NewRequest (http .MethodGet , "/users/find" , opt , nil )
80112
81113if err != nil {
82114return nil , nil , err
83115}
84116
85- var record * Users
117+ var record * UsersResponse
86118
87119resp , err := s .client .Do (req , & record )
88120
@@ -93,17 +125,16 @@ func (s *UsersService) FindByName(opt *UsersFindByNameOptions) (*Users, *Respons
93125return record , resp , nil
94126}
95127
96- // Returns data about a specific user within the company
97128// Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users/get_users_id
98- func (s * UsersService ) GetById (id int ) (* SingleUser , * Response , error ) {
129+ func (s * UsersService ) GetById (id int ) (* UserFollowersResponse , * Response , error ) {
99130uri := fmt .Sprintf ("/users/%v" , id )
100131req , err := s .client .NewRequest (http .MethodGet , uri , nil , nil )
101132
102133if err != nil {
103134return nil , nil , err
104135}
105136
106- var record * SingleUser
137+ var record * UserFollowersResponse
107138
108139resp , err := s .client .Do (req , & record )
109140
@@ -114,11 +145,46 @@ func (s *UsersService) GetById(id int) (*SingleUser, *Response, error) {
114145return record , resp , nil
115146}
116147
117- // Delete a role assignment for a user.
148+ // Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users/put_users_id
149+ func (s * UsersService ) UpdateUserDetails (id int , opt * UsersUpdateUserDetailsOptions ) (* Response , error ) {
150+ uri := fmt .Sprintf ("/users/%v" , id )
151+ req , err := s .client .NewRequest (http .MethodPut , uri , opt , nil )
152+
153+ if err != nil {
154+ return nil , err
155+ }
156+
157+ resp , err := s .client .Do (req , nil )
158+
159+ if err != nil {
160+ return resp , err
161+ }
162+
163+ return resp , nil
164+ }
165+
166+ // Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users/delete_users_id_permissionSetAssignments
167+ func (s * UsersService ) DeletePermissionSetAssignment (id int , opt * DeletePermissionSetAssignmentOptions ) (* Response , error ) {
168+ uri := fmt .Sprintf ("/users/%v/permissionSetAssignments" , id )
169+ req , err := s .client .NewRequest (http .MethodDelete , uri , opt , nil )
170+
171+ if err != nil {
172+ return nil , err
173+ }
174+
175+ resp , err := s .client .Do (req , nil )
176+
177+ if err != nil {
178+ return resp , err
179+ }
180+
181+ return resp , nil
182+ }
183+
118184// Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Users/delete_users_id_roleAssignments
119185func (s * UsersService ) DeleteRoleAssignment (id int , opt * DeleteRoleAssignmentOptions ) (* Response , error ) {
120186uri := fmt .Sprintf ("/users/%v/roleAssignments" , id )
121- req , err := s .client .NewRequest (http .MethodDelete , uri , nil , nil )
187+ req , err := s .client .NewRequest (http .MethodDelete , uri , opt , nil )
122188
123189if err != nil {
124190return nil , err
0 commit comments