Skip to content

Commit

Permalink
Improve Candid connector documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AzeemMuzammil committed Feb 16, 2024
1 parent 23c03db commit 2d09e70
Show file tree
Hide file tree
Showing 49 changed files with 814 additions and 231 deletions.
52 changes: 46 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Compiled class file
*.class

*.balx
# Log file
*.log

Expand All @@ -11,24 +11,64 @@
.mtj.tmp/

# Package Files #
*.jar
!gradle/**/*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
*.deb

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# Ignore everything in this directory
target
.classpath
.settings
.project
*.iml
*.iws
*.ipr
.idea
.m2
.vscode/
# Ignore ballerina files
accessToken.bal
temp.bal
*.conf
*Ballerina.lock
#Ignore doc files
target/
.ballerina

# Ignore resource .json files
**/resources/*.json

github/tests/Config.toml
github/modules/webhook/tests/Config.toml

Config.toml

# Ballerina related ignores
Ballerina.lock

# Compiled class file
*.class

# Log file
*.log

# DS_Store file
*.DS_Store

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
target

# Environment files
*.env

# Ignore all Dependencies.toml files in the examples directory
examples/**/Dependencies.toml
153 changes: 110 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,134 @@
# Ballerina Candid Connector

[![CI](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/ci.yml)
[![Build](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/ci.yml)
[![Trivy](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/trivy-scan.yml)
[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-candid/branch/master/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-candid)
[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-candid/actions/workflows/build-with-bal-test-graalvm.yml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-candid.svg)](https://github.com/ballerina-platform/module-ballerinax-candid/commits/master)
[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/candid.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fcandid)

[Candid](https://candid.org/) is a non-profit organization that provides a comprehensive database of information about nonprofits, foundations, grantmakers, and philanthropists. Their mission is to connect people who want to change the world to the resources they need to do it.

The `ballerinax/candid` module provides APIs to allow to access Candid's database that includes information on over 2 million nonprofits, including their mission, programs, finances, and leadership. And also provides information on over 100,000 foundations and grantmakers, as well as data on individual philanthropists.
This Ballerina connector is designed to interface with Candid.org's API, enabling developers to access Candid's resources programmatically. It supports various operations, such as searching for nonprofit organizations, accessing grant data, and retrieving information about philanthropic trends and insights.

Currently, the following Candid APIs are supported through this module

- Charity Check PDF API
- **Charity Check PDF API**
- The Charity Check PDF API is a powerful tool that allows to download formatted Charity Check PDF reports for individual nonprofits.
- Essentials API
- **Essentials API**
- The Essentials API is a lightweight API that provides basic information about nonprofits, such as their name, address, EIN, and mission statement. It is ideal for applications that need to quickly and easily identify and access basic nonprofit data.
- Premier API
- **Premier API**
- The Premier API is a more comprehensive API that provides access to a wider range of nonprofit data, including financial information, staffing data, grantmaking data, and DEI data. It is ideal for applications that need to deep dive into the data of individual nonprofits or perform complex analyses of nonprofit data.

## Samples
## Setup Guide
To use the Candid.org Connector in Ballerina, you must first obtain an API key from Candid.org.

### Charity Check PDF API
### Step 1: Visit Candid's Developer API Access page
1. Visit [Candid's Developer API Access](https://developer.candid.org/reference/getting-access) page.
2. Review the documentation to understand the type of access suits your need.

The following Ballerina program generates a PDF report to validate nonprofit status and eligibility with a 100% IRS-compliant charity check.
### Step 2: Request API Access
- **For a Trial Account:** If you're looking for trial access to explore Candid's API, complete the [form](https://info.candid.org/API-free-trial) to request trial access. Candid.org will review your request and get in touch with you regarding your trial API key.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-candid/master/docs/setup/resources/1-trial-account-form.png alt="Candid API Access Form" width="50%">

- **For a Production Account:** If you require access for production use, fill out the [form](https://info.candid.org/API-info-request) to initiate the process. Candid.org will contact you to discuss your needs and provide you with a production API key.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-candid/master/docs/setup/resources/2-prod-account-form.png alt="Candid API Access Form" width="50%">

## Quickstart

To use the `Candid` connector in your Ballerina application, modify the `.bal` file as follows:

### Step 1: Import the connector

Import the relevent Candid module into your Ballerina project.

#### Charity Check PDF API
```ballerina
import ballerinax/candid.charitycheckpdf;
```

charitycheckpdf:ApiKeysConfig apiKeyConfig = {subscriptionKey: "ENTER-THE-SUBSCRIPTION-KEY"};
charitycheckpdf:Client charitycheckpdf = check new charitycheckpdf:Client(apiKeyConfig);
#### Essentials API
```ballerina
import ballerinax/candid.essentials;
```

function getCharityCheckPDF() returns http:Response|error {
http:Response|error result = charitycheckpdf->/v1/pdf/["EMP-ID-NUM"];
return result;
}
#### Premier API
```ballerina
import ballerinax/candid.premier;
```

### Essentials API
### Step 2: Instantiate a new connector

The following Ballerina program finds nonprofits using search criterias and explore essential information.
Create an instance of `ApiKeysConfig` with the obtained Subscription Key and initialize the connector with it.

#### Charity Check PDF API
```ballerina
import ballerinax/candid.essentials;
charitycheckpdf:ApiKeysConfig apiKeyConfig = {
subscriptionKey: "ENTER-THE-SUBSCRIPTION-KEY"
};
charitycheckpdf:Client charitycheckpdf = check new (apiKeyConfig);
```

#### Essentials API
```ballerina
essentials:ApiKeysConfig apiKeyConfig = {
subscriptionKey: "ENTER-THE-SUBSCRIPTION-KEY"
};
essentials:Client essentials = check new (apiKeyConfig);
```

essentials:ApiKeysConfig apiKeyConfig = {subscriptionKey: "ENTER-THE-SUBSCRIPTION-KEY"};
essentials:Client essentials = check new essentials:Client(apiKeyConfig);
#### Premier API
```ballerina
premier:ApiKeysConfig apiKeyConfig = {
subscriptionKey: "ENTER-THE-SUBSCRIPTION-KEY"
};
premier:Client premier = check new (apiKeyConfig);
```

### Step 3: Invoke the connector operation

Now, utilize the available connector operations.

function getV3Essesntials() returns essentials:V3EssentialsResponse|error {
essentials:V3Query query = {
search_terms: "candid"
};
essentials:V3EssentialsResponse|error result = essentials->/v3.post(query);
#### Charity Check PDF API
The following Ballerina program generates a PDF report to validate nonprofit status and eligibility with a 100% IRS-compliant charity check.

```ballerina
http:Response|error result = charitycheckpdf->/v1/pdf/["EMP-ID-NUM"];
return result;
}
```

### Premier API
#### Essentials API
The following Ballerina program finds nonprofits using search criterias and explore essential information.

```ballerina
essentials:V3Query query = {
search_terms: "candid"
};
essentials:V3EssentialsResponse|error result = essentials->/v3.post(query);
```

#### Premier API
The following Ballerina program retrieves data on a nonprofit's financials, people, DEI, and IRS compliance validation for the given employer id number.

```ballerina
import ballerinax/candid.premier;
premier:V3PublicProfile|error result = check premier->/v3/["EMP-ID-NUM"];
```

premier:ApiKeysConfig apiKeyConfig = {subscriptionKey: "ENTER-THE-SUBSCRIPTION-KEY"};
premier:Client premier = check new premier:Client(apiKeyConfig);
## Examples

function getV3Premier() returns premier:V3PublicProfile|error {
premier:V3PublicProfile|error result = check premier->/v3/["EMP-ID-NUM"];
return result;
}
```
The `Candid` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-candid/tree/master/examples) to understand how to interact with the Candid.org API for tasks such as generating compliance reports, searching for essential nonprofit information, and retrieving detailed employer data.

1. [Generate Charity Check PDF](https://github.com/ballerina-platform/module-ballerinax-candid/tree/master/examples/generate-charity-check-pdf) - Generate a detailed Charity Check PDF for a specified nonprofit organization using Candid.org's API.

2. [Search Essential Information](https://github.com/ballerina-platform/module-ballerinax-candid/tree/master/examples/search-essential-information) - Search for and retrieve essential information about nonprofit organizations through the Candid.org Essentials API.

3. [Get Employer Information](https://github.com/ballerina-platform/module-ballerinax-candid/tree/master/examples/get-employer-information) - Obtain comprehensive employer information for nonprofit organizations using the Candid.org Premier API.

## Issues and projects
## Issues and projects

The **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library).
The **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library).

This repository only contains the source code for the package.

Expand All @@ -100,37 +154,50 @@ This repository only contains the source code for the package.
Execute the commands below to build from the source.

1. To build the package:
```

```bash
./gradlew clean build
```

2. To run the tests:
```

```bash
./gradlew clean test
```

3. To build the without the tests:
```

```bash
./gradlew clean build -x test
```

5. To debug package with a remote debugger:
4. To run tests against different environment:

```bash
./gradlew clean test -Pgroups=<Comma separated groups/test cases>
```

5. To debug package with a remote debugger:

```bash
./gradlew clean build -Pdebug=<port>
```

6. To debug with the Ballerina language:
```

```bash
./gradlew clean build -PbalJavaDebug=<port>
```

7. Publish the generated artifacts to the local Ballerina Central repository:
```

```bash
./gradlew clean build -PpublishToLocalCentral=true
```

8. Publish the generated artifacts to the Ballerina Central repository:
```

```bash
./gradlew clean build -PpublishToCentral=true
```

Expand Down
3 changes: 0 additions & 3 deletions ballerina/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
org = "ballerinax"
name = "candid"
version = "0.1.0"
version = "0.2.0"
authors = ["Ballerina"]
export = ["candid", "candid.charitycheckpdf", "candid.essentials", "candid.premier"]
keywords = ["Candid", "Nonprofit Data", "Philanthropy Data", "Nonprofit APIs"]
repository = "https://github.com/ballerina-platform/module-ballerinax-candid"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.8.0"
distribution = "2201.8.4"
10 changes: 5 additions & 5 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.8.0"
distribution-version = "2201.8.4"

[[package]]
org = "ballerina"
Expand All @@ -22,7 +22,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "cache"
version = "3.7.0"
version = "3.7.1"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -61,7 +61,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.3"
version = "2.10.7"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -241,7 +241,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.2.0"
version = "1.2.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down Expand Up @@ -302,7 +302,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "candid"
version = "0.1.0"
version = "0.2.0"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "log"},
Expand Down
Loading

0 comments on commit 2d09e70

Please sign in to comment.