@@ -143,6 +143,7 @@ type TicketListOptions struct {
143
143
// TicketAPI an interface containing all ticket related methods
144
144
type TicketAPI interface {
145
145
GetTickets (ctx context.Context , opts * TicketListOptions ) ([]Ticket , Page , error )
146
+ GetOrganizationTickets (ctx context.Context , organizationID int64 , ops * TicketListOptions ) ([]Ticket , Page , error )
146
147
GetTicket (ctx context.Context , id int64 ) (Ticket , error )
147
148
GetMultipleTickets (ctx context.Context , ticketIDs []int64 ) ([]Ticket , error )
148
149
CreateTicket (ctx context.Context , ticket Ticket ) (Ticket , error )
@@ -181,6 +182,40 @@ func (z *Client) GetTickets(ctx context.Context, opts *TicketListOptions) ([]Tic
181
182
return data .Tickets , data .Page , nil
182
183
}
183
184
185
+ // GetOrganizationTickets get organization ticket list
186
+ //
187
+ // ref: https://developer.zendesk.com/rest_api/docs/support/tickets#list-tickets
188
+ func (z * Client ) GetOrganizationTickets (
189
+ ctx context.Context , organizationID int64 , opts * TicketListOptions ,
190
+ ) ([]Ticket , Page , error ) {
191
+ var data struct {
192
+ Tickets []Ticket `json:"tickets"`
193
+ Page
194
+ }
195
+
196
+ tmp := opts
197
+ if tmp == nil {
198
+ tmp = & TicketListOptions {}
199
+ }
200
+
201
+ path := fmt .Sprintf ("/organizations/%d/tickets.json" , organizationID )
202
+ u , err := addOptions (path , tmp )
203
+ if err != nil {
204
+ return nil , Page {}, err
205
+ }
206
+
207
+ body , err := z .get (ctx , u )
208
+ if err != nil {
209
+ return nil , Page {}, err
210
+ }
211
+
212
+ err = json .Unmarshal (body , & data )
213
+ if err != nil {
214
+ return nil , Page {}, err
215
+ }
216
+ return data .Tickets , data .Page , nil
217
+ }
218
+
184
219
// GetTicket gets a specified ticket
185
220
//
186
221
// ref: https://developer.zendesk.com/rest_api/docs/support/tickets#show-ticket
0 commit comments