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
174 changes: 77 additions & 97 deletions ballerina/client.bal
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
// AUTO-GENERATED FILE. DO NOT MODIFY.
// This file is auto-generated by the Ballerina OpenAPI tool.

// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
Expand All @@ -14,131 +17,110 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/data.jsondata;
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") 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 companies by internal ID, or unique property values
#
# + headers - Headers to be sent with the request
# + return - No content
resource isolated function delete companies/[string companyId](map<string|string[]> headers = {}) returns http:Response|error {
string resourcePath = string `/companies/${getEncodedUri(companyId)}`;
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function post companies/batch/read(BatchReadInputSimplePublicObjectId payload, map<string|string[]> headers = {}, *PostCrmV3ObjectsCompaniesBatchReadReadQueries queries) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/companies/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 = jsondata:toJson(payload);
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 companies(map<string|string[]> headers = {}, *GetCrmV3ObjectsCompanies_getpageQueries queries) returns CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error {
string resourcePath = string `/companies`;
resource isolated function get companies/[string companyId](map<string|string[]> headers = {}, *GetCrmV3ObjectsCompaniesCompanyIdGetByIdQueries queries) returns SimplePublicObjectWithAssociations|error {
string resourcePath = string `/companies/${getEncodedUri(companyId)}`;
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 companies/[string companyId](map<string|string[]> headers = {}, *GetCrmV3ObjectsCompaniesCompanyid_getbyidQueries queries) returns SimplePublicObjectWithAssociations|error {
# + return - No content
resource isolated function delete companies/[string companyId](map<string|string[]> headers = {}) returns error? {
string resourcePath = string `/companies/${getEncodedUri(companyId)}`;
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
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function patch companies/[string companyId](SimplePublicObjectInput payload, map<string|string[]> headers = {}, *PatchCrmV3ObjectsCompaniesCompanyid_updateQueries queries) returns SimplePublicObject|error {
resource isolated function patch companies/[string companyId](SimplePublicObjectInput payload, map<string|string[]> headers = {}, *PatchCrmV3ObjectsCompaniesCompanyIdUpdateQueries queries) returns SimplePublicObject|error {
string resourcePath = string `/companies/${getEncodedUri(companyId)}`;
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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->patch(resourcePath, request, httpHeaders);
}

# Create
# Merge two companies with same type
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post companies(SimplePublicObjectInputForCreate payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/companies`;
resource isolated function post companies/merge(PublicMergeInput payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/companies/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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}
Expand All @@ -147,15 +129,15 @@ public isolated client class Client {
#
# + headers - Headers to be sent with the request
# + return - No content
resource isolated function post companies/batch/archive(BatchInputSimplePublicObjectId payload, map<string|string[]> headers = {}) returns http:Response|error {
resource isolated function post companies/batch/archive(BatchInputSimplePublicObjectId payload, map<string|string[]> headers = {}) returns error? {
string resourcePath = string `/companies/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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}
Expand All @@ -168,81 +150,79 @@ public isolated client class Client {
string resourcePath = string `/companies/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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Read a batch of companies by internal ID, or unique property values
# Update a batch of companies 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 companies/batch/read(BatchReadInputSimplePublicObjectId payload, map<string|string[]> headers = {}, *PostCrmV3ObjectsCompaniesBatchRead_readQueries queries) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/companies/batch/read`;
resource isolated function post companies/batch/update(BatchInputSimplePublicObjectBatchInput payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/companies/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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Update a batch of companies by internal ID, or 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 companies/batch/update(BatchInputSimplePublicObjectBatchInput payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/companies/batch/update`;
resource isolated function get companies(map<string|string[]> headers = {}, *GetCrmV3ObjectsCompaniesGetPageQueries queries) returns CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error {
string resourcePath = string `/companies`;
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);
}

# Create or update a batch of companies by unique property values
# Create
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post companies/batch/upsert(BatchInputSimplePublicObjectBatchInputUpsert payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error {
string resourcePath = string `/companies/batch/upsert`;
resource isolated function post companies(SimplePublicObjectInputForCreate payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/companies`;
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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}

# Merge two companies with same type
# Create or update a batch of companies by unique property values
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post companies/merge(PublicMergeInput payload, map<string|string[]> headers = {}) returns SimplePublicObject|error {
string resourcePath = string `/companies/merge`;
resource isolated function post companies/batch/upsert(BatchInputSimplePublicObjectBatchInputUpsert payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicUpsertObject|BatchResponseSimplePublicUpsertObjectWithErrors|error {
string resourcePath = string `/companies/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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}
Expand All @@ -253,11 +233,11 @@ public isolated client class Client {
string resourcePath = string `/companies/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();
json jsonBody = jsondata:toJson(payload);
request.setPayload(jsonBody, "application/json");
return self.clientEp->post(resourcePath, request, httpHeaders);
}
Expand Down
Loading
Loading