Skip to content

Consolidate the various approaches for making custom calls to the Genesys Cloud API apart from the SDK Client into a single Custom API Client library.#2204

Open
bbbco wants to merge 1 commit intoMyPureCloud:devfrom
bbbco:feature/consolidate_custom_api_client
Open

Consolidate the various approaches for making custom calls to the Genesys Cloud API apart from the SDK Client into a single Custom API Client library.#2204
bbbco wants to merge 1 commit intoMyPureCloud:devfrom
bbbco:feature/consolidate_custom_api_client

Conversation

@bbbco
Copy link
Contributor

@bbbco bbbco commented Mar 15, 2026

Introduces a shared custom_api_client package that wraps the SDK's APIClient.CallAPI() method, then migrates all proxy files that were making direct CallAPI or raw http.Client calls to
use it. This eliminates ~1,400 lines of duplicated boilerplate (authorization headers, content-type negotiation, query parameter encoding, error handling, JSON unmarshaling) across 21
files.

Motivation

Proxy files that needed to call API endpoints without generated SDK methods were each independently constructing HTTP requests — building auth headers, setting content types, encoding query params, handling errors, and unmarshaling responses. This was error-prone, inconsistent, and created a maintenance burden. Some files used APIClient.CallAPI() directly, others used raw net/http.Client, and each had slightly different error handling.

What's included

New package: genesyscloud/custom_api_client/

  • Client struct with callAPIAttr function attribute (same pattern as proxy files for testability)
  • Do[T] — generic typed JSON response
  • DoNoResponse — for DELETE / PUT with no return body
  • DoRaw — raw []byte response for custom unmarshaling
  • DoWithAcceptHeader — custom Accept header (e.g., text/csv)
  • QueryParams type alias (url.Values) + NewQueryParams() helper
  • Method constants (MethodGet, MethodPost, MethodPut, MethodPatch, MethodDelete)
  • 19 unit tests using mocked function attribute injection

Migrated files (21 files across 16 packages):

Package Files Pattern replaced
process_automation_trigger proxy + data source CallAPI ×4, pagination fixed to relative paths
architect_datatable proxy CallAPI ×2
architect_datatable_row proxy CallAPI ×1
integration_action proxy CallAPI ×4 (upload function untouched)
scripts proxy CallAPI ×1 + http.Client ×1
guide proxy + utils http.Client (6 helper functions deleted)
guide_version proxy + utils http.Client (utils file deleted)
recording_media_retention_policy proxy CallAPI ×1
knowledge_document proxy CallAPI ×1
telephony_providers_edges_trunkbasesettings proxy CallAPI ×1
business_rules_schema proxy CallAPI ×1
task_management_workitem_schema proxy CallAPI ×1
task_management_worktype_status_transition proxy CallAPI ×1
external_user proxy CallAPI ×1
architect_flow proxy http.Client (makeFlowRequest deleted)
user utils CallAPI ×2 (buildHeaderParams deleted)
routing_queue members CallAPI ×1

Documentation:

  • Package-level Go doc with usage examples, when to use / not use, query param patterns
  • New "Custom API Client" section added to README.md under developer guidance

What was NOT changed

  • S3 upload logic (scripts, architect_grammar_language, architect_user_prompt, responsemanagement_responseasset)
  • Integration action upload function (presigned URL flow)
  • Schema, CRUD, or test files
  • Proxy function attribute signatures (only internal implementations changed)
  • Any proxy already using SDK methods properly

…esys Cloud API apart from the SDK Client into a single Custom API Client library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant