diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eb1db6..a6088f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: path-to-profile: profile.cov flag-name: Go-${{ matrix.go-version }} parallel: true - ignore: zendesk/mock/client.go + ignore: zendesk/mock/client.go, zendesk/*_generated.go finalize: needs: test diff --git a/CBPMigration.md b/CBPMigration.md new file mode 100644 index 0000000..6a546b1 --- /dev/null +++ b/CBPMigration.md @@ -0,0 +1,92 @@ +# OBP to CBP migration + +Zendesk is [obsoleting](https://support.zendesk.com/hc/en-us/articles/4408846180634-Introducing-Pagination-Changes-Zendesk-API#h_01F7Y57A0G5M3R8JXGCQTBKVWA) Offset Based Pagination (OBP), it's recomended to start adopting Cursor Based Pagination (CBP). This SDK have created pagination Iterators to help facilite the change. + +To use the pagination iterator, start with `NewPaginationOptions()` function, it will return a `PaginationOptions` object, you can specify the default page size in `PageSize` variable. By default, `PageSize` is 100. Then you can call the `client.GetXXXXXIterator(ctx, ops)` to return an object pagination iterator, with the iterator, you can iterator through the objects with `HasMore()` and `GetNext()` until `HasMore` return `false`. + +```go +ops := NewPaginationOptions() +// ops.PageSize = 50 // PageSize can be set to 50 +it := client.GetTicketsIterator(ctx, ops) +for it.HasMore() { + tickets, err := it.GetNext() + if err == nil { + for _, ticket := range tickets { + println(ticket.Subject) + } + } +} +``` + +If the API endpoint requires more options like organization ID, it can be set into the `Id` attribute like below example: + +```go +ops := NewPaginationOptions() +ops.Sort = "updated_at" +ops.PageSize = 10 +ops.Id = 360363695492 +it := client.GetOrganizationTicketsIterator(ctx, ops) + +for it.HasMore() { + tickets, err := it.GetNext() + if err == nil { + for _, ticket := range tickets { + println(ticket.Subject) + } + } +} +``` + +For any API specific parameters, they are predefined in the `CommonOptions` struct, we can set these attributes in the `PaginationOptions` object. +If new attributes are introduced to any existing or new API endpoints, it can be added into this struct. + +```go +type CommonOptions struct { + Active bool `url:"active,omitempty"` + Role string `url:"role,omitempty"` + Roles []string `url:"role[],omitempty"` + PermissionSet int64 `url:"permission_set,omitempty"` + + // SortBy can take "assignee", "assignee.name", "created_at", "group", "id", + // "locale", "requester", "requester.name", "status", "subject", "updated_at" + SortBy string `url:"sort_by,omitempty"` + + // SortOrder can take "asc" or "desc" + SortOrder string `url:"sort_order,omitempty"` + Sort string `url:"sort,omitempty"` + Id int64 + GroupID int64 `json:"group_id,omitempty" url:"group_id,omitempty"` + UserID int64 `json:"user_id,omitempty" url:"user_id,omitempty"` + OrganizationID int64 `json:"organization_id,omitempty" url:"organization_id,omitempty"` + + Access string `json:"access"` + Category int `json:"category"` + Include string `json:"include" url:"include,omitempty"` + OnlyViewable bool `json:"only_viewable"` + Query string `url:"query"` + EndUserVisible bool `url:"end_user_visible,omitempty"` + FallbackToDefault bool `url:"fallback_to_default,omitempty"` + AssociatedToBrand bool `url:"associated_to_brand,omitempty"` + CategoryID string `url:"category_id,omitempty"` + + IncludeInlineImages string `url:"include_inline_images,omitempty"` +} +``` + +## To regenerate CBP(Cursor Based Pagination), OBP(Offset Based Pagination) helper function and Iterators + +If a new API endpoint supports CBP, add a new element to the funcData in script/codegen/main.go file like this: + +```go +{ + FuncName: "Automations", + ObjectName: "Automation", + ApiEndpoint: "/automation.json", + JsonName: "automations", + FileName: "automation", +}, +``` + +should use the script to generate the helper functions and the iterator +`go run script/codegen/main.go` + diff --git a/README.md b/README.md index 84ac1d8..da32481 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # go-zendesk + [![Actions Status](https://github.com/nukosuke/go-zendesk/workflows/CI/badge.svg)](https://github.com/nukosuke/go-zendesk/actions) [![Build status](https://ci.appveyor.com/api/projects/status/ce4p1mswjkdftv6o/branch/master?svg=true)](https://ci.appveyor.com/project/nukosuke/go-zendesk/branch/master) [![Coverage Status](https://coveralls.io/repos/github/nukosuke/go-zendesk/badge.svg?branch=master)](https://coveralls.io/github/nukosuke/go-zendesk?branch=master) @@ -12,7 +13,7 @@ Zendesk API client library for Go ## Installation -``` shell +```shell $ go get github.com/nukosuke/go-zendesk ``` @@ -48,6 +49,7 @@ func main() { ``` ## Want to mock API? + go-zendesk has a [mock package](https://pkg.go.dev/github.com/nukosuke/go-zendesk/zendesk/mock) generated by [golang/mock](https://github.com/golang/mock). You can simulate the response from Zendesk API with it. @@ -55,7 +57,10 @@ You can simulate the response from Zendesk API with it. `go generate ./...` +## Zendesk [OBP(Offset Based Pagination) to CBP(Cursor Based Pagination) migration guide](CBPMigration.md) + ## Maintainer + - [nukosuke](https://github.com/nukosuke) ## License @@ -64,5 +69,4 @@ MIT License. See the file [LICENSE](./LICENSE). - [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnukosuke%2Fgo-zendesk.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnukosuke%2Fgo-zendesk?ref=badge_large) diff --git a/script/codegen/main.go b/script/codegen/main.go new file mode 100644 index 0000000..db38f1b --- /dev/null +++ b/script/codegen/main.go @@ -0,0 +1,285 @@ +package main + +import ( + "fmt" + "html/template" + "os" +) + +var tpl = ` +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk +{{ if .ExtraParam }} +import ( + "context" + "fmt" +) +{{ else }} +import "context" +{{ end }} +func (z *Client) Get{{.FuncName}}Iterator(ctx context.Context, opts *PaginationOptions) *Iterator[{{.ObjectName}}] { + return &Iterator[{{.ObjectName}}]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.Get{{.FuncName}}OBP, + cbpFunc: z.Get{{.FuncName}}CBP, + } +} + +func (z *Client) Get{{.FuncName}}OBP(ctx context.Context, opts *OBPOptions) ([]{{.ObjectName}}, Page, error) { + var data struct { + {{.ObjectName}}s []{{.ObjectName}} ` + "`json:\"{{.JsonName}}\"`" + ` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + {{ if .ExtraParam }} + path := fmt.Sprintf("{{.ApiEndpoint}}", tmp.Id) + u, err := addOptions(path, tmp) + {{ else }} + u, err := addOptions("{{.ApiEndpoint}}", tmp) + {{ end }} + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.{{.ObjectName}}s, data.Page, nil +} + +func (z *Client) Get{{.FuncName}}CBP(ctx context.Context, opts *CBPOptions) ([]{{.ObjectName}}, CursorPaginationMeta, error) { + var data struct { + {{.ObjectName}}s []{{.ObjectName}} ` + "`json:\"{{.JsonName}}\"`" + ` + Meta CursorPaginationMeta ` + "`json:\"meta\"`" + ` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + {{ if .ExtraParam }} + path := fmt.Sprintf("{{.ApiEndpoint}}", tmp.Id) + u, err := addOptions(path, tmp) + {{ else }} + u, err := addOptions("{{.ApiEndpoint}}", tmp) + {{ end }} + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.{{.ObjectName}}s, data.Meta, nil +} + +` + +type FuncTemplateData struct { + FuncName string + ObjectName string + ApiEndpoint string + JsonName string + FileName string + ExtraParam bool +} + +var funcData []FuncTemplateData = []FuncTemplateData{ + { + FuncName: "Automations", + ObjectName: "Automation", + ApiEndpoint: "/automation.json", + JsonName: "automations", + FileName: "automation", + }, + { + FuncName: "GroupMemberships", + ObjectName: "GroupMembership", + ApiEndpoint: "/group_memberships.json", + JsonName: "group_memberships", + FileName: "group_membership", + }, + { + FuncName: "Macros", + ObjectName: "Macro", + ApiEndpoint: "/macros.json", + JsonName: "macros", + FileName: "macro", + }, + { + FuncName: "OrganizationFields", + ObjectName: "OrganizationField", + ApiEndpoint: "/organization_fields.json", + JsonName: "organization_fields", + FileName: "organization_field", + }, + { + FuncName: "OrganizationMemberships", + ObjectName: "OrganizationMembership", + ApiEndpoint: "/organization_memberships.json", + JsonName: "organization_memberships", + FileName: "organization_membership", + }, + { + FuncName: "Organizations", + ObjectName: "Organization", + ApiEndpoint: "/organizations.json", + JsonName: "organizations", + FileName: "organization", + }, + { + FuncName: "Search", + ObjectName: "SearchResults", + ApiEndpoint: "/search.json", + JsonName: "results", + FileName: "search", + }, + { + FuncName: "SLAPolicies", + ObjectName: "SLAPolicy", + ApiEndpoint: "/slas/policies.json", + JsonName: "sla_policies", + FileName: "sla_policy", + }, + { + FuncName: "AllTicketAudits", + ObjectName: "TicketAudit", + ApiEndpoint: "/ticket_audits.json", + JsonName: "audits", + FileName: "all_ticket_audit", + }, + { + FuncName: "TicketAudits", + ObjectName: "TicketAudit", + ApiEndpoint: "/tickets/%d/audits.json", + JsonName: "audits", + FileName: "ticket_audit", + ExtraParam: true, + }, + { + FuncName: "TicketFields", + ObjectName: "TicketField", + ApiEndpoint: "/ticket_fields.json", + JsonName: "ticket_fields", + FileName: "ticket_field", + }, + { + FuncName: "TicketForms", + ObjectName: "TicketForm", + ApiEndpoint: "/ticket_forms.json", + JsonName: "ticket_forms", + FileName: "ticket_form", + }, + { + FuncName: "Triggers", + ObjectName: "Trigger", + ApiEndpoint: "/triggers.json", + JsonName: "triggers", + FileName: "trigger", + }, + { + FuncName: "UserFields", + ObjectName: "UserField", + ApiEndpoint: "/user_fields.json", + JsonName: "user_fields", + FileName: "user_field", + }, + { + FuncName: "Users", + ObjectName: "User", + ApiEndpoint: "/users.json", + JsonName: "users", + FileName: "user", + }, + { + FuncName: "OrganizationUsers", + ObjectName: "User", + ApiEndpoint: "/organizations/%d/users.json", + JsonName: "users", + FileName: "organization_users", + ExtraParam: true, + }, + { + FuncName: "Views", + ObjectName: "View", + ApiEndpoint: "/views.json", + JsonName: "views", + FileName: "view", + }, + { + FuncName: "TicketsFromView", + ObjectName: "Ticket", + ApiEndpoint: "/views/%d/tickets.json", + JsonName: "tickets", + FileName: "tickets_from_view", + ExtraParam: true, + }, + { + FuncName: "Tickets", + ObjectName: "Ticket", + ApiEndpoint: "/tickets.json", + JsonName: "tickets", + FileName: "ticket", + }, + { + FuncName: "TicketComments", + ObjectName: "TicketComment", + ApiEndpoint: "/tickets/%d/comments.json", + JsonName: "comments", + FileName: "ticket_comment", + ExtraParam: true, + }, + { + FuncName: "Groups", + ObjectName: "Group", + ApiEndpoint: "/groups.json", + JsonName: "groups", + FileName: "group", + }, + { + FuncName: "OrganizationTickets", + ObjectName: "Ticket", + ApiEndpoint: "/organizations/%d/tickets.json", + JsonName: "tickets", + FileName: "organization_tickets", + ExtraParam: true, + }, +} + +func main() { + + tt := template.Must(template.New("func").Parse(tpl)) + + for _, v := range funcData { + dest := "zendesk/" + v.FileName + "_generated.go" + file, err := os.Create(dest) + if err != nil { + panic(err) + } + err = tt.Execute(file, v) + if err != nil { + panic(err) + } + file.Close() + fmt.Println("Generated " + dest + " successfully") + } + +} diff --git a/zendesk/all_ticket_audit_generated.go b/zendesk/all_ticket_audit_generated.go new file mode 100644 index 0000000..8b7a77d --- /dev/null +++ b/zendesk/all_ticket_audit_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetAllTicketAuditsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketAudit] { + return &Iterator[TicketAudit]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetAllTicketAuditsOBP, + cbpFunc: z.GetAllTicketAuditsCBP, + } +} + +func (z *Client) GetAllTicketAuditsOBP(ctx context.Context, opts *OBPOptions) ([]TicketAudit, Page, error) { + var data struct { + TicketAudits []TicketAudit `json:"audits"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/ticket_audits.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.TicketAudits, data.Page, nil +} + +func (z *Client) GetAllTicketAuditsCBP(ctx context.Context, opts *CBPOptions) ([]TicketAudit, CursorPaginationMeta, error) { + var data struct { + TicketAudits []TicketAudit `json:"audits"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/ticket_audits.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.TicketAudits, data.Meta, nil +} + diff --git a/zendesk/automation.go b/zendesk/automation.go index c04be55..4538b46 100644 --- a/zendesk/automation.go +++ b/zendesk/automation.go @@ -59,6 +59,9 @@ type AutomationAPI interface { GetAutomation(ctx context.Context, id int64) (Automation, error) UpdateAutomation(ctx context.Context, id int64, automation Automation) (Automation, error) DeleteAutomation(ctx context.Context, id int64) error + GetAutomationsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Automation] + GetAutomationsOBP(ctx context.Context, opts *OBPOptions) ([]Automation, Page, error) + GetAutomationsCBP(ctx context.Context, opts *CBPOptions) ([]Automation, CursorPaginationMeta, error) } // GetAutomations fetch automation list diff --git a/zendesk/automation_generated.go b/zendesk/automation_generated.go new file mode 100644 index 0000000..4d6d92d --- /dev/null +++ b/zendesk/automation_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetAutomationsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Automation] { + return &Iterator[Automation]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetAutomationsOBP, + cbpFunc: z.GetAutomationsCBP, + } +} + +func (z *Client) GetAutomationsOBP(ctx context.Context, opts *OBPOptions) ([]Automation, Page, error) { + var data struct { + Automations []Automation `json:"automations"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/automation.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Automations, data.Page, nil +} + +func (z *Client) GetAutomationsCBP(ctx context.Context, opts *CBPOptions) ([]Automation, CursorPaginationMeta, error) { + var data struct { + Automations []Automation `json:"automations"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/automation.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Automations, data.Meta, nil +} + diff --git a/zendesk/dynamic_content.go b/zendesk/dynamic_content.go index 39fc83a..b94395e 100644 --- a/zendesk/dynamic_content.go +++ b/zendesk/dynamic_content.go @@ -14,6 +14,9 @@ type DynamicContentAPI interface { GetDynamicContentItem(ctx context.Context, id int64) (DynamicContentItem, error) UpdateDynamicContentItem(ctx context.Context, id int64, item DynamicContentItem) (DynamicContentItem, error) DeleteDynamicContentItem(ctx context.Context, id int64) error + GetDynamicContentItemsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[DynamicContentItem] + GetDynamicContentItemsOBP(ctx context.Context, opts *OBPOptions) ([]DynamicContentItem, Page, error) + GetDynamicContentItemsCBP(ctx context.Context, opts *CBPOptions) ([]DynamicContentItem, CursorPaginationMeta, error) } // DynamicContentItem is zendesk dynamic content item JSON payload format diff --git a/zendesk/dynamic_content_generated.go b/zendesk/dynamic_content_generated.go new file mode 100644 index 0000000..f9f7872 --- /dev/null +++ b/zendesk/dynamic_content_generated.go @@ -0,0 +1,64 @@ +package zendesk + +import "context" + +func (z *Client) GetDynamicContentItemsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[DynamicContentItem] { + return &Iterator[DynamicContentItem]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetDynamicContentItemsOBP, + cbpFunc: z.GetDynamicContentItemsCBP, + } +} + +func (z *Client) GetDynamicContentItemsOBP(ctx context.Context, opts *OBPOptions) ([]DynamicContentItem, Page, error) { + var data struct { + DynamicContentItems []DynamicContentItem `json:"items"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/dynamic_content/items.json", tmp) + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.DynamicContentItems, data.Page, nil +} + +func (z *Client) GetDynamicContentItemsCBP(ctx context.Context, opts *CBPOptions) ([]DynamicContentItem, CursorPaginationMeta, error) { + var data struct { + DynamicContentItems []DynamicContentItem `json:"items"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/dynamic_content/items.json", tmp) + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.DynamicContentItems, data.Meta, nil +} + diff --git a/zendesk/group.go b/zendesk/group.go index 1e36230..500039d 100644 --- a/zendesk/group.go +++ b/zendesk/group.go @@ -69,72 +69,6 @@ func (z *Client) GetGroups(ctx context.Context, opts *GroupListOptions) ([]Group return data.Groups, data.Page, nil } -// GetGroupsOBP fetches group list from OBP (Offset Based Pagination) -// https://developer.zendesk.com/rest_api/docs/support/groups#list-groups -func (z *Client) GetGroupsOBP(ctx context.Context, opts *OBPOptions) ([]Group, Page, error) { - var data struct { - Groups []Group `json:"groups"` - Page - } - - tmp := opts - if tmp == nil { - tmp = &OBPOptions{} - } - - u, err := addOptions("/groups.json", tmp) - if err != nil { - return []Group{}, Page{}, err - } - - err = getData(z, ctx, u, &data) - if err != nil { - return []Group{}, Page{}, err - } - return data.Groups, data.Page, nil -} - -// GetGroupsIterator returns an Iterator to iterate over groups -// -// ref: https://developer.zendesk.com/rest_api/docs/support/groups#list-groups -func (z *Client) GetGroupsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Group] { - return &Iterator[Group]{ - pageSize: opts.PageSize, - hasMore: true, - isCBP: opts.IsCBP, - pageAfter: "", - pageIndex: 1, - ctx: ctx, - obpFunc: z.GetGroupsOBP, - cbpFunc: z.GetGroupsCBP, - } -} - -// GetGroupsCBP fetches group list from CBP (Cursor Based Pagination) -// https://developer.zendesk.com/rest_api/docs/support/groups#list-groups -func (z *Client) GetGroupsCBP(ctx context.Context, opts *CBPOptions) ([]Group, CursorPaginationMeta, error) { - var data struct { - Groups []Group `json:"groups"` - Meta CursorPaginationMeta `json:"meta"` - } - - tmp := opts - if tmp == nil { - tmp = &CBPOptions{} - } - - u, err := addOptions("/groups.json", tmp) - if err != nil { - return []Group{}, data.Meta, err - } - - err = getData(z, ctx, u, &data) - if err != nil { - return []Group{}, data.Meta, err - } - return data.Groups, data.Meta, nil -} - // CreateGroup creates new group // https://developer.zendesk.com/rest_api/docs/support/groups#create-group func (z *Client) CreateGroup(ctx context.Context, group Group) (Group, error) { diff --git a/zendesk/group_generated.go b/zendesk/group_generated.go new file mode 100644 index 0000000..eb6e9c7 --- /dev/null +++ b/zendesk/group_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetGroupsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Group] { + return &Iterator[Group]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetGroupsOBP, + cbpFunc: z.GetGroupsCBP, + } +} + +func (z *Client) GetGroupsOBP(ctx context.Context, opts *OBPOptions) ([]Group, Page, error) { + var data struct { + Groups []Group `json:"groups"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/groups.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Groups, data.Page, nil +} + +func (z *Client) GetGroupsCBP(ctx context.Context, opts *CBPOptions) ([]Group, CursorPaginationMeta, error) { + var data struct { + Groups []Group `json:"groups"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/groups.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Groups, data.Meta, nil +} + diff --git a/zendesk/group_membership.go b/zendesk/group_membership.go index 590d0d7..f4e6968 100644 --- a/zendesk/group_membership.go +++ b/zendesk/group_membership.go @@ -31,6 +31,9 @@ type ( // GroupMembershipAPI is an interface containing group membership related methods GroupMembershipAPI interface { GetGroupMemberships(context.Context, *GroupMembershipListOptions) ([]GroupMembership, Page, error) + GetGroupMembershipsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[GroupMembership] + GetGroupMembershipsOBP(ctx context.Context, opts *OBPOptions) ([]GroupMembership, Page, error) + GetGroupMembershipsCBP(ctx context.Context, opts *CBPOptions) ([]GroupMembership, CursorPaginationMeta, error) } ) diff --git a/zendesk/group_membership_generated.go b/zendesk/group_membership_generated.go new file mode 100644 index 0000000..22e58c0 --- /dev/null +++ b/zendesk/group_membership_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetGroupMembershipsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[GroupMembership] { + return &Iterator[GroupMembership]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetGroupMembershipsOBP, + cbpFunc: z.GetGroupMembershipsCBP, + } +} + +func (z *Client) GetGroupMembershipsOBP(ctx context.Context, opts *OBPOptions) ([]GroupMembership, Page, error) { + var data struct { + GroupMemberships []GroupMembership `json:"group_memberships"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/group_memberships.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.GroupMemberships, data.Page, nil +} + +func (z *Client) GetGroupMembershipsCBP(ctx context.Context, opts *CBPOptions) ([]GroupMembership, CursorPaginationMeta, error) { + var data struct { + GroupMemberships []GroupMembership `json:"group_memberships"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/group_memberships.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.GroupMemberships, data.Meta, nil +} + diff --git a/zendesk/iterator.go b/zendesk/iterator.go index 1d8ebb1..7c07e03 100644 --- a/zendesk/iterator.go +++ b/zendesk/iterator.go @@ -32,9 +32,24 @@ type CommonOptions struct { SortBy string `url:"sort_by,omitempty"` // SortOrder can take "asc" or "desc" - SortOrder string `url:"sort_order,omitempty"` - Sort string `url:"sort,omitempty"` - Id int64 + SortOrder string `url:"sort_order,omitempty"` + Sort string `url:"sort,omitempty"` + Id int64 + GroupID int64 `json:"group_id,omitempty" url:"group_id,omitempty"` + UserID int64 `json:"user_id,omitempty" url:"user_id,omitempty"` + OrganizationID int64 `json:"organization_id,omitempty" url:"organization_id,omitempty"` + + Access string `json:"access"` + Category int `json:"category"` + Include string `json:"include" url:"include,omitempty"` + OnlyViewable bool `json:"only_viewable"` + Query string `url:"query"` + EndUserVisible bool `url:"end_user_visible,omitempty"` + FallbackToDefault bool `url:"fallback_to_default,omitempty"` + AssociatedToBrand bool `url:"associated_to_brand,omitempty"` + CategoryID string `url:"category_id,omitempty"` + + IncludeInlineImages string `url:"include_inline_images,omitempty"` } // CBPOptions struct is used to specify options for listing objects in CBP (Cursor Based Pagination). diff --git a/zendesk/macro.go b/zendesk/macro.go index 8982255..8631ba5 100644 --- a/zendesk/macro.go +++ b/zendesk/macro.go @@ -55,6 +55,9 @@ type MacroAPI interface { CreateMacro(ctx context.Context, macro Macro) (Macro, error) UpdateMacro(ctx context.Context, macroID int64, macro Macro) (Macro, error) DeleteMacro(ctx context.Context, macroID int64) error + GetMacrosIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Macro] + GetMacrosOBP(ctx context.Context, opts *OBPOptions) ([]Macro, Page, error) + GetMacrosCBP(ctx context.Context, opts *CBPOptions) ([]Macro, CursorPaginationMeta, error) } // GetMacros get macro list diff --git a/zendesk/macro_generated.go b/zendesk/macro_generated.go new file mode 100644 index 0000000..1579820 --- /dev/null +++ b/zendesk/macro_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetMacrosIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Macro] { + return &Iterator[Macro]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetMacrosOBP, + cbpFunc: z.GetMacrosCBP, + } +} + +func (z *Client) GetMacrosOBP(ctx context.Context, opts *OBPOptions) ([]Macro, Page, error) { + var data struct { + Macros []Macro `json:"macros"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/macros.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Macros, data.Page, nil +} + +func (z *Client) GetMacrosCBP(ctx context.Context, opts *CBPOptions) ([]Macro, CursorPaginationMeta, error) { + var data struct { + Macros []Macro `json:"macros"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/macros.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Macros, data.Meta, nil +} + diff --git a/zendesk/mock/client.go b/zendesk/mock/client.go index 0929ba2..c664718 100644 --- a/zendesk/mock/client.go +++ b/zendesk/mock/client.go @@ -687,6 +687,52 @@ func (mr *ClientMockRecorder) GetAutomations(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAutomations", reflect.TypeOf((*Client)(nil).GetAutomations), ctx, opts) } +// GetAutomationsCBP mocks base method. +func (m *Client) GetAutomationsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.Automation, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAutomationsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Automation) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetAutomationsCBP indicates an expected call of GetAutomationsCBP. +func (mr *ClientMockRecorder) GetAutomationsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAutomationsCBP", reflect.TypeOf((*Client)(nil).GetAutomationsCBP), ctx, opts) +} + +// GetAutomationsIterator mocks base method. +func (m *Client) GetAutomationsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Automation] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAutomationsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.Automation]) + return ret0 +} + +// GetAutomationsIterator indicates an expected call of GetAutomationsIterator. +func (mr *ClientMockRecorder) GetAutomationsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAutomationsIterator", reflect.TypeOf((*Client)(nil).GetAutomationsIterator), ctx, opts) +} + +// GetAutomationsOBP mocks base method. +func (m *Client) GetAutomationsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.Automation, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAutomationsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Automation) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetAutomationsOBP indicates an expected call of GetAutomationsOBP. +func (mr *ClientMockRecorder) GetAutomationsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAutomationsOBP", reflect.TypeOf((*Client)(nil).GetAutomationsOBP), ctx, opts) +} + // GetBrand mocks base method. func (m *Client) GetBrand(ctx context.Context, brandID int64) (zendesk.Brand, error) { m.ctrl.T.Helper() @@ -748,6 +794,52 @@ func (mr *ClientMockRecorder) GetDynamicContentItems(ctx any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDynamicContentItems", reflect.TypeOf((*Client)(nil).GetDynamicContentItems), ctx) } +// GetDynamicContentItemsCBP mocks base method. +func (m *Client) GetDynamicContentItemsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.DynamicContentItem, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDynamicContentItemsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.DynamicContentItem) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetDynamicContentItemsCBP indicates an expected call of GetDynamicContentItemsCBP. +func (mr *ClientMockRecorder) GetDynamicContentItemsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDynamicContentItemsCBP", reflect.TypeOf((*Client)(nil).GetDynamicContentItemsCBP), ctx, opts) +} + +// GetDynamicContentItemsIterator mocks base method. +func (m *Client) GetDynamicContentItemsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.DynamicContentItem] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDynamicContentItemsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.DynamicContentItem]) + return ret0 +} + +// GetDynamicContentItemsIterator indicates an expected call of GetDynamicContentItemsIterator. +func (mr *ClientMockRecorder) GetDynamicContentItemsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDynamicContentItemsIterator", reflect.TypeOf((*Client)(nil).GetDynamicContentItemsIterator), ctx, opts) +} + +// GetDynamicContentItemsOBP mocks base method. +func (m *Client) GetDynamicContentItemsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.DynamicContentItem, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDynamicContentItemsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.DynamicContentItem) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetDynamicContentItemsOBP indicates an expected call of GetDynamicContentItemsOBP. +func (mr *ClientMockRecorder) GetDynamicContentItemsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDynamicContentItemsOBP", reflect.TypeOf((*Client)(nil).GetDynamicContentItemsOBP), ctx, opts) +} + // GetGroup mocks base method. func (m *Client) GetGroup(ctx context.Context, groupID int64) (zendesk.Group, error) { m.ctrl.T.Helper() @@ -779,6 +871,52 @@ func (mr *ClientMockRecorder) GetGroupMemberships(arg0, arg1 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMemberships", reflect.TypeOf((*Client)(nil).GetGroupMemberships), arg0, arg1) } +// GetGroupMembershipsCBP mocks base method. +func (m *Client) GetGroupMembershipsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.GroupMembership, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetGroupMembershipsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.GroupMembership) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetGroupMembershipsCBP indicates an expected call of GetGroupMembershipsCBP. +func (mr *ClientMockRecorder) GetGroupMembershipsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMembershipsCBP", reflect.TypeOf((*Client)(nil).GetGroupMembershipsCBP), ctx, opts) +} + +// GetGroupMembershipsIterator mocks base method. +func (m *Client) GetGroupMembershipsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.GroupMembership] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetGroupMembershipsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.GroupMembership]) + return ret0 +} + +// GetGroupMembershipsIterator indicates an expected call of GetGroupMembershipsIterator. +func (mr *ClientMockRecorder) GetGroupMembershipsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMembershipsIterator", reflect.TypeOf((*Client)(nil).GetGroupMembershipsIterator), ctx, opts) +} + +// GetGroupMembershipsOBP mocks base method. +func (m *Client) GetGroupMembershipsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.GroupMembership, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetGroupMembershipsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.GroupMembership) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetGroupMembershipsOBP indicates an expected call of GetGroupMembershipsOBP. +func (mr *ClientMockRecorder) GetGroupMembershipsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMembershipsOBP", reflect.TypeOf((*Client)(nil).GetGroupMembershipsOBP), ctx, opts) +} + // GetGroups mocks base method. func (m *Client) GetGroups(ctx context.Context, opts *zendesk.GroupListOptions) ([]zendesk.Group, zendesk.Page, error) { m.ctrl.T.Helper() @@ -887,6 +1025,52 @@ func (mr *ClientMockRecorder) GetMacros(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMacros", reflect.TypeOf((*Client)(nil).GetMacros), ctx, opts) } +// GetMacrosCBP mocks base method. +func (m *Client) GetMacrosCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.Macro, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMacrosCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Macro) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetMacrosCBP indicates an expected call of GetMacrosCBP. +func (mr *ClientMockRecorder) GetMacrosCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMacrosCBP", reflect.TypeOf((*Client)(nil).GetMacrosCBP), ctx, opts) +} + +// GetMacrosIterator mocks base method. +func (m *Client) GetMacrosIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Macro] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMacrosIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.Macro]) + return ret0 +} + +// GetMacrosIterator indicates an expected call of GetMacrosIterator. +func (mr *ClientMockRecorder) GetMacrosIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMacrosIterator", reflect.TypeOf((*Client)(nil).GetMacrosIterator), ctx, opts) +} + +// GetMacrosOBP mocks base method. +func (m *Client) GetMacrosOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.Macro, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetMacrosOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Macro) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetMacrosOBP indicates an expected call of GetMacrosOBP. +func (mr *ClientMockRecorder) GetMacrosOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMacrosOBP", reflect.TypeOf((*Client)(nil).GetMacrosOBP), ctx, opts) +} + // GetManyUsers mocks base method. func (m *Client) GetManyUsers(ctx context.Context, opts *zendesk.GetManyUsersOptions) ([]zendesk.User, zendesk.Page, error) { m.ctrl.T.Helper() @@ -965,6 +1149,52 @@ func (mr *ClientMockRecorder) GetOrganizationFields(ctx any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationFields", reflect.TypeOf((*Client)(nil).GetOrganizationFields), ctx) } +// GetOrganizationFieldsCBP mocks base method. +func (m *Client) GetOrganizationFieldsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.OrganizationField, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationFieldsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.OrganizationField) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationFieldsCBP indicates an expected call of GetOrganizationFieldsCBP. +func (mr *ClientMockRecorder) GetOrganizationFieldsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationFieldsCBP", reflect.TypeOf((*Client)(nil).GetOrganizationFieldsCBP), ctx, opts) +} + +// GetOrganizationFieldsIterator mocks base method. +func (m *Client) GetOrganizationFieldsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.OrganizationField] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationFieldsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.OrganizationField]) + return ret0 +} + +// GetOrganizationFieldsIterator indicates an expected call of GetOrganizationFieldsIterator. +func (mr *ClientMockRecorder) GetOrganizationFieldsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationFieldsIterator", reflect.TypeOf((*Client)(nil).GetOrganizationFieldsIterator), ctx, opts) +} + +// GetOrganizationFieldsOBP mocks base method. +func (m *Client) GetOrganizationFieldsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.OrganizationField, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationFieldsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.OrganizationField) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationFieldsOBP indicates an expected call of GetOrganizationFieldsOBP. +func (mr *ClientMockRecorder) GetOrganizationFieldsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationFieldsOBP", reflect.TypeOf((*Client)(nil).GetOrganizationFieldsOBP), ctx, opts) +} + // GetOrganizationMemberships mocks base method. func (m *Client) GetOrganizationMemberships(arg0 context.Context, arg1 *zendesk.OrganizationMembershipListOptions) ([]zendesk.OrganizationMembership, zendesk.Page, error) { m.ctrl.T.Helper() @@ -981,6 +1211,52 @@ func (mr *ClientMockRecorder) GetOrganizationMemberships(arg0, arg1 any) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationMemberships", reflect.TypeOf((*Client)(nil).GetOrganizationMemberships), arg0, arg1) } +// GetOrganizationMembershipsCBP mocks base method. +func (m *Client) GetOrganizationMembershipsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.OrganizationMembership, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationMembershipsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.OrganizationMembership) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationMembershipsCBP indicates an expected call of GetOrganizationMembershipsCBP. +func (mr *ClientMockRecorder) GetOrganizationMembershipsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationMembershipsCBP", reflect.TypeOf((*Client)(nil).GetOrganizationMembershipsCBP), ctx, opts) +} + +// GetOrganizationMembershipsIterator mocks base method. +func (m *Client) GetOrganizationMembershipsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.OrganizationMembership] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationMembershipsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.OrganizationMembership]) + return ret0 +} + +// GetOrganizationMembershipsIterator indicates an expected call of GetOrganizationMembershipsIterator. +func (mr *ClientMockRecorder) GetOrganizationMembershipsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationMembershipsIterator", reflect.TypeOf((*Client)(nil).GetOrganizationMembershipsIterator), ctx, opts) +} + +// GetOrganizationMembershipsOBP mocks base method. +func (m *Client) GetOrganizationMembershipsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.OrganizationMembership, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationMembershipsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.OrganizationMembership) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationMembershipsOBP indicates an expected call of GetOrganizationMembershipsOBP. +func (mr *ClientMockRecorder) GetOrganizationMembershipsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationMembershipsOBP", reflect.TypeOf((*Client)(nil).GetOrganizationMembershipsOBP), ctx, opts) +} + // GetOrganizationTags mocks base method. func (m *Client) GetOrganizationTags(ctx context.Context, organizationID int64) ([]zendesk.Tag, error) { m.ctrl.T.Helper() @@ -1029,17 +1305,17 @@ func (mr *ClientMockRecorder) GetOrganizationTicketsCBP(ctx, opts any) *gomock.C } // GetOrganizationTicketsIterator mocks base method. -func (m *Client) GetOrganizationTicketsIterator(ctx context.Context, organizationID int64, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Ticket] { +func (m *Client) GetOrganizationTicketsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Ticket] { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOrganizationTicketsIterator", ctx, organizationID, opts) + ret := m.ctrl.Call(m, "GetOrganizationTicketsIterator", ctx, opts) ret0, _ := ret[0].(*zendesk.Iterator[zendesk.Ticket]) return ret0 } // GetOrganizationTicketsIterator indicates an expected call of GetOrganizationTicketsIterator. -func (mr *ClientMockRecorder) GetOrganizationTicketsIterator(ctx, organizationID, opts any) *gomock.Call { +func (mr *ClientMockRecorder) GetOrganizationTicketsIterator(ctx, opts any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationTicketsIterator", reflect.TypeOf((*Client)(nil).GetOrganizationTicketsIterator), ctx, organizationID, opts) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationTicketsIterator", reflect.TypeOf((*Client)(nil).GetOrganizationTicketsIterator), ctx, opts) } // GetOrganizationTicketsOBP mocks base method. @@ -1074,6 +1350,52 @@ func (mr *ClientMockRecorder) GetOrganizationUsers(ctx, orgID, opts any) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationUsers", reflect.TypeOf((*Client)(nil).GetOrganizationUsers), ctx, orgID, opts) } +// GetOrganizationUsersCBP mocks base method. +func (m *Client) GetOrganizationUsersCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.User, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationUsersCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.User) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationUsersCBP indicates an expected call of GetOrganizationUsersCBP. +func (mr *ClientMockRecorder) GetOrganizationUsersCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationUsersCBP", reflect.TypeOf((*Client)(nil).GetOrganizationUsersCBP), ctx, opts) +} + +// GetOrganizationUsersIterator mocks base method. +func (m *Client) GetOrganizationUsersIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.User] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationUsersIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.User]) + return ret0 +} + +// GetOrganizationUsersIterator indicates an expected call of GetOrganizationUsersIterator. +func (mr *ClientMockRecorder) GetOrganizationUsersIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationUsersIterator", reflect.TypeOf((*Client)(nil).GetOrganizationUsersIterator), ctx, opts) +} + +// GetOrganizationUsersOBP mocks base method. +func (m *Client) GetOrganizationUsersOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.User, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationUsersOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.User) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationUsersOBP indicates an expected call of GetOrganizationUsersOBP. +func (mr *ClientMockRecorder) GetOrganizationUsersOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationUsersOBP", reflect.TypeOf((*Client)(nil).GetOrganizationUsersOBP), ctx, opts) +} + // GetOrganizations mocks base method. func (m *Client) GetOrganizations(ctx context.Context, opts *zendesk.OrganizationListOptions) ([]zendesk.Organization, zendesk.Page, error) { m.ctrl.T.Helper() @@ -1090,6 +1412,52 @@ func (mr *ClientMockRecorder) GetOrganizations(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizations", reflect.TypeOf((*Client)(nil).GetOrganizations), ctx, opts) } +// GetOrganizationsCBP mocks base method. +func (m *Client) GetOrganizationsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.Organization, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Organization) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationsCBP indicates an expected call of GetOrganizationsCBP. +func (mr *ClientMockRecorder) GetOrganizationsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationsCBP", reflect.TypeOf((*Client)(nil).GetOrganizationsCBP), ctx, opts) +} + +// GetOrganizationsIterator mocks base method. +func (m *Client) GetOrganizationsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Organization] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.Organization]) + return ret0 +} + +// GetOrganizationsIterator indicates an expected call of GetOrganizationsIterator. +func (mr *ClientMockRecorder) GetOrganizationsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationsIterator", reflect.TypeOf((*Client)(nil).GetOrganizationsIterator), ctx, opts) +} + +// GetOrganizationsOBP mocks base method. +func (m *Client) GetOrganizationsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.Organization, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOrganizationsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Organization) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetOrganizationsOBP indicates an expected call of GetOrganizationsOBP. +func (mr *ClientMockRecorder) GetOrganizationsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationsOBP", reflect.TypeOf((*Client)(nil).GetOrganizationsOBP), ctx, opts) +} + // GetSLAPolicies mocks base method. func (m *Client) GetSLAPolicies(ctx context.Context, opts *zendesk.SLAPolicyListOptions) ([]zendesk.SLAPolicy, zendesk.Page, error) { m.ctrl.T.Helper() @@ -1106,6 +1474,52 @@ func (mr *ClientMockRecorder) GetSLAPolicies(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSLAPolicies", reflect.TypeOf((*Client)(nil).GetSLAPolicies), ctx, opts) } +// GetSLAPoliciesCBP mocks base method. +func (m *Client) GetSLAPoliciesCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.SLAPolicy, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSLAPoliciesCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.SLAPolicy) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetSLAPoliciesCBP indicates an expected call of GetSLAPoliciesCBP. +func (mr *ClientMockRecorder) GetSLAPoliciesCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSLAPoliciesCBP", reflect.TypeOf((*Client)(nil).GetSLAPoliciesCBP), ctx, opts) +} + +// GetSLAPoliciesIterator mocks base method. +func (m *Client) GetSLAPoliciesIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.SLAPolicy] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSLAPoliciesIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.SLAPolicy]) + return ret0 +} + +// GetSLAPoliciesIterator indicates an expected call of GetSLAPoliciesIterator. +func (mr *ClientMockRecorder) GetSLAPoliciesIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSLAPoliciesIterator", reflect.TypeOf((*Client)(nil).GetSLAPoliciesIterator), ctx, opts) +} + +// GetSLAPoliciesOBP mocks base method. +func (m *Client) GetSLAPoliciesOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.SLAPolicy, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSLAPoliciesOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.SLAPolicy) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetSLAPoliciesOBP indicates an expected call of GetSLAPoliciesOBP. +func (mr *ClientMockRecorder) GetSLAPoliciesOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSLAPoliciesOBP", reflect.TypeOf((*Client)(nil).GetSLAPoliciesOBP), ctx, opts) +} + // GetSLAPolicy mocks base method. func (m *Client) GetSLAPolicy(ctx context.Context, id int64) (zendesk.SLAPolicy, error) { m.ctrl.T.Helper() @@ -1121,6 +1535,52 @@ func (mr *ClientMockRecorder) GetSLAPolicy(ctx, id any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSLAPolicy", reflect.TypeOf((*Client)(nil).GetSLAPolicy), ctx, id) } +// GetSearchCBP mocks base method. +func (m *Client) GetSearchCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.SearchResults, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSearchCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.SearchResults) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetSearchCBP indicates an expected call of GetSearchCBP. +func (mr *ClientMockRecorder) GetSearchCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSearchCBP", reflect.TypeOf((*Client)(nil).GetSearchCBP), ctx, opts) +} + +// GetSearchIterator mocks base method. +func (m *Client) GetSearchIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.SearchResults] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSearchIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.SearchResults]) + return ret0 +} + +// GetSearchIterator indicates an expected call of GetSearchIterator. +func (mr *ClientMockRecorder) GetSearchIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSearchIterator", reflect.TypeOf((*Client)(nil).GetSearchIterator), ctx, opts) +} + +// GetSearchOBP mocks base method. +func (m *Client) GetSearchOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.SearchResults, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSearchOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.SearchResults) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetSearchOBP indicates an expected call of GetSearchOBP. +func (mr *ClientMockRecorder) GetSearchOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSearchOBP", reflect.TypeOf((*Client)(nil).GetSearchOBP), ctx, opts) +} + // GetTarget mocks base method. func (m *Client) GetTarget(ctx context.Context, ticketID int64) (zendesk.Target, error) { m.ctrl.T.Helper() @@ -1198,6 +1658,98 @@ func (mr *ClientMockRecorder) GetTicketAudits(ctx, ticketID, opts any) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketAudits", reflect.TypeOf((*Client)(nil).GetTicketAudits), ctx, ticketID, opts) } +// GetTicketAuditsCBP mocks base method. +func (m *Client) GetTicketAuditsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.TicketAudit, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketAuditsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketAudit) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketAuditsCBP indicates an expected call of GetTicketAuditsCBP. +func (mr *ClientMockRecorder) GetTicketAuditsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketAuditsCBP", reflect.TypeOf((*Client)(nil).GetTicketAuditsCBP), ctx, opts) +} + +// GetTicketAuditsIterator mocks base method. +func (m *Client) GetTicketAuditsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.TicketAudit] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketAuditsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.TicketAudit]) + return ret0 +} + +// GetTicketAuditsIterator indicates an expected call of GetTicketAuditsIterator. +func (mr *ClientMockRecorder) GetTicketAuditsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketAuditsIterator", reflect.TypeOf((*Client)(nil).GetTicketAuditsIterator), ctx, opts) +} + +// GetTicketAuditsOBP mocks base method. +func (m *Client) GetTicketAuditsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.TicketAudit, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketAuditsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketAudit) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketAuditsOBP indicates an expected call of GetTicketAuditsOBP. +func (mr *ClientMockRecorder) GetTicketAuditsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketAuditsOBP", reflect.TypeOf((*Client)(nil).GetTicketAuditsOBP), ctx, opts) +} + +// GetTicketCommentsCBP mocks base method. +func (m *Client) GetTicketCommentsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.TicketComment, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketCommentsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketComment) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketCommentsCBP indicates an expected call of GetTicketCommentsCBP. +func (mr *ClientMockRecorder) GetTicketCommentsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketCommentsCBP", reflect.TypeOf((*Client)(nil).GetTicketCommentsCBP), ctx, opts) +} + +// GetTicketCommentsIterator mocks base method. +func (m *Client) GetTicketCommentsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.TicketComment] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketCommentsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.TicketComment]) + return ret0 +} + +// GetTicketCommentsIterator indicates an expected call of GetTicketCommentsIterator. +func (mr *ClientMockRecorder) GetTicketCommentsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketCommentsIterator", reflect.TypeOf((*Client)(nil).GetTicketCommentsIterator), ctx, opts) +} + +// GetTicketCommentsOBP mocks base method. +func (m *Client) GetTicketCommentsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.TicketComment, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketCommentsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketComment) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketCommentsOBP indicates an expected call of GetTicketCommentsOBP. +func (mr *ClientMockRecorder) GetTicketCommentsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketCommentsOBP", reflect.TypeOf((*Client)(nil).GetTicketCommentsOBP), ctx, opts) +} + // GetTicketField mocks base method. func (m *Client) GetTicketField(ctx context.Context, ticketID int64) (zendesk.TicketField, error) { m.ctrl.T.Helper() @@ -1229,6 +1781,52 @@ func (mr *ClientMockRecorder) GetTicketFields(ctx any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFields", reflect.TypeOf((*Client)(nil).GetTicketFields), ctx) } +// GetTicketFieldsCBP mocks base method. +func (m *Client) GetTicketFieldsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.TicketField, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketFieldsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketField) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketFieldsCBP indicates an expected call of GetTicketFieldsCBP. +func (mr *ClientMockRecorder) GetTicketFieldsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFieldsCBP", reflect.TypeOf((*Client)(nil).GetTicketFieldsCBP), ctx, opts) +} + +// GetTicketFieldsIterator mocks base method. +func (m *Client) GetTicketFieldsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.TicketField] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketFieldsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.TicketField]) + return ret0 +} + +// GetTicketFieldsIterator indicates an expected call of GetTicketFieldsIterator. +func (mr *ClientMockRecorder) GetTicketFieldsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFieldsIterator", reflect.TypeOf((*Client)(nil).GetTicketFieldsIterator), ctx, opts) +} + +// GetTicketFieldsOBP mocks base method. +func (m *Client) GetTicketFieldsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.TicketField, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketFieldsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketField) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketFieldsOBP indicates an expected call of GetTicketFieldsOBP. +func (mr *ClientMockRecorder) GetTicketFieldsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFieldsOBP", reflect.TypeOf((*Client)(nil).GetTicketFieldsOBP), ctx, opts) +} + // GetTicketForm mocks base method. func (m *Client) GetTicketForm(ctx context.Context, id int64) (zendesk.TicketForm, error) { m.ctrl.T.Helper() @@ -1260,6 +1858,52 @@ func (mr *ClientMockRecorder) GetTicketForms(ctx, options any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketForms", reflect.TypeOf((*Client)(nil).GetTicketForms), ctx, options) } +// GetTicketFormsCBP mocks base method. +func (m *Client) GetTicketFormsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.TicketForm, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketFormsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketForm) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketFormsCBP indicates an expected call of GetTicketFormsCBP. +func (mr *ClientMockRecorder) GetTicketFormsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFormsCBP", reflect.TypeOf((*Client)(nil).GetTicketFormsCBP), ctx, opts) +} + +// GetTicketFormsIterator mocks base method. +func (m *Client) GetTicketFormsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.TicketForm] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketFormsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.TicketForm]) + return ret0 +} + +// GetTicketFormsIterator indicates an expected call of GetTicketFormsIterator. +func (mr *ClientMockRecorder) GetTicketFormsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFormsIterator", reflect.TypeOf((*Client)(nil).GetTicketFormsIterator), ctx, opts) +} + +// GetTicketFormsOBP mocks base method. +func (m *Client) GetTicketFormsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.TicketForm, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketFormsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.TicketForm) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketFormsOBP indicates an expected call of GetTicketFormsOBP. +func (mr *ClientMockRecorder) GetTicketFormsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketFormsOBP", reflect.TypeOf((*Client)(nil).GetTicketFormsOBP), ctx, opts) +} + // GetTicketTags mocks base method. func (m *Client) GetTicketTags(ctx context.Context, ticketID int64) ([]zendesk.Tag, error) { m.ctrl.T.Helper() @@ -1323,6 +1967,52 @@ func (mr *ClientMockRecorder) GetTicketsFromView(arg0, arg1, arg2 any) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketsFromView", reflect.TypeOf((*Client)(nil).GetTicketsFromView), arg0, arg1, arg2) } +// GetTicketsFromViewCBP mocks base method. +func (m *Client) GetTicketsFromViewCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.Ticket, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketsFromViewCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Ticket) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketsFromViewCBP indicates an expected call of GetTicketsFromViewCBP. +func (mr *ClientMockRecorder) GetTicketsFromViewCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketsFromViewCBP", reflect.TypeOf((*Client)(nil).GetTicketsFromViewCBP), ctx, opts) +} + +// GetTicketsFromViewIterator mocks base method. +func (m *Client) GetTicketsFromViewIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Ticket] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketsFromViewIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.Ticket]) + return ret0 +} + +// GetTicketsFromViewIterator indicates an expected call of GetTicketsFromViewIterator. +func (mr *ClientMockRecorder) GetTicketsFromViewIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketsFromViewIterator", reflect.TypeOf((*Client)(nil).GetTicketsFromViewIterator), ctx, opts) +} + +// GetTicketsFromViewOBP mocks base method. +func (m *Client) GetTicketsFromViewOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.Ticket, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTicketsFromViewOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Ticket) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTicketsFromViewOBP indicates an expected call of GetTicketsFromViewOBP. +func (mr *ClientMockRecorder) GetTicketsFromViewOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTicketsFromViewOBP", reflect.TypeOf((*Client)(nil).GetTicketsFromViewOBP), ctx, opts) +} + // GetTicketsIterator mocks base method. func (m *Client) GetTicketsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Ticket] { m.ctrl.T.Helper() @@ -1384,6 +2074,52 @@ func (mr *ClientMockRecorder) GetTriggers(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTriggers", reflect.TypeOf((*Client)(nil).GetTriggers), ctx, opts) } +// GetTriggersCBP mocks base method. +func (m *Client) GetTriggersCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.Trigger, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTriggersCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Trigger) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTriggersCBP indicates an expected call of GetTriggersCBP. +func (mr *ClientMockRecorder) GetTriggersCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTriggersCBP", reflect.TypeOf((*Client)(nil).GetTriggersCBP), ctx, opts) +} + +// GetTriggersIterator mocks base method. +func (m *Client) GetTriggersIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.Trigger] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTriggersIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.Trigger]) + return ret0 +} + +// GetTriggersIterator indicates an expected call of GetTriggersIterator. +func (mr *ClientMockRecorder) GetTriggersIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTriggersIterator", reflect.TypeOf((*Client)(nil).GetTriggersIterator), ctx, opts) +} + +// GetTriggersOBP mocks base method. +func (m *Client) GetTriggersOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.Trigger, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTriggersOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.Trigger) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetTriggersOBP indicates an expected call of GetTriggersOBP. +func (mr *ClientMockRecorder) GetTriggersOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTriggersOBP", reflect.TypeOf((*Client)(nil).GetTriggersOBP), ctx, opts) +} + // GetUser mocks base method. func (m *Client) GetUser(ctx context.Context, userID int64) (zendesk.User, error) { m.ctrl.T.Helper() @@ -1415,6 +2151,52 @@ func (mr *ClientMockRecorder) GetUserFields(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserFields", reflect.TypeOf((*Client)(nil).GetUserFields), ctx, opts) } +// GetUserFieldsCBP mocks base method. +func (m *Client) GetUserFieldsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.UserField, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserFieldsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.UserField) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetUserFieldsCBP indicates an expected call of GetUserFieldsCBP. +func (mr *ClientMockRecorder) GetUserFieldsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserFieldsCBP", reflect.TypeOf((*Client)(nil).GetUserFieldsCBP), ctx, opts) +} + +// GetUserFieldsIterator mocks base method. +func (m *Client) GetUserFieldsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.UserField] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserFieldsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.UserField]) + return ret0 +} + +// GetUserFieldsIterator indicates an expected call of GetUserFieldsIterator. +func (mr *ClientMockRecorder) GetUserFieldsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserFieldsIterator", reflect.TypeOf((*Client)(nil).GetUserFieldsIterator), ctx, opts) +} + +// GetUserFieldsOBP mocks base method. +func (m *Client) GetUserFieldsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.UserField, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserFieldsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.UserField) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetUserFieldsOBP indicates an expected call of GetUserFieldsOBP. +func (mr *ClientMockRecorder) GetUserFieldsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserFieldsOBP", reflect.TypeOf((*Client)(nil).GetUserFieldsOBP), ctx, opts) +} + // GetUserRelated mocks base method. func (m *Client) GetUserRelated(ctx context.Context, userID int64) (zendesk.UserRelated, error) { m.ctrl.T.Helper() @@ -1461,6 +2243,52 @@ func (mr *ClientMockRecorder) GetUsers(ctx, opts any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUsers", reflect.TypeOf((*Client)(nil).GetUsers), ctx, opts) } +// GetUsersCBP mocks base method. +func (m *Client) GetUsersCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.User, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUsersCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.User) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetUsersCBP indicates an expected call of GetUsersCBP. +func (mr *ClientMockRecorder) GetUsersCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUsersCBP", reflect.TypeOf((*Client)(nil).GetUsersCBP), ctx, opts) +} + +// GetUsersIterator mocks base method. +func (m *Client) GetUsersIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.User] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUsersIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.User]) + return ret0 +} + +// GetUsersIterator indicates an expected call of GetUsersIterator. +func (mr *ClientMockRecorder) GetUsersIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUsersIterator", reflect.TypeOf((*Client)(nil).GetUsersIterator), ctx, opts) +} + +// GetUsersOBP mocks base method. +func (m *Client) GetUsersOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.User, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUsersOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.User) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetUsersOBP indicates an expected call of GetUsersOBP. +func (mr *ClientMockRecorder) GetUsersOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUsersOBP", reflect.TypeOf((*Client)(nil).GetUsersOBP), ctx, opts) +} + // GetView mocks base method. func (m *Client) GetView(arg0 context.Context, arg1 int64) (zendesk.View, error) { m.ctrl.T.Helper() @@ -1492,6 +2320,52 @@ func (mr *ClientMockRecorder) GetViews(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetViews", reflect.TypeOf((*Client)(nil).GetViews), arg0) } +// GetViewsCBP mocks base method. +func (m *Client) GetViewsCBP(ctx context.Context, opts *zendesk.CBPOptions) ([]zendesk.View, zendesk.CursorPaginationMeta, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetViewsCBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.View) + ret1, _ := ret[1].(zendesk.CursorPaginationMeta) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetViewsCBP indicates an expected call of GetViewsCBP. +func (mr *ClientMockRecorder) GetViewsCBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetViewsCBP", reflect.TypeOf((*Client)(nil).GetViewsCBP), ctx, opts) +} + +// GetViewsIterator mocks base method. +func (m *Client) GetViewsIterator(ctx context.Context, opts *zendesk.PaginationOptions) *zendesk.Iterator[zendesk.View] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetViewsIterator", ctx, opts) + ret0, _ := ret[0].(*zendesk.Iterator[zendesk.View]) + return ret0 +} + +// GetViewsIterator indicates an expected call of GetViewsIterator. +func (mr *ClientMockRecorder) GetViewsIterator(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetViewsIterator", reflect.TypeOf((*Client)(nil).GetViewsIterator), ctx, opts) +} + +// GetViewsOBP mocks base method. +func (m *Client) GetViewsOBP(ctx context.Context, opts *zendesk.OBPOptions) ([]zendesk.View, zendesk.Page, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetViewsOBP", ctx, opts) + ret0, _ := ret[0].([]zendesk.View) + ret1, _ := ret[1].(zendesk.Page) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetViewsOBP indicates an expected call of GetViewsOBP. +func (mr *ClientMockRecorder) GetViewsOBP(ctx, opts any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetViewsOBP", reflect.TypeOf((*Client)(nil).GetViewsOBP), ctx, opts) +} + // GetWebhook mocks base method. func (m *Client) GetWebhook(ctx context.Context, webhookID string) (*zendesk.Webhook, error) { m.ctrl.T.Helper() diff --git a/zendesk/organization.go b/zendesk/organization.go index 66da2e9..d09bb60 100644 --- a/zendesk/organization.go +++ b/zendesk/organization.go @@ -41,6 +41,9 @@ type OrganizationAPI interface { GetOrganizationByExternalID(ctx context.Context, externalID string) ([]Organization, Page, error) UpdateOrganization(ctx context.Context, orgID int64, org Organization) (Organization, error) DeleteOrganization(ctx context.Context, orgID int64) error + GetOrganizationsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Organization] + GetOrganizationsOBP(ctx context.Context, opts *OBPOptions) ([]Organization, Page, error) + GetOrganizationsCBP(ctx context.Context, opts *CBPOptions) ([]Organization, CursorPaginationMeta, error) } // GetOrganizations fetch organization list diff --git a/zendesk/organization_field.go b/zendesk/organization_field.go index e9ba15b..af8db4c 100644 --- a/zendesk/organization_field.go +++ b/zendesk/organization_field.go @@ -32,6 +32,9 @@ type OrganizationField struct { type OrganizationFieldAPI interface { GetOrganizationFields(ctx context.Context) ([]OrganizationField, Page, error) CreateOrganizationField(ctx context.Context, organizationField OrganizationField) (OrganizationField, error) + GetOrganizationFieldsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[OrganizationField] + GetOrganizationFieldsOBP(ctx context.Context, opts *OBPOptions) ([]OrganizationField, Page, error) + GetOrganizationFieldsCBP(ctx context.Context, opts *CBPOptions) ([]OrganizationField, CursorPaginationMeta, error) } // GetOrganizationFields fetches organization field list diff --git a/zendesk/organization_field_generated.go b/zendesk/organization_field_generated.go new file mode 100644 index 0000000..149847f --- /dev/null +++ b/zendesk/organization_field_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetOrganizationFieldsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[OrganizationField] { + return &Iterator[OrganizationField]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetOrganizationFieldsOBP, + cbpFunc: z.GetOrganizationFieldsCBP, + } +} + +func (z *Client) GetOrganizationFieldsOBP(ctx context.Context, opts *OBPOptions) ([]OrganizationField, Page, error) { + var data struct { + OrganizationFields []OrganizationField `json:"organization_fields"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/organization_fields.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.OrganizationFields, data.Page, nil +} + +func (z *Client) GetOrganizationFieldsCBP(ctx context.Context, opts *CBPOptions) ([]OrganizationField, CursorPaginationMeta, error) { + var data struct { + OrganizationFields []OrganizationField `json:"organization_fields"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/organization_fields.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.OrganizationFields, data.Meta, nil +} + diff --git a/zendesk/organization_generated.go b/zendesk/organization_generated.go new file mode 100644 index 0000000..127ee5b --- /dev/null +++ b/zendesk/organization_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetOrganizationsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Organization] { + return &Iterator[Organization]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetOrganizationsOBP, + cbpFunc: z.GetOrganizationsCBP, + } +} + +func (z *Client) GetOrganizationsOBP(ctx context.Context, opts *OBPOptions) ([]Organization, Page, error) { + var data struct { + Organizations []Organization `json:"organizations"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/organizations.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Organizations, data.Page, nil +} + +func (z *Client) GetOrganizationsCBP(ctx context.Context, opts *CBPOptions) ([]Organization, CursorPaginationMeta, error) { + var data struct { + Organizations []Organization `json:"organizations"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/organizations.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Organizations, data.Meta, nil +} + diff --git a/zendesk/organization_membership.go b/zendesk/organization_membership.go index 4f657cc..24f6980 100644 --- a/zendesk/organization_membership.go +++ b/zendesk/organization_membership.go @@ -41,6 +41,9 @@ type ( GetOrganizationMemberships(context.Context, *OrganizationMembershipListOptions) ([]OrganizationMembership, Page, error) CreateOrganizationMembership(context.Context, OrganizationMembershipOptions) (OrganizationMembership, error) SetDefaultOrganization(context.Context, OrganizationMembershipOptions) (OrganizationMembership, error) + GetOrganizationMembershipsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[OrganizationMembership] + GetOrganizationMembershipsOBP(ctx context.Context, opts *OBPOptions) ([]OrganizationMembership, Page, error) + GetOrganizationMembershipsCBP(ctx context.Context, opts *CBPOptions) ([]OrganizationMembership, CursorPaginationMeta, error) } ) diff --git a/zendesk/organization_membership_generated.go b/zendesk/organization_membership_generated.go new file mode 100644 index 0000000..2e6f60a --- /dev/null +++ b/zendesk/organization_membership_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetOrganizationMembershipsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[OrganizationMembership] { + return &Iterator[OrganizationMembership]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetOrganizationMembershipsOBP, + cbpFunc: z.GetOrganizationMembershipsCBP, + } +} + +func (z *Client) GetOrganizationMembershipsOBP(ctx context.Context, opts *OBPOptions) ([]OrganizationMembership, Page, error) { + var data struct { + OrganizationMemberships []OrganizationMembership `json:"organization_memberships"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/organization_memberships.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.OrganizationMemberships, data.Page, nil +} + +func (z *Client) GetOrganizationMembershipsCBP(ctx context.Context, opts *CBPOptions) ([]OrganizationMembership, CursorPaginationMeta, error) { + var data struct { + OrganizationMemberships []OrganizationMembership `json:"organization_memberships"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/organization_memberships.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.OrganizationMemberships, data.Meta, nil +} + diff --git a/zendesk/organization_tickets_generated.go b/zendesk/organization_tickets_generated.go new file mode 100644 index 0000000..090cf73 --- /dev/null +++ b/zendesk/organization_tickets_generated.go @@ -0,0 +1,79 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import ( + "context" + "fmt" +) + +func (z *Client) GetOrganizationTicketsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Ticket] { + return &Iterator[Ticket]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetOrganizationTicketsOBP, + cbpFunc: z.GetOrganizationTicketsCBP, + } +} + +func (z *Client) GetOrganizationTicketsOBP(ctx context.Context, opts *OBPOptions) ([]Ticket, Page, error) { + var data struct { + Tickets []Ticket `json:"tickets"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + path := fmt.Sprintf("/organizations/%d/tickets.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Tickets, data.Page, nil +} + +func (z *Client) GetOrganizationTicketsCBP(ctx context.Context, opts *CBPOptions) ([]Ticket, CursorPaginationMeta, error) { + var data struct { + Tickets []Ticket `json:"tickets"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + path := fmt.Sprintf("/organizations/%d/tickets.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Tickets, data.Meta, nil +} + diff --git a/zendesk/organization_users_generated.go b/zendesk/organization_users_generated.go new file mode 100644 index 0000000..e9461d6 --- /dev/null +++ b/zendesk/organization_users_generated.go @@ -0,0 +1,79 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import ( + "context" + "fmt" +) + +func (z *Client) GetOrganizationUsersIterator(ctx context.Context, opts *PaginationOptions) *Iterator[User] { + return &Iterator[User]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetOrganizationUsersOBP, + cbpFunc: z.GetOrganizationUsersCBP, + } +} + +func (z *Client) GetOrganizationUsersOBP(ctx context.Context, opts *OBPOptions) ([]User, Page, error) { + var data struct { + Users []User `json:"users"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + path := fmt.Sprintf("/organizations/%d/users.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Users, data.Page, nil +} + +func (z *Client) GetOrganizationUsersCBP(ctx context.Context, opts *CBPOptions) ([]User, CursorPaginationMeta, error) { + var data struct { + Users []User `json:"users"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + path := fmt.Sprintf("/organizations/%d/users.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Users, data.Meta, nil +} + diff --git a/zendesk/search.go b/zendesk/search.go index 576316d..9249730 100644 --- a/zendesk/search.go +++ b/zendesk/search.go @@ -26,6 +26,9 @@ type CountOptions struct { type SearchAPI interface { Search(ctx context.Context, opts *SearchOptions) (SearchResults, Page, error) SearchCount(ctx context.Context, opts *CountOptions) (int, error) + GetSearchIterator(ctx context.Context, opts *PaginationOptions) *Iterator[SearchResults] + GetSearchOBP(ctx context.Context, opts *OBPOptions) ([]SearchResults, Page, error) + GetSearchCBP(ctx context.Context, opts *CBPOptions) ([]SearchResults, CursorPaginationMeta, error) } type SearchResults struct { diff --git a/zendesk/search_generated.go b/zendesk/search_generated.go new file mode 100644 index 0000000..aadb00f --- /dev/null +++ b/zendesk/search_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetSearchIterator(ctx context.Context, opts *PaginationOptions) *Iterator[SearchResults] { + return &Iterator[SearchResults]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetSearchOBP, + cbpFunc: z.GetSearchCBP, + } +} + +func (z *Client) GetSearchOBP(ctx context.Context, opts *OBPOptions) ([]SearchResults, Page, error) { + var data struct { + SearchResultss []SearchResults `json:"results"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/search.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.SearchResultss, data.Page, nil +} + +func (z *Client) GetSearchCBP(ctx context.Context, opts *CBPOptions) ([]SearchResults, CursorPaginationMeta, error) { + var data struct { + SearchResultss []SearchResults `json:"results"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/search.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.SearchResultss, data.Meta, nil +} + diff --git a/zendesk/sla_policy.go b/zendesk/sla_policy.go index ed4c946..a5dd212 100644 --- a/zendesk/sla_policy.go +++ b/zendesk/sla_policy.go @@ -70,6 +70,9 @@ type SLAPolicyAPI interface { GetSLAPolicy(ctx context.Context, id int64) (SLAPolicy, error) UpdateSLAPolicy(ctx context.Context, id int64, slaPolicy SLAPolicy) (SLAPolicy, error) DeleteSLAPolicy(ctx context.Context, id int64) error + GetSLAPoliciesIterator(ctx context.Context, opts *PaginationOptions) *Iterator[SLAPolicy] + GetSLAPoliciesOBP(ctx context.Context, opts *OBPOptions) ([]SLAPolicy, Page, error) + GetSLAPoliciesCBP(ctx context.Context, opts *CBPOptions) ([]SLAPolicy, CursorPaginationMeta, error) } // GetSLAPolicies fetch slaPolicy list diff --git a/zendesk/sla_policy_generated.go b/zendesk/sla_policy_generated.go new file mode 100644 index 0000000..d2c973a --- /dev/null +++ b/zendesk/sla_policy_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetSLAPoliciesIterator(ctx context.Context, opts *PaginationOptions) *Iterator[SLAPolicy] { + return &Iterator[SLAPolicy]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetSLAPoliciesOBP, + cbpFunc: z.GetSLAPoliciesCBP, + } +} + +func (z *Client) GetSLAPoliciesOBP(ctx context.Context, opts *OBPOptions) ([]SLAPolicy, Page, error) { + var data struct { + SLAPolicys []SLAPolicy `json:"sla_policies"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/slas/policies.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.SLAPolicys, data.Page, nil +} + +func (z *Client) GetSLAPoliciesCBP(ctx context.Context, opts *CBPOptions) ([]SLAPolicy, CursorPaginationMeta, error) { + var data struct { + SLAPolicys []SLAPolicy `json:"sla_policies"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/slas/policies.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.SLAPolicys, data.Meta, nil +} + diff --git a/zendesk/ticket.go b/zendesk/ticket.go index 211bab2..c49030d 100644 --- a/zendesk/ticket.go +++ b/zendesk/ticket.go @@ -158,7 +158,7 @@ type TicketAPI interface { GetOrganizationTickets(ctx context.Context, organizationID int64, ops *TicketListOptions) ([]Ticket, Page, error) GetOrganizationTicketsOBP(ctx context.Context, opts *OBPOptions) ([]Ticket, Page, error) GetOrganizationTicketsCBP(ctx context.Context, opts *CBPOptions) ([]Ticket, CursorPaginationMeta, error) - GetOrganizationTicketsIterator(ctx context.Context, organizationID int64, opts *PaginationOptions) *Iterator[Ticket] + GetOrganizationTicketsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Ticket] GetTicket(ctx context.Context, id int64) (Ticket, error) GetMultipleTickets(ctx context.Context, ticketIDs []int64) ([]Ticket, error) CreateTicket(ctx context.Context, ticket Ticket) (Ticket, error) @@ -166,23 +166,6 @@ type TicketAPI interface { DeleteTicket(ctx context.Context, ticketID int64) error } -// GetTicketsIterator returns a TicketIterator to iterate over tickets -// -// ref: https://developer.zendesk.com/rest_api/docs/support/tickets#list-tickets -func (z *Client) GetTicketsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Ticket] { - return &Iterator[Ticket]{ - CommonOptions: opts.CommonOptions, - pageSize: opts.PageSize, - hasMore: true, - isCBP: opts.IsCBP, - pageAfter: "", - pageIndex: 1, - ctx: ctx, - obpFunc: z.GetTicketsOBP, - cbpFunc: z.GetTicketsCBP, - } -} - // GetTickets get ticket list with offset based pagination // // ref: https://developer.zendesk.com/rest_api/docs/support/tickets#list-tickets @@ -214,54 +197,6 @@ func (z *Client) GetTickets(ctx context.Context, opts *TicketListOptions) ([]Tic return data.Tickets, data.Page, nil } -// GetTickets get ticket list with offset based pagination -// -// ref: https://developer.zendesk.com/rest_api/docs/support/tickets#list-tickets -func (z *Client) GetTicketsOBP(ctx context.Context, opts *OBPOptions) ([]Ticket, Page, error) { - var data struct { - Tickets []Ticket `json:"tickets"` - Page - } - - tmp := opts - if tmp == nil { - tmp = &OBPOptions{} - } - - u, err := addOptions("/tickets.json", tmp) - if err != nil { - return nil, Page{}, err - } - - err = getData(z, ctx, u, &data) - if err != nil { - return nil, Page{}, err - } - return data.Tickets, data.Page, nil -} - -// GetTicketsCBP get ticket list with cursor based pagination -// -// ref: https://developer.zendesk.com/rest_api/docs/support/tickets#list-tickets -func (z *Client) GetTicketsCBP(ctx context.Context, opts *CBPOptions) ([]Ticket, CursorPaginationMeta, error) { - var data TicketListCBPResult - - tmp := opts - if tmp == nil { - tmp = &CBPOptions{} - } - - u, err := addOptions("/tickets.json", tmp) - if err != nil { - return nil, data.Meta, err - } - - err = getData(z, ctx, u, &data) - if err != nil { - return nil, data.Meta, err - } - return data.Tickets, data.Meta, nil -} // GetOrganizationTickets get organization ticket list // @@ -292,74 +227,6 @@ func (z *Client) GetOrganizationTickets( return data.Tickets, data.Page, nil } -func (z *Client) GetOrganizationTicketsOBP( - ctx context.Context, opts *OBPOptions, -) ([]Ticket, Page, error) { - var data struct { - Tickets []Ticket `json:"tickets"` - Page - } - - tmp := opts - if tmp == nil { - tmp = &OBPOptions{} - } - - path := fmt.Sprintf("/organizations/%d/tickets.json", tmp.Id) - u, err := addOptions(path, tmp) - if err != nil { - return nil, Page{}, err - } - - err = getData(z, ctx, u, &data) - if err != nil { - return nil, Page{}, err - } - return data.Tickets, data.Page, nil -} - -func (z *Client) GetOrganizationTicketsCBP( - ctx context.Context, opts *CBPOptions, -) ([]Ticket, CursorPaginationMeta, error) { - var data struct { - Tickets []Ticket `json:"tickets"` - Meta CursorPaginationMeta `json:"meta"` - } - - tmp := opts - if tmp == nil { - tmp = &CBPOptions{} - } - - path := fmt.Sprintf("/organizations/%d/tickets.json", tmp.Id) - u, err := addOptions(path, tmp) - if err != nil { - return nil, data.Meta, err - } - - err = getData(z, ctx, u, &data) - if err != nil { - return nil, data.Meta, err - } - return data.Tickets, data.Meta, nil -} - -func (z *Client) GetOrganizationTicketsIterator(ctx context.Context, organizationID int64, opts *PaginationOptions) *Iterator[Ticket] { - commonOpts := opts.CommonOptions - commonOpts.Id = organizationID - return &Iterator[Ticket]{ - CommonOptions: commonOpts, - pageSize: opts.PageSize, - hasMore: true, - isCBP: opts.IsCBP, - pageAfter: "", - pageIndex: 1, - ctx: ctx, - obpFunc: z.GetOrganizationTicketsOBP, - cbpFunc: z.GetOrganizationTicketsCBP, - } -} - // GetTicket gets a specified ticket // // ref: https://developer.zendesk.com/rest_api/docs/support/tickets#show-ticket diff --git a/zendesk/ticket_audit.go b/zendesk/ticket_audit.go index cb661ba..01bdb58 100644 --- a/zendesk/ticket_audit.go +++ b/zendesk/ticket_audit.go @@ -33,6 +33,9 @@ type TicketAuditAPI interface { GetAllTicketAudits(ctx context.Context, opts CursorOption) ([]TicketAudit, Cursor, error) GetTicketAudits(ctx context.Context, ticketID int64, opts PageOptions) ([]TicketAudit, Page, error) GetTicketAudit(ctx context.Context, TicketID, ID int64) (TicketAudit, error) + GetTicketAuditsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketAudit] + GetTicketAuditsOBP(ctx context.Context, opts *OBPOptions) ([]TicketAudit, Page, error) + GetTicketAuditsCBP(ctx context.Context, opts *CBPOptions) ([]TicketAudit, CursorPaginationMeta, error) } // GetAllTicketAudits list all ticket audits diff --git a/zendesk/ticket_audit_generated.go b/zendesk/ticket_audit_generated.go new file mode 100644 index 0000000..b76163b --- /dev/null +++ b/zendesk/ticket_audit_generated.go @@ -0,0 +1,79 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import ( + "context" + "fmt" +) + +func (z *Client) GetTicketAuditsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketAudit] { + return &Iterator[TicketAudit]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTicketAuditsOBP, + cbpFunc: z.GetTicketAuditsCBP, + } +} + +func (z *Client) GetTicketAuditsOBP(ctx context.Context, opts *OBPOptions) ([]TicketAudit, Page, error) { + var data struct { + TicketAudits []TicketAudit `json:"audits"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + path := fmt.Sprintf("/tickets/%d/audits.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.TicketAudits, data.Page, nil +} + +func (z *Client) GetTicketAuditsCBP(ctx context.Context, opts *CBPOptions) ([]TicketAudit, CursorPaginationMeta, error) { + var data struct { + TicketAudits []TicketAudit `json:"audits"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + path := fmt.Sprintf("/tickets/%d/audits.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.TicketAudits, data.Meta, nil +} + diff --git a/zendesk/ticket_comment.go b/zendesk/ticket_comment.go index 9e4bcc3..8790633 100644 --- a/zendesk/ticket_comment.go +++ b/zendesk/ticket_comment.go @@ -12,6 +12,9 @@ type TicketCommentAPI interface { CreateTicketComment(ctx context.Context, ticketID int64, ticketComment TicketComment) (TicketComment, error) ListTicketComments(ctx context.Context, ticketID int64, opts *ListTicketCommentsOptions) (*ListTicketCommentsResult, error) MakeCommentPrivate(ctx context.Context, ticketID int64, ticketCommentID int64) error + GetTicketCommentsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketComment] + GetTicketCommentsOBP(ctx context.Context, opts *OBPOptions) ([]TicketComment, Page, error) + GetTicketCommentsCBP(ctx context.Context, opts *CBPOptions) ([]TicketComment, CursorPaginationMeta, error) } // TicketComment is a struct for ticket comment payload diff --git a/zendesk/ticket_comment_generated.go b/zendesk/ticket_comment_generated.go new file mode 100644 index 0000000..647e1d0 --- /dev/null +++ b/zendesk/ticket_comment_generated.go @@ -0,0 +1,79 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import ( + "context" + "fmt" +) + +func (z *Client) GetTicketCommentsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketComment] { + return &Iterator[TicketComment]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTicketCommentsOBP, + cbpFunc: z.GetTicketCommentsCBP, + } +} + +func (z *Client) GetTicketCommentsOBP(ctx context.Context, opts *OBPOptions) ([]TicketComment, Page, error) { + var data struct { + TicketComments []TicketComment `json:"comments"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + path := fmt.Sprintf("/tickets/%d/comments.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.TicketComments, data.Page, nil +} + +func (z *Client) GetTicketCommentsCBP(ctx context.Context, opts *CBPOptions) ([]TicketComment, CursorPaginationMeta, error) { + var data struct { + TicketComments []TicketComment `json:"comments"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + path := fmt.Sprintf("/tickets/%d/comments.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.TicketComments, data.Meta, nil +} + diff --git a/zendesk/ticket_field.go b/zendesk/ticket_field.go index ab66aed..37a7212 100644 --- a/zendesk/ticket_field.go +++ b/zendesk/ticket_field.go @@ -53,6 +53,9 @@ type TicketFieldAPI interface { GetTicketField(ctx context.Context, ticketID int64) (TicketField, error) UpdateTicketField(ctx context.Context, ticketID int64, field TicketField) (TicketField, error) DeleteTicketField(ctx context.Context, ticketID int64) error + GetTicketFieldsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketField] + GetTicketFieldsOBP(ctx context.Context, opts *OBPOptions) ([]TicketField, Page, error) + GetTicketFieldsCBP(ctx context.Context, opts *CBPOptions) ([]TicketField, CursorPaginationMeta, error) } // GetTicketFields fetches ticket field list diff --git a/zendesk/ticket_field_generated.go b/zendesk/ticket_field_generated.go new file mode 100644 index 0000000..c188ff2 --- /dev/null +++ b/zendesk/ticket_field_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetTicketFieldsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketField] { + return &Iterator[TicketField]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTicketFieldsOBP, + cbpFunc: z.GetTicketFieldsCBP, + } +} + +func (z *Client) GetTicketFieldsOBP(ctx context.Context, opts *OBPOptions) ([]TicketField, Page, error) { + var data struct { + TicketFields []TicketField `json:"ticket_fields"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/ticket_fields.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.TicketFields, data.Page, nil +} + +func (z *Client) GetTicketFieldsCBP(ctx context.Context, opts *CBPOptions) ([]TicketField, CursorPaginationMeta, error) { + var data struct { + TicketFields []TicketField `json:"ticket_fields"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/ticket_fields.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.TicketFields, data.Meta, nil +} + diff --git a/zendesk/ticket_form.go b/zendesk/ticket_form.go index 209f7ef..017f288 100644 --- a/zendesk/ticket_form.go +++ b/zendesk/ticket_form.go @@ -41,6 +41,9 @@ type TicketFormAPI interface { DeleteTicketForm(ctx context.Context, id int64) error UpdateTicketForm(ctx context.Context, id int64, form TicketForm) (TicketForm, error) GetTicketForm(ctx context.Context, id int64) (TicketForm, error) + GetTicketFormsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketForm] + GetTicketFormsOBP(ctx context.Context, opts *OBPOptions) ([]TicketForm, Page, error) + GetTicketFormsCBP(ctx context.Context, opts *CBPOptions) ([]TicketForm, CursorPaginationMeta, error) } // GetTicketForms fetches ticket forms diff --git a/zendesk/ticket_form_generated.go b/zendesk/ticket_form_generated.go new file mode 100644 index 0000000..d193d3a --- /dev/null +++ b/zendesk/ticket_form_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetTicketFormsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[TicketForm] { + return &Iterator[TicketForm]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTicketFormsOBP, + cbpFunc: z.GetTicketFormsCBP, + } +} + +func (z *Client) GetTicketFormsOBP(ctx context.Context, opts *OBPOptions) ([]TicketForm, Page, error) { + var data struct { + TicketForms []TicketForm `json:"ticket_forms"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/ticket_forms.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.TicketForms, data.Page, nil +} + +func (z *Client) GetTicketFormsCBP(ctx context.Context, opts *CBPOptions) ([]TicketForm, CursorPaginationMeta, error) { + var data struct { + TicketForms []TicketForm `json:"ticket_forms"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/ticket_forms.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.TicketForms, data.Meta, nil +} + diff --git a/zendesk/ticket_generated.go b/zendesk/ticket_generated.go new file mode 100644 index 0000000..8adc647 --- /dev/null +++ b/zendesk/ticket_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetTicketsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Ticket] { + return &Iterator[Ticket]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTicketsOBP, + cbpFunc: z.GetTicketsCBP, + } +} + +func (z *Client) GetTicketsOBP(ctx context.Context, opts *OBPOptions) ([]Ticket, Page, error) { + var data struct { + Tickets []Ticket `json:"tickets"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/tickets.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Tickets, data.Page, nil +} + +func (z *Client) GetTicketsCBP(ctx context.Context, opts *CBPOptions) ([]Ticket, CursorPaginationMeta, error) { + var data struct { + Tickets []Ticket `json:"tickets"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/tickets.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Tickets, data.Meta, nil +} + diff --git a/zendesk/ticket_test.go b/zendesk/ticket_test.go index e7bfc2b..69ea2ef 100644 --- a/zendesk/ticket_test.go +++ b/zendesk/ticket_test.go @@ -187,8 +187,8 @@ func TestGetOrganizationTicketsIterator(t *testing.T) { ops := NewPaginationOptions() ops.Sort = "updated_at" ops.PageSize = 10 - - it := client.GetOrganizationTicketsIterator(ctx, 360363695492, ops) + ops.Id = 360363695492 + it := client.GetOrganizationTicketsIterator(ctx, ops) expectedLength := 2 ticketCount := 0 diff --git a/zendesk/tickets_from_view_generated.go b/zendesk/tickets_from_view_generated.go new file mode 100644 index 0000000..9f020a7 --- /dev/null +++ b/zendesk/tickets_from_view_generated.go @@ -0,0 +1,79 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import ( + "context" + "fmt" +) + +func (z *Client) GetTicketsFromViewIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Ticket] { + return &Iterator[Ticket]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTicketsFromViewOBP, + cbpFunc: z.GetTicketsFromViewCBP, + } +} + +func (z *Client) GetTicketsFromViewOBP(ctx context.Context, opts *OBPOptions) ([]Ticket, Page, error) { + var data struct { + Tickets []Ticket `json:"tickets"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + path := fmt.Sprintf("/views/%d/tickets.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Tickets, data.Page, nil +} + +func (z *Client) GetTicketsFromViewCBP(ctx context.Context, opts *CBPOptions) ([]Ticket, CursorPaginationMeta, error) { + var data struct { + Tickets []Ticket `json:"tickets"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + path := fmt.Sprintf("/views/%d/tickets.json", tmp.Id) + u, err := addOptions(path, tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Tickets, data.Meta, nil +} + diff --git a/zendesk/trigger.go b/zendesk/trigger.go index 23ce969..8426a21 100644 --- a/zendesk/trigger.go +++ b/zendesk/trigger.go @@ -61,6 +61,9 @@ type TriggerAPI interface { GetTrigger(ctx context.Context, id int64) (Trigger, error) UpdateTrigger(ctx context.Context, id int64, trigger Trigger) (Trigger, error) DeleteTrigger(ctx context.Context, id int64) error + GetTriggersIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Trigger] + GetTriggersOBP(ctx context.Context, opts *OBPOptions) ([]Trigger, Page, error) + GetTriggersCBP(ctx context.Context, opts *CBPOptions) ([]Trigger, CursorPaginationMeta, error) } // GetTriggers fetch trigger list diff --git a/zendesk/trigger_generated.go b/zendesk/trigger_generated.go new file mode 100644 index 0000000..d0aa967 --- /dev/null +++ b/zendesk/trigger_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetTriggersIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Trigger] { + return &Iterator[Trigger]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetTriggersOBP, + cbpFunc: z.GetTriggersCBP, + } +} + +func (z *Client) GetTriggersOBP(ctx context.Context, opts *OBPOptions) ([]Trigger, Page, error) { + var data struct { + Triggers []Trigger `json:"triggers"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/triggers.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Triggers, data.Page, nil +} + +func (z *Client) GetTriggersCBP(ctx context.Context, opts *CBPOptions) ([]Trigger, CursorPaginationMeta, error) { + var data struct { + Triggers []Trigger `json:"triggers"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/triggers.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Triggers, data.Meta, nil +} + diff --git a/zendesk/user.go b/zendesk/user.go index c61324d..7dacf0e 100644 --- a/zendesk/user.go +++ b/zendesk/user.go @@ -122,6 +122,12 @@ type UserAPI interface { CreateOrUpdateUser(ctx context.Context, user User) (User, error) UpdateUser(ctx context.Context, userID int64, user User) (User, error) GetUserRelated(ctx context.Context, userID int64) (UserRelated, error) + GetUsersIterator(ctx context.Context, opts *PaginationOptions) *Iterator[User] + GetUsersOBP(ctx context.Context, opts *OBPOptions) ([]User, Page, error) + GetUsersCBP(ctx context.Context, opts *CBPOptions) ([]User, CursorPaginationMeta, error) + GetOrganizationUsersIterator(ctx context.Context, opts *PaginationOptions) *Iterator[User] + GetOrganizationUsersOBP(ctx context.Context, opts *OBPOptions) ([]User, Page, error) + GetOrganizationUsersCBP(ctx context.Context, opts *CBPOptions) ([]User, CursorPaginationMeta, error) } // GetUsers fetch user list diff --git a/zendesk/user_field.go b/zendesk/user_field.go index 19f981b..2794232 100644 --- a/zendesk/user_field.go +++ b/zendesk/user_field.go @@ -33,6 +33,9 @@ type UserFieldListOptions struct { type UserFieldAPI interface { GetUserFields(ctx context.Context, opts *UserFieldListOptions) ([]UserField, Page, error) CreateUserField(ctx context.Context, userField UserField) (UserField, error) + GetUserFieldsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[UserField] + GetUserFieldsOBP(ctx context.Context, opts *OBPOptions) ([]UserField, Page, error) + GetUserFieldsCBP(ctx context.Context, opts *CBPOptions) ([]UserField, CursorPaginationMeta, error) } // GetUserFields fetch trigger list diff --git a/zendesk/user_field_generated.go b/zendesk/user_field_generated.go new file mode 100644 index 0000000..570c36a --- /dev/null +++ b/zendesk/user_field_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetUserFieldsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[UserField] { + return &Iterator[UserField]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetUserFieldsOBP, + cbpFunc: z.GetUserFieldsCBP, + } +} + +func (z *Client) GetUserFieldsOBP(ctx context.Context, opts *OBPOptions) ([]UserField, Page, error) { + var data struct { + UserFields []UserField `json:"user_fields"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/user_fields.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.UserFields, data.Page, nil +} + +func (z *Client) GetUserFieldsCBP(ctx context.Context, opts *CBPOptions) ([]UserField, CursorPaginationMeta, error) { + var data struct { + UserFields []UserField `json:"user_fields"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/user_fields.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.UserFields, data.Meta, nil +} + diff --git a/zendesk/user_generated.go b/zendesk/user_generated.go new file mode 100644 index 0000000..98b95df --- /dev/null +++ b/zendesk/user_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetUsersIterator(ctx context.Context, opts *PaginationOptions) *Iterator[User] { + return &Iterator[User]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetUsersOBP, + cbpFunc: z.GetUsersCBP, + } +} + +func (z *Client) GetUsersOBP(ctx context.Context, opts *OBPOptions) ([]User, Page, error) { + var data struct { + Users []User `json:"users"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/users.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Users, data.Page, nil +} + +func (z *Client) GetUsersCBP(ctx context.Context, opts *CBPOptions) ([]User, CursorPaginationMeta, error) { + var data struct { + Users []User `json:"users"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/users.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Users, data.Meta, nil +} + diff --git a/zendesk/view.go b/zendesk/view.go index ad32a14..e61637d 100644 --- a/zendesk/view.go +++ b/zendesk/view.go @@ -29,6 +29,12 @@ type ( GetView(context.Context, int64) (View, error) GetViews(context.Context) ([]View, Page, error) GetTicketsFromView(context.Context, int64, *TicketListOptions) ([]Ticket, Page, error) + GetTicketsFromViewIterator(ctx context.Context, opts *PaginationOptions) *Iterator[Ticket] + GetTicketsFromViewOBP(ctx context.Context, opts *OBPOptions) ([]Ticket, Page, error) + GetTicketsFromViewCBP(ctx context.Context, opts *CBPOptions) ([]Ticket, CursorPaginationMeta, error) + GetViewsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[View] + GetViewsOBP(ctx context.Context, opts *OBPOptions) ([]View, Page, error) + GetViewsCBP(ctx context.Context, opts *CBPOptions) ([]View, CursorPaginationMeta, error) } ) diff --git a/zendesk/view_generated.go b/zendesk/view_generated.go new file mode 100644 index 0000000..3f7425a --- /dev/null +++ b/zendesk/view_generated.go @@ -0,0 +1,74 @@ + +// Code generated by Script. DO NOT EDIT. +// Source: script/codegen/main.go +// +// Generated by this command: +// +// go run script/codegen/main.go + +package zendesk + +import "context" + +func (z *Client) GetViewsIterator(ctx context.Context, opts *PaginationOptions) *Iterator[View] { + return &Iterator[View]{ + CommonOptions: opts.CommonOptions, + pageSize: opts.PageSize, + hasMore: true, + isCBP: opts.IsCBP, + pageAfter: "", + pageIndex: 1, + ctx: ctx, + obpFunc: z.GetViewsOBP, + cbpFunc: z.GetViewsCBP, + } +} + +func (z *Client) GetViewsOBP(ctx context.Context, opts *OBPOptions) ([]View, Page, error) { + var data struct { + Views []View `json:"views"` + Page + } + + tmp := opts + if tmp == nil { + tmp = &OBPOptions{} + } + + u, err := addOptions("/views.json", tmp) + + if err != nil { + return nil, Page{}, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, Page{}, err + } + return data.Views, data.Page, nil +} + +func (z *Client) GetViewsCBP(ctx context.Context, opts *CBPOptions) ([]View, CursorPaginationMeta, error) { + var data struct { + Views []View `json:"views"` + Meta CursorPaginationMeta `json:"meta"` + } + + tmp := opts + if tmp == nil { + tmp = &CBPOptions{} + } + + u, err := addOptions("/views.json", tmp) + + if err != nil { + return nil, data.Meta, err + } + + err = getData(z, ctx, u, &data) + if err != nil { + return nil, data.Meta, err + } + return data.Views, data.Meta, nil +} +