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
46 changes: 15 additions & 31 deletions ballerina/client.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/data.jsondata;
import ballerina/http;

public isolated client class Client {
Expand All @@ -42,26 +43,20 @@ public isolated client class Client {
#
# + headers - Headers to be sent with the request
# + return - successful operation
remote isolated function postCommunicationPreferencesV4StatusesBatchWrite(BatchInputPublicStatusRequest payload, map<string|string[]> headers = {}) returns BatchResponsePublicStatus|error {
resource isolated function post statuses/batch/write(BatchInputPublicStatusRequest payload, map<string|string[]> headers = {}) returns BatchResponsePublicStatus|error {
string resourcePath = string `/statuses/batch/write`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app"] = self.apiKeyConfig?.privateApp;
}
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);
}

# Retrieve a contact's unsubscribed status
#
# + subscriberIdString - The contact's email address
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function getCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAll(string subscriberIdString, map<string|string[]> headers = {}, *GetCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAllQueries queries) returns ActionResponseWithResultsPublicWideStatus|error {
resource isolated function get statuses/[string subscriberIdString]/unsubscribe\-all(map<string|string[]> headers = {}, *GetCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAllQueries queries) returns ActionResponseWithResultsPublicWideStatus|error {
string resourcePath = string `/statuses/${getEncodedUri(subscriberIdString)}/unsubscribe-all`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -72,13 +67,7 @@ public isolated client class Client {
return self.clientEp->get(resourcePath, httpHeaders);
}

# Unsubscribe a contact from all subscriptions
#
# + subscriberIdString - The contact's email address
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function postCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAll(string subscriberIdString, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAllQueries queries) returns ActionResponseWithResultsPublicStatus|error {
resource isolated function post statuses/[string subscriberIdString]/unsubscribe\-all(map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAllQueries queries) returns ActionResponseWithResultsPublicStatus|error {
string resourcePath = string `/statuses/${getEncodedUri(subscriberIdString)}/unsubscribe-all`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -95,7 +84,7 @@ public isolated client class Client {
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function postCommunicationPreferencesV4StatusesBatchRead(BatchInputString payload, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesBatchReadQueries queries) returns BatchResponsePublicStatusBulkResponse|BatchResponsePublicStatusBulkResponseWithErrors|error {
resource isolated function post statuses/batch/read(BatchInputString payload, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesBatchReadQueries queries) returns BatchResponsePublicStatusBulkResponse|BatchResponsePublicStatusBulkResponseWithErrors|error {
string resourcePath = string `/statuses/batch/read`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -104,17 +93,12 @@ public isolated client class Client {
resourcePath = resourcePath + check getPathForQueryParam(queries);
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);
}

# Batch unsubscribe contacts from all subscriptions
#
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function postCommunicationPreferencesV4StatusesBatchUnsubscribeAll(BatchInputString payload, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesBatchUnsubscribeAllQueries queries) returns BatchResponsePublicBulkOptOutFromAllResponse|error {
resource isolated function post statuses/batch/unsubscribe\-all(BatchInputString payload, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesBatchUnsubscribeAllQueries queries) returns BatchResponsePublicBulkOptOutFromAllResponse|error {
string resourcePath = string `/statuses/batch/unsubscribe-all`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -123,7 +107,7 @@ public isolated client class Client {
resourcePath = resourcePath + check getPathForQueryParam(queries);
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 @@ -133,7 +117,7 @@ public isolated client class Client {
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function getCommunicationPreferencesV4Definitions(map<string|string[]> headers = {}, *GetCommunicationPreferencesV4DefinitionsQueries queries) returns ActionResponseWithResultsSubscriptionDefinition|error {
resource isolated function get definitions(map<string|string[]> headers = {}, *GetCommunicationPreferencesV4DefinitionsQueries queries) returns ActionResponseWithResultsSubscriptionDefinition|error {
string resourcePath = string `/definitions`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -149,7 +133,7 @@ public isolated client class Client {
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function postCommunicationPreferencesV4StatusesBatchUnsubscribeAllRead(BatchInputString payload, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesBatchUnsubscribeAllReadQueries queries) returns BatchResponsePublicWideStatusBulkResponse|BatchResponsePublicWideStatusBulkResponseWithErrors|error {
resource isolated function post statuses/batch/unsubscribe\-all/read(BatchInputString payload, map<string|string[]> headers = {}, *PostCommunicationPreferencesV4StatusesBatchUnsubscribeAllReadQueries queries) returns BatchResponsePublicWideStatusBulkResponse|BatchResponsePublicWideStatusBulkResponseWithErrors|error {
string resourcePath = string `/statuses/batch/unsubscribe-all/read`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -158,7 +142,7 @@ public isolated client class Client {
resourcePath = resourcePath + check getPathForQueryParam(queries);
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 @@ -169,7 +153,7 @@ public isolated client class Client {
# + headers - Headers to be sent with the request
# + queries - Queries to be sent with the request
# + return - successful operation
remote isolated function getCommunicationPreferencesV4StatusesSubscriberIdString(string subscriberIdString, map<string|string[]> headers = {}, *GetCommunicationPreferencesV4StatusesSubscriberIdStringQueries queries) returns ActionResponseWithResultsPublicStatus|error {
resource isolated function get statuses/[string subscriberIdString](map<string|string[]> headers = {}, *GetCommunicationPreferencesV4StatusesSubscriberIdStringQueries queries) returns ActionResponseWithResultsPublicStatus|error {
string resourcePath = string `/statuses/${getEncodedUri(subscriberIdString)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
Expand All @@ -185,15 +169,15 @@ public isolated client class Client {
# + subscriberIdString - The contact's email address
# + headers - Headers to be sent with the request
# + return - successful operation
remote isolated function postCommunicationPreferencesV4StatusesSubscriberIdString(string subscriberIdString, PartialPublicStatusRequest payload, map<string|string[]> headers = {}) returns ActionResponseWithResultsPublicStatus|error {
resource isolated function post statuses/[string subscriberIdString](PartialPublicStatusRequest payload, map<string|string[]> headers = {}) returns ActionResponseWithResultsPublicStatus|error {
string resourcePath = string `/statuses/${getEncodedUri(subscriberIdString)}`;
map<anydata> headerValues = {...headers};
if self.apiKeyConfig is ApiKeysConfig {
headerValues["private-app-legacy"] = self.apiKeyConfig?.privateAppLegacy;
}
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
14 changes: 7 additions & 7 deletions ballerina/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ 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`
"EMAIL"|"WHATSAPP"|"SMS" channel;
Expand All @@ -127,7 +127,7 @@ public type OAuth2RefreshTokenGrantConfig record {|
string refreshUrl = "https://api.hubapi.com/oauth/v1/token";
|};

# Represents the Queries record for the operation: postCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAll
# 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;
Expand Down Expand Up @@ -206,7 +206,7 @@ public type PublicSubscriptionTranslation record {
int:Signed32 updatedAt;
};

# 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
boolean includeTranslations?;
Expand Down Expand Up @@ -264,7 +264,7 @@ public type ActionResponseWithResultsPublicStatus record {
"PENDING"|"PROCESSING"|"CANCELED"|"COMPLETE" status;
};

# Represents the Queries record for the operation: getCommunicationPreferencesV4StatusesSubscriberIdString
# 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;
Expand All @@ -281,7 +281,7 @@ 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`
"EMAIL"|"WHATSAPP"|"SMS" channel;
Expand Down Expand Up @@ -325,7 +325,7 @@ public type ApiKeysConfig record {|
string privateApp;
|};

# Represents the Queries record for the operation: getCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAll
# 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;
Expand All @@ -335,7 +335,7 @@ public type GetCommunicationPreferencesV4StatusesSubscriberIdStringUnsubscribeAl
boolean verbose = false;
};

# 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`
"EMAIL"|"WHATSAPP"|"SMS" channel;
Expand Down
Loading