Skip to content
Closed
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
150 changes: 55 additions & 95 deletions ballerina/client.bal

Large diffs are not rendered by default.

130 changes: 58 additions & 72 deletions ballerina/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public type ErrorDetail record {
string subCategory?;
# The status code associated with the error detail
string code?;
# The name of the field or parameter in which the error was found.
# The name of the field or parameter in which the error was found
string 'in?;
# Context about the error condition
record {|string[]...;|} context?;
Expand Down Expand Up @@ -112,11 +112,11 @@ public type ActionResponseWithResultsSubscriptionDefinition record {
"PENDING"|"PROCESSING"|"CANCELED"|"COMPLETE" status;
};

# Represents the Queries record for the operation: postCommunicationPreferencesV4StatusesBatchRead
# Represents the Queries record for the operation: post-/communication-preferences/v4/statuses/batch/read
public type PostCommunicationPreferencesV4StatusesBatchReadQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`.
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
};

Expand All @@ -127,13 +127,13 @@ public type OAuth2RefreshTokenGrantConfig record {|
string refreshUrl = "https://api.hubapi.com/oauth/v1/token";
|};

# Represents the Queries record for the operation: getCommunicationPreferencesV4StatusesSubscriberidstringUnsubscribeAll
public type GetCommunicationPreferencesV4StatusesSubscriberidstringUnsubscribeAllQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`.
# Represents the Queries record for the operation: post-/communication-preferences/v4/statuses/{subscriberIdString}/unsubscribe-all
public type PostCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAllQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
# Set to `true` to include the details of the updated subscription statuses in the response. Not including this parameter will result in an empty response.
# Set to `true` to include the details of the updated subscription statuses in the response. Not including this parameter will result in an empty response
boolean verbose = false;
};

Expand All @@ -156,31 +156,40 @@ public type ConnectionConfig record {|
# The HTTP version understood by the client
http:HttpVersion httpVersion = http:HTTP_2_0;
# Configurations related to HTTP/1.x protocol
ClientHttp1Settings http1Settings?;
http:ClientHttp1Settings http1Settings = {};
# Configurations related to HTTP/2 protocol
http:ClientHttp2Settings http2Settings?;
http:ClientHttp2Settings http2Settings = {};
# The maximum time to wait (in seconds) for a response before closing the connection
decimal timeout = 60;
decimal timeout = 30;
# The choice of setting `forwarded`/`x-forwarded` header
string forwarded = "disable";
# Configurations associated with Redirection
http:FollowRedirects followRedirects?;
# Configurations associated with request pooling
http:PoolConfiguration poolConfig?;
# HTTP caching related configurations
http:CacheConfig cache?;
http:CacheConfig cache = {};
# Specifies the way of handling compression (`accept-encoding`) header
http:Compression compression = http:COMPRESSION_AUTO;
# Configurations associated with the behaviour of the Circuit Breaker
http:CircuitBreakerConfig circuitBreaker?;
# Configurations associated with retrying
http:RetryConfig retryConfig?;
# Configurations associated with cookies
http:CookieConfig cookieConfig?;
# Configurations associated with inbound response size limits
http:ResponseLimitConfigs responseLimits?;
http:ResponseLimitConfigs responseLimits = {};
# SSL/TLS-related options
http:ClientSecureSocket secureSocket?;
# Proxy server related options
http:ProxyConfig proxy?;
# Provides settings related to client socket configuration
http:ClientSocketConfig socketConfig = {};
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables relaxed data binding on the client side. When enabled, `nil` values are treated as optional,
# and absent fields are handled as `nilable` types. Enabled by default.
boolean laxDataBinding = true;
|};

public type PublicStatusBulkResponse record {
Expand All @@ -197,19 +206,11 @@ public type PublicSubscriptionTranslation record {
int:Signed32 updatedAt;
};

# Represents the Queries record for the operation: getCommunicationPreferencesV4StatusesSubscriberidstring
public type GetCommunicationPreferencesV4StatusesSubscriberidstringQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`.
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
int businessUnitId?;
};

# Represents the Queries record for the operation: getCommunicationPreferencesV4Definitions
# Represents the Queries record for the operation: get-/communication-preferences/v4/definitions
public type GetCommunicationPreferencesV4DefinitionsQueries record {
# Set to `true` to return subscription translations associated with each definition.
# Set to `true` to return subscription translations associated with each definition
boolean includeTranslations?;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
};

Expand All @@ -233,17 +234,17 @@ public type BatchResponsePublicStatus record {
};

public type PublicStatusRequest record {
# The status of the contact's subscription.
# The status of the contact's subscription
"SUBSCRIBED"|"UNSUBSCRIBED"|"NOT_SPECIFIED" statusState;
# The type of communication channel. Currently, only `EMAIL` is supported.
# The type of communication channel. Currently, only `EMAIL` is supported
"EMAIL"|"WHATSAPP"|"SMS" channel;
# The contact's email address.
# The contact's email address
string subscriberIdString;
# The legal basis for communication.
# The legal basis for communication
"LEGITIMATE_INTEREST_PQL"|"LEGITIMATE_INTEREST_CLIENT"|"PERFORMANCE_OF_CONTRACT"|"CONSENT_WITH_NOTICE"|"NON_GDPR"|"PROCESS_AND_STORE"|"LEGITIMATE_INTEREST_OTHER" legalBasis?;
# The ID of the subscription to update.
# The ID of the subscription to update
int:Signed32 subscriptionId;
# The explanation for the legal basis.
# The explanation for the legal basis
string legalBasisExplanation?;
};

Expand All @@ -252,19 +253,6 @@ public type PublicWideStatusBulkResponse record {
string subscriberIdString;
};

# Proxy server configurations to be used with the HTTP client endpoint.
public type ProxyConfig record {|
# Host name of the proxy server
string host = "";
# Proxy server port
int port = 0;
# Proxy server username
string userName = "";
# Proxy server password
@display {label: "", kind: "password"}
string password = "";
|};

public type ActionResponseWithResultsPublicStatus record {
string completedAt;
int:Signed32 numErrors?;
Expand All @@ -276,6 +264,14 @@ public type ActionResponseWithResultsPublicStatus record {
"PENDING"|"PROCESSING"|"CANCELED"|"COMPLETE" status;
};

# Represents the Queries record for the operation: get-/communication-preferences/v4/statuses/{subscriberIdString}
public type GetCommunicationPreferencesV4StatusesSubscriberIdStringQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
};

public type BatchResponsePublicWideStatusBulkResponse record {
string completedAt;
string requestedAt?;
Expand All @@ -285,28 +281,18 @@ public type BatchResponsePublicWideStatusBulkResponse record {
"PENDING"|"PROCESSING"|"CANCELED"|"COMPLETE" status;
};

# Represents the Queries record for the operation: postCommunicationPreferencesV4StatusesBatchUnsubscribeAllRead
# Represents the Queries record for the operation: post-/communication-preferences/v4/statuses/batch/unsubscribe-all/read
public type PostCommunicationPreferencesV4StatusesBatchUnsubscribeAllReadQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`.
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
};

