API Client
The application makes almost no hand-written HTTP calls. Backend access goes
through @payability/pyb-ng2-api, a private package published to GitHub Packages
that ships typed services, DTOs, models and enums for the Payability APIs.
Package |
|
Registry |
GitHub Packages ( |
Module |
|
Surface |
~44 service files under |
Because it is a separate package, its internals are documented by its own component in the central Antora site. This page documents how this application consumes it.
Registration
AppModule configures the client once, from the generated environment:
PybApiModule.forRoot({
baseUrl: environment.apiUrl,
marketplaceUrl: environment.marketplaceUrl,
frontendActionsToolsApiUrl: environment.frontendActionsToolsApiUrl,
b2bDocumentUrl: environment.b2bDocumentUrl,
gci: environment.gci,
frontendTaskManager: environment.frontendTaskManager,
documentsApiUrl: environment.apiUrl, (1)
}),
| 1 | Documents share the main API host; the config field exists so they can be split later. |
The config shape is ApiServiceConfig:
export interface ApiServiceConfig {
baseUrl: string;
marketplaceUrl: string;
frontendActionsToolsApiUrl: string;
b2bDocumentUrl: string;
documentsApiUrl?: string;
frontendTaskManager: string;
gci: string;
cloudWatchApiUrl?: string;
}
Each value becomes a DI token that the generated services inject:
|
The main supplier API. |
|
Marketplace web API — connection health, invites, credentials. |
|
Frontend actions tools. |
|
Document upload and retrieval. |
|
Task manager. |
|
The |
|
Metrics endpoint. Not passed here; |
cloudWatchApiUrl is deliberately absent
|
|
|
EnvironmentService
src/environments/environment.service.ts is the type for the generated
environment object, and is also provided so it can be injected:
@Injectable()
export class EnvironmentService {
env?: string;
version?: string;
buildTime?: string;
production: boolean;
isMockEnabled: boolean;
authTokenKey: string;
airwalexBaseUrl: string;
apiUrl: string;
authUrl: string;
gci: string;
frontendTaskManager: string;
marketplaceUrl: string;
frontendActionsToolsApiUrl: string;
b2bDocumentUrl: string;
tabapayUrl: string;
agGridLicenseKey: string;
segmentKey: string;
referralUrl: string;
marquetaSandbox: boolean;
plaidSandbox: boolean;
cloudWatchApiUrl: string;
zendeskWidgetUrl: string;
zendeskWidgetKey: string;
recaptchaKey: string;
smartLookKey: string;
}
Injecting EnvironmentService is preferred over importing the environment
constant, because it is mockable in tests. Roughly two dozen services do so.
|
Adding a setting means touching four places, or the build breaks or silently ships an empty string:
|
authUrl and airwalexBaseUrl are not passed to PybApiModule — they are used
directly by AuthService and AirwallexCardService, which build their own
requests.
Service catalog
The generated services this application actually imports, grouped by area. Names
are the exported classes; files live in lib/services/.
Supplier and account
|
Supplier details, status, account creation, available payment methods. The most-used service in the app. |
|
Pre-activation status, |
|
Pre-submission step state. |
|
Business profile reference data. |
|
Shipping address for physical cards. |
|
Geographic reference data. |
|
Compliance records and required actions. |
|
Document upload, listing, retrieval. |
|
Login history. |
|
Authenticated password change. |
|
The server-driven announcement banner. |
|
Dashboard-version feedback and switching. |
|
Deactivation. Cancellation & Reactivation |
Money and products
|
Available balance. |
|
Advance Line summary, offers, withdrawals. Advance Line |
|
Product offering availability. Product Offerings |
|
The dashboard product summary. |
|
Payout methods ( |
|
Transfer requests. |
|
The fee schedule behind the |
|
Punch-card rewards. |
|
Open invoices. |
|
Month-end close state. |
|
Vendor Pay outgoing payments. Vendor Pay |
Cards and banking
|
Seller Card issuance, activation, reveal. Marqeta & Airwallex |
|
Card transaction report. |
|
Link token exchange. Plaid |
|
Routing/SWIFT verification — used as an async validator. Forms, Fields and Validation |
Marketplaces
|
Supplier marketplaces, invites, credentials. |
|
Amazon-specific connection operations. Marketplace API Connectors |
Contracts
|
One URL-generating method per flow — |
Reports
|
Daily summary. |
|
Transfers. |
|
Marketplace payments and transaction details. |
|
Fees. |
|
Advance report. |
|
Reconciliation view. |
|
Commitment overview. |
|
Export and statement generation. |
Report data is consumed through the datasource layer rather than called directly from components — see Reports.
Infrastructure
|
Task manager operations. |
|
Dashboard notification operations, under |
|
B2B document API. |
|
Server-side Segment helpers. The client uses |
|
Present in the package, but the app uses its own |
Full local service inventory: Service Catalog.
Request lifecycle
Every generated-service call goes through the same chain, because there is one
HttpClient:
SomeApiService.method(args)
→ HttpClient
→ AuthInterceptor adds Authorization / session headers
→ UnauthorizedInterceptor 401 → logout + redirect
→ HttpErrorHandlerInterceptor toasts, special-cases ACCOUNT_LOCKED
→ response (typed DTO)
Details in HTTP Interceptors. The practical consequence: never add auth headers or error toasts at the call site. The interceptors already did it.
Calls that bypass the generated client
Twelve services build requests with HttpClient directly. They are not mistakes
in every case, but each is a place where a URL is assembled by hand:
| Service | Why |
|---|---|
|
Targets |
|
Targets |
|
Entrust session creation. Entrust Identity |
|
Own module and own URL token. Observability |
|
CMS endpoint, outside the supplier API. |
|
Email preference endpoints not yet in the package. |
|
Predates |
|
|
|
Widget-local transfer call. |
|
Report endpoints assembled locally alongside their column configs. |
|
When to add a raw call
Prefer extending |
Mocking in tests
Generated services are mocked like any other provider, following the
<Resource>ServiceMock convention. See Testing.
Related pages
-
Model Reference — the local models DTOs are mapped into
-
Service Catalog — the in-repo services that wrap these
-
Local Setup — registry auth and environment generation