@@ -116,6 +116,7 @@ type UserAPI interface {
116
116
SearchUsers (ctx context.Context , opts * SearchUsersOptions ) ([]User , Page , error )
117
117
GetManyUsers (ctx context.Context , opts * GetManyUsersOptions ) ([]User , Page , error )
118
118
GetUsers (ctx context.Context , opts * UserListOptions ) ([]User , Page , error )
119
+ GetOrganizationUsers (ctx context.Context , orgID int64 , opts * UserListOptions ) ([]User , Page , error )
119
120
GetUser (ctx context.Context , userID int64 ) (User , error )
120
121
CreateUser (ctx context.Context , user User ) (User , error )
121
122
CreateOrUpdateUser (ctx context.Context , user User ) (User , error )
@@ -153,6 +154,38 @@ func (z *Client) GetUsers(ctx context.Context, opts *UserListOptions) ([]User, P
153
154
return data .Users , data .Page , nil
154
155
}
155
156
157
+ // GetOrganizationUsers fetch organization users list
158
+ // https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users
159
+ // /api/v2/organizations/{organization_id}/users
160
+ func (z * Client ) GetOrganizationUsers (ctx context.Context , orgID int64 , opts * UserListOptions ) ([]User , Page , error ) {
161
+ var data struct {
162
+ Users []User `json:"users"`
163
+ Page
164
+ }
165
+
166
+ tmp := opts
167
+ if tmp == nil {
168
+ tmp = & UserListOptions {}
169
+ }
170
+ apiURL := fmt .Sprintf ("/organizations/%d/users.json" , orgID )
171
+
172
+ u , err := addOptions (apiURL , tmp )
173
+ if err != nil {
174
+ return nil , Page {}, err
175
+ }
176
+
177
+ body , err := z .get (ctx , u )
178
+ if err != nil {
179
+ return nil , Page {}, err
180
+ }
181
+
182
+ err = json .Unmarshal (body , & data )
183
+ if err != nil {
184
+ return nil , Page {}, err
185
+ }
186
+ return data .Users , data .Page , nil
187
+ }
188
+
156
189
// SearchUsers Returns an array of users who meet the search criteria.
157
190
// https://developer.zendesk.com/api-reference/ticketing/users/users/#search-users
158
191
func (z * Client ) SearchUsers (ctx context.Context , opts * SearchUsersOptions ) ([]User , Page , error ) {
0 commit comments