Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 70 additions & 97 deletions ballerina/client.bal
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// AUTO-GENERATED FILE. DO NOT MODIFY.
// This file is auto-generated by the Ballerina OpenAPI tool.

// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
Expand All @@ -22,92 +19,70 @@ import ballerina/http;
public isolated client class Client {
final http:Client clientEp;
final readonly & ApiKeysConfig? apiKeyConfig;

# Gets invoked to initialize the `connector`.
#
# + config - The configurations to be used when initializing the `connector`
# + serviceUrl - URL of the target service
# + return - An error if connector initialization failed
public isolated function init(ConnectionConfig config, string serviceUrl = "https://api.hubapi.com/crm/v3/objects/contacts") returns error? {
http:ClientConfiguration httpClientConfig = {httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation};
do {
if config.http1Settings is ClientHttp1Settings {
ClientHttp1Settings settings = check config.http1Settings.ensureType(ClientHttp1Settings);
httpClientConfig.http1Settings = {...settings};
}
if config.http2Settings is http:ClientHttp2Settings {
httpClientConfig.http2Settings = check config.http2Settings.ensureType(http:ClientHttp2Settings);
}
if config.cache is http:CacheConfig {
httpClientConfig.cache = check config.cache.ensureType(http:CacheConfig);
}
if config.responseLimits is http:ResponseLimitConfigs {
httpClientConfig.responseLimits = check config.responseLimits.ensureType(http:ResponseLimitConfigs);
}
if config.secureSocket is http:ClientSecureSocket {
httpClientConfig.secureSocket = check config.secureSocket.ensureType(http:ClientSecureSocket);
}
if config.proxy is http:ProxyConfig {
httpClientConfig.proxy = check config.proxy.ensureType(http:ProxyConfig);
}
}
http:ClientConfiguration httpClientConfig = {httpVersion: config.httpVersion, http1Settings: config.http1Settings, http2Settings: config.http2Settings, timeout: config.timeout, forwarded: config.forwarded, followRedirects: config.followRedirects, poolConfig: config.poolConfig, cache: config.cache, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, cookieConfig: config.cookieConfig, responseLimits: config.responseLimits, secureSocket: config.secureSocket, proxy: config.proxy, socketConfig: config.socketConfig, validation: config.validation, laxDataBinding: config.laxDataBinding};
if config.auth is ApiKeysConfig {
self.apiKeyConfig = (<ApiKeysConfig>config.auth).cloneReadOnly();
} else {
httpClientConfig.auth = <http:BearerTokenConfig|OAuth2RefreshTokenGrantConfig>config.auth;
self.apiKeyConfig = ();
}
http:Client httpEp = check new (serviceUrl, httpClientConfig);
self.clientEp = httpEp;
return;
self.clientEp = check new (serviceUrl, httpClientConfig);
}

# Archive
# Read a batch of contacts by internal ID, or unique property values
#
# + headers - Headers to be sent with the request
# + return - No content
resource isolated function delete [string contactId](map<string|string[]> headers = {}) returns http:Response|error {
string resourcePath = string `/${getEncodedUri(contactId)}`;
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function post batch/read(BatchReadInputSimplePublicObjectId payload, map<string|string[]> headers = {}, *PostCrmV3ObjectsContactsBatchReadReadQueries queries) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/batch/read`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
return self.clientEp->delete(resourcePath, headers = httpHeaders);
resourcePath = resourcePath + check getPathForQueryParam(queries);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# List
# Read
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function get .(map<string|string[]> headers = {}, *ReadPageOfContactsQueries queries) returns CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error {
string resourcePath = string `/`;
resource isolated function get [string contactId](map<string|string[]> headers = {}, *GetCrmV3ObjectsContactsContactIdGetByIdQueries queries) returns SimplePublicObjectWithAssociations|error {
string resourcePath = string `/${getEncodedUri(contactId)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<Encoding> queryParamEncoding = {"properties": {style: FORM, explode: true}, "propertiesWithHistory": {style: FORM, explode: true}, "associations": {style: FORM, explode: true}};
resourcePath = resourcePath + check getPathForQueryParam(queries, queryParamEncoding);
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
return self.clientEp->get(resourcePath, httpHeaders);
}

# Read
# Archive
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function get [string contactId](map<string|string[]> headers = {}, *ReadContactByIdQueries queries) returns SimplePublicObjectWithAssociations|error {
# + return - No content
resource isolated function delete [string contactId](map<string|string[]> headers = {}) returns error? {
string resourcePath = string `/${getEncodedUri(contactId)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<Encoding> queryParamEncoding = {"properties": {style: FORM, explode: true}, "propertiesWithHistory": {style: FORM, explode: true}, "associations": {style: FORM, explode: true}};
resourcePath = resourcePath + check getPathForQueryParam(queries, queryParamEncoding);
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
return self.clientEp->get(resourcePath, httpHeaders);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
return self.clientEp->delete(resourcePath, headers = httpHeaders);
}

# Update
Expand All @@ -118,26 +93,26 @@ public isolated client class Client {
string resourcePath = string `/${getEncodedUri(contactId)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->patch(resourcePath, request, httpHeaders);
}

# Create
# Merge two contacts with same type
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post .(SimplePublicObjectInputForCreate payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/`;
resource isolated function post merge(PublicMergeInput payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/merge`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
Expand All @@ -148,13 +123,13 @@ public isolated client class Client {
#
# + headers - Headers to be sent with the request
# + return - No content
resource isolated function post batch/archive(BatchInputSimplePublicObjectId payload, map<string|string[]> headers = {}) returns http:Response|error {
resource isolated function post batch/archive(BatchInputSimplePublicObjectId payload, map<string|string[]> headers = {}) returns error? {
string resourcePath = string `/batch/archive`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
Expand All @@ -169,92 +144,90 @@ public isolated client class Client {
string resourcePath = string `/batch/create`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Read a batch of contacts by internal ID, or unique property values
# Update a batch of contacts by internal ID, or unique property values
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function post batch/read(BatchReadInputSimplePublicObjectId payload, map<string|string[]> headers = {}, *ReadBatchOfContactsByInternalIdOrUniquePropertyValuesQueries queries) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/batch/read`;
resource isolated function post batch/update(BatchInputSimplePublicObjectBatchInput payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/batch/update`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
resourcePath = resourcePath + check getPathForQueryParam(queries);
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Update a batch of contacts by internal ID, or unique property values
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post batch/update(BatchInputSimplePublicObjectBatchInput payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/batch/update`;
resource isolated function post gdpr\-delete(PublicGdprDeleteInput payload, map<string|string[]> headers = {}) returns error? {
string resourcePath = string `/gdpr-delete`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Create or update a batch of contacts by unique property values
# List
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function post batch/upsert(BatchInputSimplePublicObjectBatchInputUpsert payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error {
string resourcePath = string `/batch/upsert`;
resource isolated function get .(map<string|string[]> headers = {}, *GetCrmV3ObjectsContactsGetPageQueries queries) returns CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error {
string resourcePath = string `/`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
map<Encoding> queryParamEncoding = {"properties": {style: FORM, explode: true}, "propertiesWithHistory": {style: FORM, explode: true}, "associations": {style: FORM, explode: true}};
resourcePath = resourcePath + check getPathForQueryParam(queries, queryParamEncoding);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
return self.clientEp->get(resourcePath, httpHeaders);
}

resource isolated function post gdpr\-delete(PublicGdprDeleteInput payload, map<string|string[]> headers = {}) returns http:Response|error {
string resourcePath = string `/gdpr-delete`;
# Create
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post .(SimplePublicObjectInputForCreate payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Merge two contacts with same type
# Create or update a batch of contacts by unique property values
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post merge(PublicMergeInput payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/merge`;
resource isolated function post batch/upsert(BatchInputSimplePublicObjectBatchInputUpsert payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error {
string resourcePath = string `/batch/upsert`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
Expand All @@ -267,9 +240,9 @@ public isolated client class Client {
string resourcePath = string `/search`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
map<string|string[]> httpHeaders = getMapForHeaders(headerValues);
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
http:Request request = new;
json jsonBody = payload.toJson();
request.setPayload(jsonBody, "application/json");
Expand Down
Loading
Loading