Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
236 changes: 236 additions & 0 deletions ballerina/client.bal
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// 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 @@ -13,3 +16,236 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

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/tasks") 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);
}
}
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;
}

# Archive a task
#
# + headers - Headers to be sent with the request
# + return - No content
resource isolated function delete [string taskId](map<string|string[]> headers = {}) returns http:Response|error {
string resourcePath = string `/${getEncodedUri(taskId)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
map<string|string[]> httpHeaders = http:getHeaderMap(headerValues);
return self.clientEp->delete(resourcePath, headers = httpHeaders);
}

# List of the tasks
#
# + 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 = {}, *GetCrmV3ObjectsTasksGetPageQueries queries) returns CollectionResponseSimplePublicObjectWithAssociationsForwardPaging|error {
string resourcePath = string `/`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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);
}

# Read a task
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function get [string taskId](map<string|string[]> headers = {}, *GetCrmV3ObjectsTasksTaskIdGetByIdQueries queries) returns SimplePublicObjectWithAssociations|error {
string resourcePath = string `/${getEncodedUri(taskId)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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);
}

# Update a task
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
resource isolated function patch [string taskId](SimplePublicObjectInput payload, map<string|string[]> headers = {}, *PatchCrmV3ObjectsTasksTaskIdUpdateQueries queries) returns SimplePublicObject|error {
string resourcePath = string `/${getEncodedUri(taskId)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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->patch(resourcePath, request, httpHeaders);
}

# Create a task
#
# + 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;
}
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);
}

# Archive a batch of tasks by ID
#
# + 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 {
string resourcePath = string `/batch/archive`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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 a batch of tasks
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post batch/create(BatchInputSimplePublicObjectInputForCreate payload, map<string|string[]> headers = {}) returns BatchResponseSimplePublicObject|BatchResponseSimplePublicObjectWithErrors|error {
string resourcePath = string `/batch/create`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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 tasks 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 = {}, *PostCrmV3ObjectsTasksBatchReadReadQueries 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;
}
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);
}

# Update a batch of tasks 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`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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 tasks by unique property values
#
# + headers - Headers 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`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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);
}

# Search for tasks
#
# + headers - Headers to be sent with the request
# + return - successful operation
resource isolated function post search(PublicObjectSearchRequest payload, map<string|string[]> headers = {}) returns CollectionResponseWithTotalSimplePublicObjectForwardPaging|error {
string resourcePath = string `/search`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.private\-app;
}
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);
}
}
Loading
Loading