Skip to content
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

Improve images and examples #7

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
Binary file modified docs/setup/resources/1-developer-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/setup/resources/2-create-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/setup/resources/3-copy-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Examples

The `ballerinax/asana` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-asana/tree/master/examples), covering use cases like cache management, session management, and rate limiting.
NipunaRanasinghe marked this conversation as resolved.
Show resolved Hide resolved

1. [Employee onboarding process automation](https://github.com/ballerina-platform/module-ballerinax-asana/tree/master/examples/employee-onboarding-process-automation) - Automate the onboarding process of new employees using Asana projects and tasks.

2. [Team workload balancer](https://github.com/ballerina-platform/module-ballerinax-asana/tree/master/examples/team-workload-balancer) - Evaluate and balance the workload of a given team using Asana tasks and assignments.


## Prerequisites

1. Create an Asana personal access token (PAT) to authenticate the connector as described in the [Setup guide](https://central.ballerina.io/ballerinax/asana/latest#setup-guide).

2. For each example, create a `Config.toml` file the related configuration. Here's an example of how your `Config.toml` file should look:

```toml
authToken="<auth_token>"
workspaceId="<workspace_id>"
```

## Running an Example

Execute the following commands to build an example from the source:

* To build an example:

```bash
bal build
```

* To run an example:

```bash
bal run
```

## Building the Examples with the Local Module

**Warning**: Due to the absence of support for reading local repositories for single Ballerina files, the Bala of the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your local Ballerina repositories.

Execute the following commands to build all the examples against the changes you have made to the module locally:

* To build all the examples:

```bash
./build.sh build
```
ayeshLK marked this conversation as resolved.
Show resolved Hide resolved

* To run all the examples:

```bash
./build.sh run
```
56 changes: 48 additions & 8 deletions examples/employee-onboarding-process-automation/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,55 @@ asana:Client asana = check new (asanaConfig);
// Function to automate the creation of an employee onboarding project with tasks
public function main() returns error? {

record {asana:ProjectCompact[] data?;} projects = check asana->/projects();

asana:Tasks_body taskReq = {
// Step 1: Create a new onboarding project
asana:Projects_body projectBody = {
data: {
name: "Email Marketing Campaign",
notes: "Create a new email marketing campaign for the upcoming product launch.",
workspace: "<workspaceId>",
projects: ["<projectId>"]
name: "Onboarding - " + newEmployeeName,
workspace: workspaceId,
team: teamId
}
};
record {asana:TaskResponse data?;} taskCreated = check asana->/tasks.post(taskReq);

asana:Inline_response_201_5|error projectResponse = asana->/projects.post(projectBody);
if projectResponse is error {
return error("error creating project: " + projectResponse.message());
}

string? projectId = projectResponse?.data?.gid;
if projectId is () {
return error("project ID not found in response");
}

// Step 2: Add sections to the new project
string[] sections = ["Documentation", "Training", "Setup"];
foreach string sectionName in sections {
asana:Project_gid_sections_body sectionBody = {
data: {
name: sectionName
}
};

asana:Inline_response_200_30|error sectionCreationResult = asana->/projects/[projectId]/sections.post(sectionBody);
if sectionCreationResult is error {
return error("error creating section: " + sectionCreationResult.message());
}
}

// Step 3: Create tasks within each section (simplified for brevity)
// In a complete implementation, you'd likely query the sections of the project first to get their IDs.
string[] tasks = ["Complete HR paperwork", "Setup work email", "Attend orientation session"];
foreach string taskName in tasks {
asana:Tasks_body newTaskPayload = {
data: {
name: taskName,
projects: [projectId],
assignee_section: "<section_id>"
}
};

asana:Inline_response_201_7|error taskCreationResponse = asana->/tasks.post(newTaskPayload);
if taskCreationResponse is error {
return error("error creating task: " + taskCreationResponse.message());
}
}
}
Loading