From 3daab08256a51582341e933388f5beac3f13acf3 Mon Sep 17 00:00:00 2001 From: Paolo Romolini Date: Thu, 29 Aug 2024 11:23:18 +0200 Subject: [PATCH] feat: add query to filter custom objects record Signed-off-by: Paolo Romolini --- zendesk/custom_object.go | 6 +++--- zendesk/mock/client.go | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/zendesk/custom_object.go b/zendesk/custom_object.go index 3972c35..438f45b 100644 --- a/zendesk/custom_object.go +++ b/zendesk/custom_object.go @@ -74,7 +74,7 @@ type CustomObjectAPI interface { customObjectKey string, ) ([]CustomObjectField, error) FilterCustomObjectRecords( - ctx context.Context, customObjectKey string, filterBody interface{}, opts *CursorPagination, + ctx context.Context, customObjectKey string, filterBody interface{}, opts *SearchCustomObjectRecordsOptions, ) ([]CustomObjectRecord, CursorPaginationMeta, int64, error) } @@ -328,7 +328,7 @@ func (z *Client) ListCustomObjectFields( // https://developer.zendesk.com/api-reference/custom-data/custom-objects/ // custom_object_records/#filtered-search-of-custom-object-records func (z *Client) FilterCustomObjectRecords( - ctx context.Context, customObjectKey string, filterBody interface{}, opts *CursorPagination, + ctx context.Context, customObjectKey string, filterBody interface{}, opts *SearchCustomObjectRecordsOptions, ) ([]CustomObjectRecord, CursorPaginationMeta, int64, error) { var data struct { FilterBody interface{} `json:"filter"` @@ -341,7 +341,7 @@ func (z *Client) FilterCustomObjectRecords( } tmp := opts if tmp == nil { - tmp = &CursorPagination{} + tmp = &SearchCustomObjectRecordsOptions{} } url := fmt.Sprintf("/custom_objects/%s/records/search", customObjectKey) urlWithOptions, err := addOptions(url, tmp) diff --git a/zendesk/mock/client.go b/zendesk/mock/client.go index a67fe05..863c471 100644 --- a/zendesk/mock/client.go +++ b/zendesk/mock/client.go @@ -687,7 +687,7 @@ func (mr *ClientMockRecorder) DeleteWebhook(ctx, webhookID any) *gomock.Call { } // FilterCustomObjectRecords mocks base method. -func (m *Client) FilterCustomObjectRecords(ctx context.Context, customObjectKey string, filterBody any, opts *zendesk.CursorPagination) ([]zendesk.CustomObjectRecord, zendesk.CursorPaginationMeta, int64, error) { +func (m *Client) FilterCustomObjectRecords(ctx context.Context, customObjectKey string, filterBody any, opts *zendesk.SearchCustomObjectRecordsOptions) ([]zendesk.CustomObjectRecord, zendesk.CursorPaginationMeta, int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FilterCustomObjectRecords", ctx, customObjectKey, filterBody, opts) ret0, _ := ret[0].([]zendesk.CustomObjectRecord) @@ -1586,6 +1586,22 @@ func (mr *ClientMockRecorder) GetUserFields(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserFields", reflect.TypeOf((*Client)(nil).GetUserFields), ctx, opts) } +// GetUserOrganizationSubscriptions mocks base method. +func (m *Client) GetUserOrganizationSubscriptions(ctx context.Context, userID int64, opts *zendesk.OrganizationListOptions) ([]zendesk.OrganizationSubscription, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserOrganizationSubscriptions", ctx, userID, opts) + ret0, _ := ret[0].([]zendesk.OrganizationSubscription) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetUserOrganizationSubscriptions indicates an expected call of GetUserOrganizationSubscriptions. +func (mr *ClientMockRecorder) GetUserOrganizationSubscriptions(ctx, userID, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserOrganizationSubscriptions", reflect.TypeOf((*Client)(nil).GetUserOrganizationSubscriptions), ctx, userID, opts) +} + // GetUserRelated mocks base method. func (m *Client) GetUserRelated(ctx context.Context, userID int64) (zendesk.UserRelated, error) { m.ctrl.T.Helper()