public type BatchInputPublicStatusRequest record {
PublicStatusRequest[] inputs;
};

# Provides settings related to HTTP/1.x protocol.
public type ClientHttp1Settings record {|
# Specifies whether to reuse a connection for multiple requests
http:KeepAlive keepAlive = http:KEEPALIVE_AUTO;
# The chunking behaviour of the request
http:Chunking chunking = http:CHUNKING_AUTO;
# Proxy server related options
ProxyConfig proxy?;
|};

public type SubscriptionDefinition record {
boolean isInternal;
string createdAt;
Expand All @@ -333,29 +319,29 @@ public type BatchResponsePublicWideStatusBulkResponseWithErrors record {
"PENDING"|"PROCESSING"|"CANCELED"|"COMPLETE" status;
};

# Represents the Queries record for the operation: postCommunicationPreferencesV4StatusesSubscriberidstringUnsubscribeAll
public type PostCommunicationPreferencesV4StatusesSubscriberidstringUnsubscribeAllQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`.
# Provides API key configurations needed when communicating with a remote HTTP endpoint.
public type ApiKeysConfig record {|
string privateAppLegacy;
string privateApp;
|};

# Represents the Queries record for the operation: get-/communication-preferences/v4/statuses/{subscriberIdString}/unsubscribe-all
public type GetCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAllQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
# Set to `true` to include the details of the updated subscription statuses in the response. Not including this parameter will result in an empty response.
# Set to `true` to include the details of the updated subscription statuses in the response. Not including this parameter will result in an empty response
boolean verbose = false;
};

# Provides API key configurations needed when communicating with a remote HTTP endpoint.
public type ApiKeysConfig record {|
string private\-app\-legacy;
string private\-app;
|};

# Represents the Queries record for the operation: postCommunicationPreferencesV4StatusesBatchUnsubscribeAll
# Represents the Queries record for the operation: post-/communication-preferences/v4/statuses/batch/unsubscribe-all
public type PostCommunicationPreferencesV4StatusesBatchUnsubscribeAllQueries record {
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`.
# The channel type for the subscription type. Currently, the only supported channel type is `EMAIL`
"EMAIL"|"WHATSAPP"|"SMS" channel;
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`.
# If you have the [business unit add-on](https://developers.hubspot.com/beta-docs/guides/api/settings/business-units-api), include this parameter to filter results by business unit ID. The default Account business unit will always use `0`
int businessUnitId?;
# Set to `true` to include the details of the updated subscription statuses in the response. Not including this parameter will result in an empty response.
# Set to `true` to include the details of the updated subscription statuses in the response. Not including this parameter will result in an empty response
boolean verbose = false;
};

Expand Down
25 changes: 5 additions & 20 deletions ballerina/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/http;
import ballerina/url;

type SimpleBasicType string|boolean|int|float|decimal;
Expand Down Expand Up @@ -186,12 +187,13 @@ isolated function getEncodedUri(anydata value) returns string {
# + encodingMap - Details on serialization mechanism
# + return - Returns generated Path or error at failure of client initialization
isolated function getPathForQueryParam(map<anydata> queryParam, map<Encoding> encodingMap = {}) returns string|error {
map<anydata> queriesMap = http:getQueryMap(queryParam);
string[] param = [];
if queryParam.length() > 0 {
if queriesMap.length() > 0 {
param.push("?");
foreach var [key, value] in queryParam.entries() {
foreach var [key, value] in queriesMap.entries() {
if value is () {
_ = queryParam.remove(key);
_ = queriesMap.remove(key);
continue;
}
Encoding encodingData = encodingMap.hasKey(key) ? encodingMap.get(key) : defaultEncoding;
Expand All @@ -215,20 +217,3 @@ isolated function getPathForQueryParam(map<anydata> queryParam, map<Encoding> en
string restOfPath = string:'join("", ...param);
return restOfPath;
}

# Generate header map for given header values.
#
# + headerParam - Headers map
# + return - Returns generated map or error at failure of client initialization
isolated function getMapForHeaders(map<anydata> headerParam) returns map<string|string[]> {
map<string|string[]> headerMap = {};
foreach var [key, value] in headerParam.entries() {
if value is SimpleBasicType[] {
headerMap[key] = from SimpleBasicType data in value
select data.toString();
} else {
headerMap[key] = value.toString();
}
}
return headerMap;
}
Loading
Loading