diff --git a/README.md b/README.md index babc242..931ef67 100644 --- a/README.md +++ b/README.md @@ -158,18 +158,18 @@ import ballerinax/hubspot.marketing.events as hsmevents; 1. Create a `Config.toml` file in the root directory of the Ballerina project and configure the obtained credentials in the above steps as follows: ```toml - clientId = - clientSecret = - refreshToken = + clientId = "" + clientSecret = "" + refreshToken = "" ``` >**Note (Optional):** If you want to use Set and Get Application Settings operations, you need to provide the Developer API Key in the `Config.toml` file as well. ```toml - clientId = - clientSecret = - refreshToken = - apiKey = + clientId = "" + clientSecret = "" + refreshToken = "" + apiKey = "" ``` 2. Instantiate a `hsmevents:ConnectionConfig` with the obtained credentials and initialize the connector with it. diff --git a/ballerina/Module.md b/ballerina/Module.md index 570f463..2ab077a 100644 --- a/ballerina/Module.md +++ b/ballerina/Module.md @@ -150,18 +150,18 @@ import ballerinax/hubspot.marketing.events as hsmevents; 1. Create a `Config.toml` file in the root directory of the Ballerina project and configure the obtained credentials in the above steps as follows: ```toml - clientId = - clientSecret = - refreshToken = + clientId = "" + clientSecret = "" + refreshToken = "" ``` >**Note (Optional):** If you want to use Set and Get Application Settings operations, you need to provide the Developer API Key in the `Config.toml` file as well. ```toml - clientId = - clientSecret = - refreshToken = - apiKey = + clientId = "" + clientSecret = "" + refreshToken = "" + apiKey = "" ``` 2. Instantiate a `hsmevents:ConnectionConfig` with the obtained credentials and initialize the connector with it. diff --git a/ballerina/Package.md b/ballerina/Package.md index 570f463..2ab077a 100644 --- a/ballerina/Package.md +++ b/ballerina/Package.md @@ -150,18 +150,18 @@ import ballerinax/hubspot.marketing.events as hsmevents; 1. Create a `Config.toml` file in the root directory of the Ballerina project and configure the obtained credentials in the above steps as follows: ```toml - clientId = - clientSecret = - refreshToken = + clientId = "" + clientSecret = "" + refreshToken = "" ``` >**Note (Optional):** If you want to use Set and Get Application Settings operations, you need to provide the Developer API Key in the `Config.toml` file as well. ```toml - clientId = - clientSecret = - refreshToken = - apiKey = + clientId = "" + clientSecret = "" + refreshToken = "" + apiKey = "" ``` 2. Instantiate a `hsmevents:ConnectionConfig` with the obtained credentials and initialize the connector with it. diff --git a/ballerina/client.bal b/ballerina/client.bal index f63c661..3e4d625 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -1,7 +1,7 @@ // 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). +// Copyright (c) 2025, 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 diff --git a/ballerina/tests/mock_server.bal b/ballerina/tests/mock_server.bal index c43c512..0598c64 100644 --- a/ballerina/tests/mock_server.bal +++ b/ballerina/tests/mock_server.bal @@ -21,13 +21,12 @@ listener http:Listener httpListener = new (localPort); http:Service mockService = service object { resource isolated function post oauth2/token(@http:Payload http:Request request) returns json { - json response = { + return { "token_type": "bearer", "refresh_token": "mock", "access_token": "mockAccessToken", "expires_in": 1800 }; - return response; } resource isolated function post events(@http:Payload MarketingEventCreateRequestParams createPayload) diff --git a/ballerina/tests/mock_tests.bal b/ballerina/tests/mock_tests.bal deleted file mode 100644 index 170bbf9..0000000 --- a/ballerina/tests/mock_tests.bal +++ /dev/null @@ -1,187 +0,0 @@ -import ballerina/http; -import ballerina/log; -import ballerina/test; - -configurable int localPort = 9090; - -// Using Separate Client for Mock Tests -Client mockClient = test:mock(Client); - -// Create Mock Auth Config -OAuth2RefreshTokenGrantConfig mockAuth = { - clientId: "mock", - clientSecret: "mock", - refreshToken: "mock", - refreshUrl: string `http://localhost:${localPort}/oauth2/token` -}; -ConnectionConfig mockConfig = {auth: mockAuth}; - -string mockTestObjId = ""; - -@test:BeforeGroups { - value: ["mock_tests"] -} -function setupMock() returns error? { - log:printInfo(string `Initiating mock server in port ${localPort}`); - check httpListener.attach(mockService, "/"); - check httpListener.'start(); - - log:printInfo("Starting Mock Tests"); - // Create Mock Client - mockClient = check new (mockConfig, string `http://localhost:${localPort}`); -}; - -@test:Config { - groups: ["mock_tests"] -} -function CreateMarketingEventMockTest() returns error? { - - // Create a New event - CrmPropertyWrapper customProperty = { - name: "test_name", - value: "Custom Value" - }; - - MarketingEventCreateRequestParams sampleCreatePayload = { - externalAccountId: "11111", - externalEventId: "10000", - eventName: "Winter webinar", - eventOrganizer: "Snowman Fellowship", - eventCancelled: false, - eventUrl: "https://example.com/holiday-jam", - eventType: "WEBINAR", - eventDescription: "Let's get together to plan for the holidays", - eventCompleted: false, - startDateTime: "2024-08-07T12:36:59.286Z", - endDateTime: "2024-08-07T12:36:59.286Z", - customProperties: [ - customProperty - ] - }; - - MarketingEventDefaultResponse createResp = check mockClient->postEvents_create(sampleCreatePayload); - - test:assertTrue(createResp?.objectId !is "" && createResp?.objectId is string); - test:assertTrue(createResp.eventName == sampleCreatePayload.eventName); - mockTestObjId = createResp?.objectId is null ? "" : createResp?.objectId.toString(); -}; - -@test:Config { - groups: ["mock_tests"] -} -function CreateOrUpdateMarketingEventMockTest() returns error? { - - // Create a New event - - string externalEventId = "11000"; - - CrmPropertyWrapper customProperty = { - name: "test_name", - value: "Custom Value" - }; - - MarketingEventCreateRequestParams sampleCreatePayload = { - externalAccountId: "11111", - externalEventId: externalEventId, - eventName: "Test 2", - eventOrganizer: "Organizer 2", - eventCancelled: false, - eventUrl: "https://example.com/test-2", - eventDescription: "Test 2", - eventCompleted: false, - eventType: "CONFERENCE", - startDateTime: "2024-08-07T12:36:59.286Z", - endDateTime: "2024-08-07T12:36:59.286Z", - customProperties: [ - customProperty - ] - }; - - MarketingEventPublicDefaultResponse createResp = check mockClient->putEventsExternaleventid_upsert( - externalEventId, sampleCreatePayload); - - test:assertTrue(createResp?.objectId !is "" && createResp?.objectId is string); - test:assertTrue(createResp.eventName == sampleCreatePayload.eventName); - - // Update an existing event - - string updatedEventName = "Test 2 Updated"; - string updatedEventOrganizer = "Organizer 2 Updated"; - - MarketingEventCreateRequestParams sampleUpdatePayload = { - externalAccountId: "11111", - externalEventId: externalEventId, - eventName: updatedEventName, - eventOrganizer: updatedEventOrganizer - }; - - MarketingEventPublicDefaultResponse updateResp = check mockClient->putEventsExternaleventid_upsert( - externalEventId, sampleUpdatePayload); - - test:assertEquals(updateResp.eventName, updatedEventName); - test:assertEquals(updateResp.eventOrganizer, updatedEventOrganizer); -}; - -@test:Config { - groups: ["mock_tests"], - dependsOn: [CreateMarketingEventMockTest, CreateOrUpdateMarketingEventMockTest] -} -function GetAllMarketingEventsMockTest() returns error? { - - CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging getResp = check mockClient->get(); - - test:assertTrue(getResp?.results !is ()); -}; - -@test:Config { - groups: ["mock_tests"], - dependsOn: [CreateMarketingEventMockTest, CreateOrUpdateMarketingEventMockTest] -} -function AssociateListFromInternalIdsMockTest() returns error? { - - string listId = "9"; // ILS List ID of the list - - http:Response createResp = check - mockClient->putAssociationsMarketingeventidListsListid_associatebymarketingeventid(testObjId, listId); - - test:assertTrue(createResp.statusCode >= 200 && createResp.statusCode < 300); -} - -// Delete All the Event Objects (After Group) - -@test:AfterGroups { - value: ["mock_tests"], - alwaysRun: true -} -function DeleteMarketingEventByObjectIdMockTest() returns error? { - - // Valid ObjID - - http:Response deleteResp = check mockClient->deleteObjectid(testObjId); - - test:assertTrue(deleteResp.statusCode == 204); - - // Invalid ObjID - - string invalidObjId = "8436"; - - http:Response deleteResp2 = check mockClient->deleteObjectid(invalidObjId); - - test:assertTrue(deleteResp2.statusCode == 404); - mockTestObjId = ""; -}; - -@test:AfterGroups { - value: ["mock_tests"], - alwaysRun: true -} -function DeleteMarketingEventByExternalIdsMockTest() returns error? { - - string externalAccountId = "11111"; - string externalEventId = "11000"; - - http:Response deleteResp = check - mockClient->deleteEventsExternaleventid_archive(externalEventId, externalAccountId = externalAccountId); - - test:assertTrue(deleteResp.statusCode == 204); -}; diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 428032e..f79802a 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -19,52 +19,68 @@ import ballerina/log; import ballerina/oauth2; import ballerina/test; -configurable string refreshToken = ""; -configurable string clientId = ""; -configurable string clientSecret = ""; +configurable boolean isLiveServer = false; +configurable string refreshToken = "mock"; +configurable string clientId = "mock"; +configurable string clientSecret = "mock"; configurable string devApiKey = "-1"; +configurable int localPort = 9090; Client hubspotClient = test:mock(Client); // Using a separate client for app setting tests since it need developer API key Client hubspotAppSettingClient = test:mock(Client); -// Create Auth Config for Live OAuth2 -OAuth2RefreshTokenGrantConfig auth = { - clientId, - clientSecret, - refreshToken, - credentialBearer: oauth2:POST_BODY_BEARER // this line should be added in to when you are going to create auth object. -}; -ConnectionConfig config = {auth}; - string testObjId = ""; string[] batchTestObjIds = []; string appId = ""; -@test:BeforeGroups { - value: ["live_tests"] -} -function setupLive() returns error? { - log:printInfo("Starting Live Tests"); - - hubspotClient = check new (config); - - // Only create the app setting client if the Dev API key is set - if devApiKey != "-1" { - log:printInfo("Developer API Key Found. Running App Setting Tests"); - ApiKeysConfig apiKeysConfig = { - hapikey: devApiKey, - private\-app\-legacy: "" +@test:BeforeSuite +function setupTests() returns error? { + if isLiveServer { + log:printInfo("Initiating live server"); + OAuth2RefreshTokenGrantConfig auth = { + clientId, + clientSecret, + refreshToken, + credentialBearer: oauth2:POST_BODY_BEARER // this line should be added in to when you are going to create auth object. }; - hubspotAppSettingClient = check new ({auth: apiKeysConfig}); + ConnectionConfig config = {auth}; + hubspotClient = check new (config); + + // Only create the app setting client if the Dev API key is set + if devApiKey != "-1" { + log:printInfo("Developer API Key Found. Running App Setting Tests"); + ApiKeysConfig apiKeysConfig = { + hapikey: devApiKey, + private\-app\-legacy: "" + }; + hubspotAppSettingClient = check new ({auth: apiKeysConfig}); + } else { + log:printInfo("Developer API Key Not Found. Skipping App Setting Tests"); + } + } else { - log:printInfo("Developer API Key Not Found. Skipping App Setting Tests"); + log:printInfo("Initiating mock server"); + check httpListener.attach(mockService, "/"); + check httpListener.'start(); + + // Create Mock Auth Config + OAuth2RefreshTokenGrantConfig mockAuth = { + clientId, + clientSecret, + refreshToken, + refreshUrl: string `http://localhost:${localPort}/oauth2/token` + }; + ConnectionConfig mockConfig = {auth: mockAuth}; + + hubspotClient = check new (mockConfig, string `http://localhost:${localPort}`); } + }; @test:Config { - groups: ["BASIC", "live_tests"] + groups: ["BASIC", "live_tests", "mock_tests"] } function CreateMarketingEventTest() returns error? { @@ -99,7 +115,7 @@ function CreateMarketingEventTest() returns error? { }; @test:Config { - groups: ["BASIC", "live_tests"] + groups: ["BASIC", "live_tests", "mock_tests"] } function CreateOrUpdateMarketingEventTest() returns error? { @@ -156,6 +172,7 @@ function CreateOrUpdateMarketingEventTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [CreateOrUpdateMarketingEventTest] } function UpdateMarketingEventByExternalIdsTest() returns error? { @@ -185,6 +202,7 @@ function UpdateMarketingEventByExternalIdsTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function updateMarketingEventByObjectIdTest() returns error? { @@ -218,7 +236,7 @@ function updateMarketingEventByObjectIdTest() returns error? { }; @test:Config { - groups: ["BASIC", "live_tests"], + groups: ["BASIC", "live_tests", "mock_tests"], dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function GetAllMarketingEventsTest() returns error? { @@ -230,6 +248,7 @@ function GetAllMarketingEventsTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [UpdateMarketingEventByExternalIdsTest, updateMarketingEventByObjectIdTest] } function GetMarketingEventbyExternalIdsTest() returns error? { @@ -246,6 +265,7 @@ function GetMarketingEventbyExternalIdsTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [updateMarketingEventByObjectIdTest] } function GetMarketingEventbyObjectIdTest() returns error? { @@ -267,7 +287,8 @@ function GetMarketingEventbyObjectIdTest() returns error? { }; @test:Config { - groups: ["BATCH", "live_tests"] + groups: ["BATCH", "live_tests"], + enable: isLiveServer } function BatchCreateOrUpdateMarketingEventsTest() returns error? { string externalAccountId = "112233"; @@ -357,6 +378,7 @@ function BatchCreateOrUpdateMarketingEventsTest() returns error? { @test:Config { groups: ["BATCH", "live_tests"], + enable: isLiveServer, dependsOn: [BatchCreateOrUpdateMarketingEventsTest] } function BatchUpdateMarketingEventsByObjectId() returns error? { @@ -456,6 +478,7 @@ function BatchDeleteMarketingEventsByObjectId() returns error? { @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function RecordParticipantsByContactIdwithMarketingEventObjectIdsTest() returns error? { @@ -483,6 +506,7 @@ function RecordParticipantsByContactIdwithMarketingEventObjectIdsTest() returns @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function RecordParticipantsByEmailwithMarketingEventObjectIdsTest() returns error? { @@ -506,6 +530,7 @@ function RecordParticipantsByEmailwithMarketingEventObjectIdsTest() returns erro @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateOrUpdateMarketingEventTest] } function RecordParticipantsByEmailwithMarketingEventExternalIdsTest() returns error? { @@ -531,6 +556,7 @@ function RecordParticipantsByEmailwithMarketingEventExternalIdsTest() returns er @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateOrUpdateMarketingEventTest] } function RecordParticipantsByContactIdswithMarketingEventExternalIdsTest() returns error? { @@ -561,6 +587,7 @@ function RecordParticipantsByContactIdswithMarketingEventExternalIdsTest() retur @test:Config { groups: ["IDENTIFIERS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function FindAppSpecificMarketingEventByExternalEventIdsTest() returns error? { @@ -575,6 +602,7 @@ function FindAppSpecificMarketingEventByExternalEventIdsTest() returns error? { @test:Config { groups: ["IDENTIFIERS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function FindMarketingEventByExternalEventIdsTest() returns error? { @@ -589,6 +617,7 @@ function FindMarketingEventByExternalEventIdsTest() returns error? { @test:Config { groups: ["EVENT_STATUS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function MarkEventCompletedTest() returns error? { @@ -610,6 +639,7 @@ function MarkEventCompletedTest() returns error? { @test:Config { groups: ["EVENT_STATUS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function MarkEventCancelledTest() returns error? { @@ -626,6 +656,7 @@ function MarkEventCancelledTest() returns error? { @test:Config { groups: ["SUBSCRIBER_STATE", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function RecordSubStateByEmailTest() returns error? { @@ -651,6 +682,7 @@ function RecordSubStateByEmailTest() returns error? { @test:Config { groups: ["SUBSCRIBER_STATE", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function RecordSubStateByContactIdTest() returns error? { @@ -680,6 +712,7 @@ function RecordSubStateByContactIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function ReadParticipationBreakdownByContactIdentifierTest() returns error? { @@ -694,6 +727,7 @@ function ReadParticipationBreakdownByContactIdentifierTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationBreakdownByExternalIdTest() returns error? { @@ -710,6 +744,7 @@ function ReadParticipationBreakdownByExternalIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationBreakdownByInternalIdTest() returns error? { @@ -724,6 +759,7 @@ function ReadParticipationBreakdownByInternalIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationCountByInternalIdTest() returns error? { @@ -739,6 +775,7 @@ function ReadParticipationCountByInternalIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationCountByExternalIdTest() returns error? { @@ -756,6 +793,7 @@ function ReadParticipationCountByExternalIdTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function AssociateListFromExternalIdsTest() returns error? { @@ -773,7 +811,7 @@ function AssociateListFromExternalIdsTest() returns error? { } @test:Config { - groups: ["LISTS", "live_tests"], + groups: ["LISTS", "live_tests", "mock_tests"], dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function AssociateListFromInternalIdsTest() returns error? { @@ -788,6 +826,7 @@ function AssociateListFromInternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [AssociateListFromInternalIdsTest] } function GetAssociatedListsFromInternalIdsTest() returns error? { @@ -800,6 +839,7 @@ function GetAssociatedListsFromInternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [AssociateListFromExternalIdsTest] } function GetAssociatedListsFromExternalIdsTest() returns error? { @@ -814,6 +854,7 @@ function GetAssociatedListsFromExternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [GetAssociatedListsFromExternalIdsTest] } function DeleteAssociatedListsfromExternalIdsTest() returns error? { @@ -831,6 +872,7 @@ function DeleteAssociatedListsfromExternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [GetAssociatedListsFromInternalIdsTest] } function DeleteAssociatedListsfromInternalIdsTest() returns error? { @@ -847,15 +889,11 @@ function DeleteAssociatedListsfromInternalIdsTest() returns error? { @test:Config { groups: ["APP_SETTINGS", "live_tests"], + enable: isLiveServer && devApiKey != "-1", dependsOn: [GetMarketingEventbyObjectIdTest] } function SetAppSettingsTest() returns error? { - if devApiKey == "-1" { - log:printInfo("Developer API Key Not Found. Skipping App Setting Tests"); - return; - } - EventDetailSettingsUrl payload = { eventDetailsUrl: "https://my.event.app/events/%s" }; @@ -870,15 +908,11 @@ function SetAppSettingsTest() returns error? { @test:Config { groups: ["APP_SETTINGS", "live_tests"], + enable: isLiveServer && devApiKey != "-1", dependsOn: [SetAppSettingsTest] } function GetAppSettingsTest() returns error? { - if devApiKey == "-1" { - log:printInfo("Developer API Key Not Found. Skipping App Retrieving Tests"); - return; - } - EventDetailSettings getResp = check hubspotAppSettingClient->getAppidSettings_getall(check int:fromString(appId).ensureType(int:Signed32)); @@ -886,17 +920,14 @@ function GetAppSettingsTest() returns error? { test:assertEquals(getResp?.eventDetailsUrl, "https://my.event.app/events/%s"); }; -// Delete All the Event Objects (After Group) +// Delete All the Event Objects (After Suite) -@test:AfterGroups { - value: ["live_tests"], - alwaysRun: true -} +@test:AfterSuite function DeleteMarketingEventByObjectIdTest() returns error? { // Valid ObjID - http:Response deleteResp = check hubspotClient->deleteObjectid(testObjId); + http:Response deleteResp = check hubspotClient->deleteObjectid(testObjId == "" ? "395700216901": testObjId); test:assertTrue(deleteResp.statusCode == 204); @@ -910,10 +941,7 @@ function DeleteMarketingEventByObjectIdTest() returns error? { testObjId = ""; }; -@test:AfterGroups { - value: ["live_tests"], - alwaysRun: true -} +@test:AfterSuite function DeleteMarketingEventByExternalIdsTest() returns error? { string externalAccountId = "11111"; diff --git a/ballerina/types.bal b/ballerina/types.bal index 7a7195c..b1e59c6 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -1,7 +1,7 @@ // 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). +// Copyright (c) 2025, 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 diff --git a/ballerina/utils.bal b/ballerina/utils.bal index 13d33ab..5d8e591 100644 --- a/ballerina/utils.bal +++ b/ballerina/utils.bal @@ -1,7 +1,7 @@ // 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). +// Copyright (c) 2025, 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 diff --git a/examples/event_participation_management/Ballerina.toml b/examples/event_participation_management/Ballerina.toml index 2735117..8ce7a58 100644 --- a/examples/event_participation_management/Ballerina.toml +++ b/examples/event_participation_management/Ballerina.toml @@ -6,9 +6,3 @@ distribution = "2201.10.0" [build-options] observabilityIncluded = true - -[[dependency]] -org = "ballerinax" -name = "hubspot.marketing.events" -version = "0.1.0" -repository = "local" diff --git a/examples/event_participation_management/main.bal b/examples/event_participation_management/main.bal index 6467209..5ab6f53 100644 --- a/examples/event_participation_management/main.bal +++ b/examples/event_participation_management/main.bal @@ -33,7 +33,7 @@ public function main() returns error? { }; hsmevents:ConnectionConfig config = {auth}; - final hsmevents:Client hubspotClient = check new (config); + final hsmevents:Client hubspotMarketingClient = check new (config); // Step 1: Create a new event @@ -52,7 +52,7 @@ public function main() returns error? { customProperties: [] }; - hsmevents:MarketingEventDefaultResponse createResp = check hubspotClient->postEvents_create(createPayload); + hsmevents:MarketingEventDefaultResponse createResp = check hubspotMarketingClient->postEvents_create(createPayload); string eventObjId = createResp?.objectId ?: "-1"; @@ -72,7 +72,7 @@ public function main() returns error? { }; hsmevents:BatchResponseSubscriberVidResponse registerResp = check - hubspotClient->postObjectidAttendanceSubscriberstateEmailCreate(eventObjId, "register", dummyParticipants); + hubspotMarketingClient->postObjectidAttendanceSubscriberstateEmailCreate(eventObjId, "register", dummyParticipants); io:println("Participants Registered: ", registerResp?.results ?: "Failed"); @@ -81,14 +81,14 @@ public function main() returns error? { // NOTE: Changing participant state takes some time to process. The changes might not be visible immediately. http:Response attendResp = check - hubspotClient->postEventsExternaleventidSubscriberstateEmailUpsert_upsertbycontactemail( + hubspotMarketingClient->postEventsExternaleventidSubscriberstateEmailUpsert_upsertbycontactemail( "12000", "attend", dummyParticipants, externalAccountId = "11111"); io:println("Participant Status Changed: ", attendResp.statusCode == 202 ? "Success" : "Failed"); // Step 4: Get Participant Breakdown of a particular event - hsmevents:CollectionResponseWithTotalParticipationBreakdownForwardPaging participants = check hubspotClient-> + hsmevents:CollectionResponseWithTotalParticipationBreakdownForwardPaging participants = check hubspotMarketingClient-> getParticipationsExternalaccountidExternaleventidBreakdown_getparticipationsbreakdownbyexternaleventid( "11111", "12000"); @@ -98,7 +98,7 @@ public function main() returns error? { // Step 5: Delete Event - http:Response deleteResp = check hubspotClient->deleteObjectid(eventObjId); + http:Response deleteResp = check hubspotMarketingClient->deleteObjectid(eventObjId); io:println("Event Deleted: ", deleteResp.statusCode == 204 ? "Success" : "Failed"); } diff --git a/examples/marketing_event_management/Ballerina.toml b/examples/marketing_event_management/Ballerina.toml index f575504..834965b 100644 --- a/examples/marketing_event_management/Ballerina.toml +++ b/examples/marketing_event_management/Ballerina.toml @@ -2,13 +2,7 @@ org = "wso2" name = "marketing_event_management" version = "0.1.0" -distribution = "2201.10.3" +distribution = "2201.10.0" [build-options] observabilityIncluded = true - -[[dependency]] -org = "ballerinax" -name = "hubspot.marketing.events" -version = "0.1.0" -repository = "local" diff --git a/examples/marketing_event_management/main.bal b/examples/marketing_event_management/main.bal index 2f208a2..a36ff73 100644 --- a/examples/marketing_event_management/main.bal +++ b/examples/marketing_event_management/main.bal @@ -33,7 +33,7 @@ public function main() returns error? { }; hsmevents:ConnectionConfig config = {auth}; - hsmevents:Client hubspotClient = check new (config); + hsmevents:Client hubspotMarketingClient = check new (config); // Step 1: Create a new event @@ -52,7 +52,7 @@ public function main() returns error? { customProperties: [] }; - hsmevents:MarketingEventDefaultResponse createResp = check hubspotClient->postEvents_create(createPayload); + hsmevents:MarketingEventDefaultResponse createResp = check hubspotMarketingClient->postEvents_create(createPayload); string eventObjId = createResp?.objectId ?: "-1"; @@ -78,13 +78,13 @@ public function main() returns error? { }; hsmevents:MarketingEventPublicDefaultResponseV2 updateResp = check - hubspotClient->patchObjectid(eventObjId, sampleUpdatePayload); + hubspotMarketingClient->patchObjectid(eventObjId, sampleUpdatePayload); io:println("Event Updated: ", updateResp?.objectId ?: "-1"); // Step 3: Get the event - hsmevents:MarketingEventPublicDefaultResponseV2 getResp = check hubspotClient->getObjectid(eventObjId); + hsmevents:MarketingEventPublicDefaultResponseV2 getResp = check hubspotMarketingClient->getObjectid(eventObjId); io:println("Event Retrieved: \n", getResp.toJsonString()); @@ -96,13 +96,13 @@ public function main() returns error? { }; hsmevents:MarketingEventDefaultResponse completeResp = check - hubspotClient->postEventsExternaleventidComplete_complete("10000", completePayload, externalAccountId = "11111"); + hubspotMarketingClient->postEventsExternaleventidComplete_complete("10000", completePayload, externalAccountId = "11111"); io:println("Event Completed: ", completeResp?.objectId ?: "-1"); // Step 5: Delete Event - http:Response deleteResp = check hubspotClient->deleteObjectid(eventObjId); + http:Response deleteResp = check hubspotMarketingClient->deleteObjectid(eventObjId); io:println("Event Deleted: ", deleteResp.statusCode == 204 ? "Success" : "Failed"); };