Skip to content

Commit

Permalink
Merge pull request #255 from dzakaammar/org-by-external-id-interface
Browse files Browse the repository at this point in the history
feat: add get organization by external id to OrganizationAPI interface
  • Loading branch information
nukosuke authored Feb 8, 2023
2 parents 74f90f9 + 19cbed2 commit 07504b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 16 additions & 0 deletions zendesk/mock/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions zendesk/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type OrganizationAPI interface {
GetOrganizations(ctx context.Context, opts *OrganizationListOptions) ([]Organization, Page, error)
CreateOrganization(ctx context.Context, org Organization) (Organization, error)
GetOrganization(ctx context.Context, orgID int64) (Organization, error)
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
}
Expand Down Expand Up @@ -103,7 +104,6 @@ func (z *Client) GetOrganization(ctx context.Context, orgID int64) (Organization
}

body, err := z.get(ctx, fmt.Sprintf("/organizations/%d.json", orgID))

if err != nil {
return Organization{}, err
}
Expand All @@ -125,7 +125,6 @@ func (z *Client) GetOrganizationByExternalID(ctx context.Context, externalID str
}

body, err := z.get(ctx, fmt.Sprintf("/organizations/search?external_id=%s", externalID))

if err != nil {
return []Organization{}, Page{}, err
}
Expand All @@ -148,7 +147,6 @@ func (z *Client) UpdateOrganization(ctx context.Context, orgID int64, org Organi
data.Organization = org

body, err := z.put(ctx, fmt.Sprintf("/organizations/%d.json", orgID), data)

if err != nil {
return Organization{}, err
}
Expand All @@ -165,7 +163,6 @@ func (z *Client) UpdateOrganization(ctx context.Context, orgID int64, org Organi
// ref: https://developer.zendesk.com/rest_api/docs/support/organizations#delete-organization
func (z *Client) DeleteOrganization(ctx context.Context, orgID int64) error {
err := z.delete(ctx, fmt.Sprintf("/organizations/%d.json", orgID))

if err != nil {
return err
}
Expand Down

0 comments on commit 07504b5

Please sign in to comment.