-
Notifications
You must be signed in to change notification settings - Fork 1
Add examples for the connector #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8c775f9
Generate the Ballerina clien
LinukaAr e1c5dcb
[Automated] Update the toml files
LinukaAr 2e84333
[Automated] Update the toml files
LinukaAr 29e40a8
add tests
LinukaAr 5eede35
Regenarate files for updated bal version
LinukaAr 699fdc7
Add tests
LinukaAr 0ef3d5a
Update authentication mechanism
LinukaAr 9005883
[Automated] Update the toml files
LinukaAr aa4c407
Address PR review comments
LinukaAr 2fd43fd
Switch to zoom genaral app type
LinukaAr 48868b7
[Automated] Update the toml files
LinukaAr 4904d84
Add setup instructions
LinukaAr 3d8747c
Add requested changes from code review
LinukaAr 348c413
Change to specific types instead of json
LinukaAr 530e29a
Update the cli command
LinukaAr 7d7f878
Remove configurations related to tests
LinukaAr 6a29409
Use markdown image syntax
LinukaAr 285046f
Refactor error handling
LinukaAr a5d8608
Add missing details in doc
LinukaAr 68bf4f1
Add sts service
LinukaAr 084e64c
Update formatting in README
LinukaAr 6b92ce7
Improve clarity in README files
LinukaAr 82e7b1c
Merge branch 'ballerina-platform:main' into main
LinukaAr d0dfd00
Add examples for the connector
LinukaAr a260f5f
Add examples
LinukaAr 0f1413c
Merge branch 'main' of https://github.com/LinukaAr/module-ballerinax-…
LinukaAr b1aa1c6
Address PR review comments
LinukaAr f3fc1e0
Add symlinks
LinukaAr 22915d3
Refactor schedule segments
LinukaAr 06968f7
Refactor event handling logic
LinukaAr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LinukaAr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "image": "ballerina/ballerina-devcontainer:2201.12.7", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": ["WSO2.ballerina"] | ||
| } | ||
| } | ||
| } |
LinukaAr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Ballerina generates this directory during the compilation of a package. | ||
| # It contains compiler-generated artifacts and the final executable if this is an application package. | ||
| target/ | ||
|
|
||
| # Ballerina maintains the compiler-generated source code here. | ||
| # Remove this if you want to commit generated sources. | ||
| generated/ | ||
|
|
||
| # Contains configuration values used during development time. | ||
| # See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details. | ||
| Config.toml |
LinukaAr marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Zoom Scheduler Availability Manager | ||
|
|
||
| This example demonstrates how to manage availability schedules and retrieve analytics using the Zoom Scheduler connector in Ballerina. The example shows how to fetch user information, create availability schedules, and monitor scheduler analytics. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### 1. Setup Zoom developer account | ||
|
|
||
| Create a Zoom app with the following scopes: | ||
| - `scheduler:read` | ||
| - `scheduler:write` | ||
| - `user:read` | ||
|
|
||
| ### 2. Configuration | ||
|
|
||
| Create a `Config.toml` file in the example's root directory and provide your Zoom account related configurations as follows: | ||
|
|
||
| ```bash | ||
| clientId = "<Client ID>" | ||
| clientSecret = "<Client Secret>" | ||
| refreshToken = "<Refresh Token>" | ||
| userId = "<User ID>" | ||
| ``` | ||
|
|
||
| ## Run the example | ||
|
|
||
| Execute the following command to run the example: | ||
|
|
||
| ```bash | ||
| bal | ||
LinukaAr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [package] | ||
| org = "wso2" | ||
| name = "availability_manager" | ||
| version = "0.1.0" | ||
| distribution = "2201.12.7" | ||
|
|
||
| [build-options] | ||
| observabilityIncluded = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| // 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 | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import ballerina/io; | ||
| import ballerinax/zoom.scheduler; | ||
|
|
||
| configurable string clientId = ?; | ||
| configurable string clientSecret = ?; | ||
| configurable string refreshToken = ?; | ||
| configurable string userId = ?; | ||
|
|
||
| final scheduler:Client zoomClient = check new ({ | ||
| auth: { | ||
| clientId, | ||
| clientSecret, | ||
| refreshUrl: "https://zoom.us/oauth/token", | ||
| refreshToken | ||
| } | ||
| }); | ||
|
|
||
| public function main() returns error? { | ||
| scheduler:InlineResponse2007 userInfo = check zoomClient->/users/[userId].get(); | ||
| io:println("User: ", userInfo.displayName, " | Timezone: ", userInfo.timeZone); | ||
| scheduler:InlineResponse200 analytics = check zoomClient->/analytics.get( | ||
| userId = userId, | ||
| 'from = "2025-01-01", | ||
| to = "2025-12-31" | ||
| ); | ||
|
|
||
| if analytics.lastNDays is scheduler:InlineResponse200LastNDays { | ||
| scheduler:InlineResponse200LastNDays stats = <scheduler:InlineResponse200LastNDays>analytics.lastNDays; | ||
| io:println("Analytics - Events Created: ", stats.scheduledEventsCreated ?: 0, | ||
| " | Completed: ", stats.scheduledEventsCompleted ?: 0, | ||
| " | Canceled: ", stats.scheduledEventsCanceled ?: 0); | ||
| } | ||
|
|
||
| scheduler:InlineResponse2001 availabilityResponse = check zoomClient->/availability.get( | ||
| userId = userId, | ||
| pageSize = 10 | ||
| ); | ||
|
|
||
| if availabilityResponse.items is scheduler:InlineResponse2001Items[] { | ||
| scheduler:InlineResponse2001Items[] availabilities = <scheduler:InlineResponse2001Items[]>availabilityResponse.items; | ||
| io:println("Availability Schedules: ", availabilities.length()); | ||
| foreach scheduler:InlineResponse2001Items availability in availabilities { | ||
| io:println("- ", availability.name, " (", availability.timeZone, "), ID: ", availability.availabilityId); | ||
| io:println("Owner: ", availability.owner ?: "Unknown"); | ||
| } | ||
| } | ||
|
|
||
| boolean shouldCreateNew = true; | ||
| if availabilityResponse.items is scheduler:InlineResponse2001Items[] { | ||
| scheduler:InlineResponse2001Items[] availabilities = <scheduler:InlineResponse2001Items[]>availabilityResponse.items; | ||
| int extendedHoursCount = 0; | ||
| foreach scheduler:InlineResponse2001Items availability in availabilities { | ||
| if availability.name == "Extended Office Hours" { | ||
| extendedHoursCount += 1; | ||
| } | ||
| } | ||
| if extendedHoursCount >= 3 { | ||
| shouldCreateNew = false; | ||
| io:println("Skipping creation - already have ", extendedHoursCount, " Extended Office Hours schedules"); | ||
| } | ||
| } | ||
|
|
||
| if shouldCreateNew { | ||
| scheduler:SchedulerAvailabilityBody newAvailability = { | ||
| name: "Extended Office Hours", | ||
| timeZone: "America/New_York", | ||
| segmentsRecurrence: { | ||
| mon: [{ | ||
| 'start: "08:00", | ||
| end: "18:00" | ||
| }], | ||
| tue: [{ | ||
| 'start: "08:00", | ||
| end: "18:00" | ||
| }], | ||
| wed: [{ | ||
| 'start: "08:00", | ||
| end: "18:00" | ||
| }], | ||
| thu: [{ | ||
| 'start: "08:00", | ||
| end: "18:00" | ||
| }], | ||
| fri: [{ | ||
| 'start: "08:00", | ||
| end: "16:00" | ||
| }] | ||
| } | ||
| }; | ||
|
|
||
| scheduler:InlineResponse201 createdAvailability = check zoomClient->/availability.post( | ||
| payload = newAvailability | ||
|
|
||
| io:println("Created new availability: ", createdAvailability.name, " (", createdAvailability.availabilityId, ")"); | ||
| } | ||
|
|
||
| scheduler:InlineResponse2005|error allSchedulesResult = zoomClient->/schedules.get( | ||
| userId = userId, | ||
| pageSize = 5, | ||
| showDeleted = false | ||
| ); | ||
|
|
||
| if allSchedulesResult is scheduler:InlineResponse2005 { | ||
| scheduler:InlineResponse2005 allSchedules = allSchedulesResult; | ||
| if allSchedules.items is scheduler:InlineResponse2005Items[] { | ||
| scheduler:InlineResponse2005Items[] schedules = <scheduler:InlineResponse2005Items[]>allSchedules.items; | ||
| io:println("Active Schedules: ", schedules.length()); | ||
| foreach scheduler:InlineResponse2005Items schedule in schedules { | ||
| io:println("- ", schedule.summary, " (", schedule.duration, "min, ", schedule.capacity, " attendees)"); | ||
| } | ||
| } else { | ||
| io:println("No schedules found"); | ||
| } | ||
| } else { | ||
| io:println("Error fetching schedules: ", allSchedulesResult.message()); | ||
| } | ||
| } |
LinukaAr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "image": "ballerina/ballerina-devcontainer:2201.12.7", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": ["WSO2.ballerina"] | ||
| } | ||
| } | ||
| } |
LinukaAr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Ballerina generates this directory during the compilation of a package. | ||
| # It contains compiler-generated artifacts and the final executable if this is an application package. | ||
| target/ | ||
|
|
||
| # Ballerina maintains the compiler-generated source code here. | ||
| # Remove this if you want to commit generated sources. | ||
| generated/ | ||
|
|
||
| # Contains configuration values used during development time. | ||
| # See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details. | ||
| Config.toml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [package] | ||
| org = "wso2" | ||
| name = "meeting_scheduler" | ||
| version = "0.1.0" | ||
| distribution = "2201.12.7" | ||
|
|
||
| [build-options] | ||
| observabilityIncluded = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Zoom Scheduler Meeting Scheduler | ||
|
|
||
| This example demonstrates how to create and manage meeting schedules using the Zoom Scheduler connector in Ballerina. The example shows how to create new schedules, fetch schedule details, and list existing schedules. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### 1. Setup Zoom developer account | ||
|
|
||
| Create a Zoom OAuth with the following scopes: | ||
| - `scheduler:read` | ||
| - `scheduler:write` | ||
| - `user:read` | ||
|
|
||
| ### 2. Configuration | ||
|
|
||
| Create a `Config.toml` file in the example's root directory and provide your Zoom account related configurations as follows: | ||
|
|
||
| ```bash | ||
| clientId = "<Client ID>" | ||
| clientSecret = "<Client Secret>" | ||
| refreshToken = "<Refresh Token>" | ||
| userId = "<User ID>" | ||
| ``` | ||
|
|
||
| ## Run the example | ||
|
|
||
| Execute the following command to run the example: | ||
|
|
||
| ```bash | ||
| bal run | ||
LinukaAr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.