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

Fix doc issues and make service url mandatory when initializing the client #8

Merged
merged 2 commits into from
Mar 27, 2024
Merged
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ To use the Zendesk Connector in Ballerina, you must have a Zendesk account and a

![Zendesk Admin Center](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/1-admin-center.png)

### Step 3: Manage API tokens
### Step 3: Create a new connection

1. In the Admin Center, click on **Apps and integrations**.
2. Click on **Connections** under the **Connections** section.
3. Click on **Create connection** to create a new connection.

![Zendesk Connection Settings](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/2-connection-settings.png)
![Zendesk Connection Settings](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/2-create-connection.png)

### Step 4: Configure & generate the token
### Step 4: Configure connection settings

When creating a new connection, you will be prompted to provide the following details:

Expand Down Expand Up @@ -71,7 +71,7 @@ zendesk:ConnectionConfig zendeskConfig = {
}
};

zendesk:Client zendesk = check new (zendeskConfig);
zendesk:Client zendesk = check new (zendeskConfig, "https://<your-domain>.zendesk.com");
```

### Step 3: Invoke the connector operation
Expand Down
8 changes: 4 additions & 4 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ To use the Zendesk Connector in Ballerina, you must have a Zendesk account and a

![Zendesk Admin Center](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/1-admin-center.png)

### Step 3: Manage API tokens
### Step 3: Create a new connection

1. In the Admin Center, click on **Apps and integrations**.
2. Click on **Connections** under the **Connections** section.
3. Click on **Create connection** to create a new connection.

![Zendesk Connection Settings](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/2-connection-settings.png)
![Zendesk Connection Settings](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/2-create-connection.png)

### Step 4: Configure & generate the token
### Step 4: Configure connection settings

When creating a new connection, you will be prompted to provide the following details:

Expand Down Expand Up @@ -65,7 +65,7 @@ zendesk:ConnectionConfig zendeskConfig = {
}
};

zendesk:Client zendesk = check new (zendeskConfig);
zendesk:Client zendesk = check new (zendeskConfig, "https://<your-domain>.zendesk.com");
```

### Step 3: Invoke the connector operation
Expand Down
8 changes: 4 additions & 4 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ To use the Zendesk Connector in Ballerina, you must have a Zendesk account and a

![Zendesk Admin Center](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/1-admin-center.png)

### Step 3: Manage API tokens
### Step 3: Create a new connection

1. In the Admin Center, click on **Apps and integrations**.
2. Click on **Connections** under the **Connections** section.
3. Click on **Create connection** to create a new connection.

![Zendesk Connection Settings](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/2-connection-settings.png)
![Zendesk Connection Settings](https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-zendesk/master/docs/setup/resources/2-create-connection.png)

### Step 4: Configure & generate the token
### Step 4: Configure connection settings

When creating a new connection, you will be prompted to provide the following details:

Expand Down Expand Up @@ -65,7 +65,7 @@ zendesk:ConnectionConfig zendeskConfig = {
}
};

zendesk:Client zendesk = check new (zendeskConfig);
zendesk:Client zendesk = check new (zendeskConfig, "https://<your-domain>.zendesk.com");
```

### Step 3: Invoke the connector operation
Expand Down
2 changes: 1 addition & 1 deletion ballerina/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public isolated client class Client {
# + config - The configurations to be used when initializing the `connector`
# + serviceUrl - URL of the target service
# + return - An error if connector initialization failed
public isolated function init(ConnectionConfig config, string serviceUrl = "https://example.zendesk.com") returns error? {
public isolated function init(ConnectionConfig config, string serviceUrl) returns error? {
http:ClientConfiguration httpClientConfig = {auth: config.auth, httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation};
do {
if config.http1Settings is ClientHttp1Settings {
Expand Down
7 changes: 0 additions & 7 deletions docs/spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ tags:
- name: Custom Object Records
- name: Essentials Card
- name: Omnichannel Routing Queues
servers:
- url: https://{subdomain}.{domain}.com
variables:
domain:
default: zendesk
subdomain:
default: example
paths:
/api/lotus/assignables/autocomplete.json:
get:
Expand Down
13 changes: 7 additions & 6 deletions docs/spec/sanitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ These changes are done in order to improve the overall usability, and as workaro

2. Use `--nullable` option when generating the client using the Ballerina OpenAPI tool.
* The ZenDesk API reference does not properly include the "nullable" property for some the request and response schemas.
* Therefore, the `--nullable` option is used as a precaution to avoid potential data-binding issues in the runtime,
which will generate all the request/response type fields with the support to handle null values.
* Therefore, the `--nullable` option is used as a precaution to avoid potential data-binding issues in the runtime, which will generate all the request/response type fields with the support to handle null values.
* This workaround can be removed once https://github.com/ballerina-platform/ballerina-library/issues/4870 is addressed.

3. Change the types `Organization_field_id` and `User_field_id` from `int|string?` to `int|string`.
* This is done as a post-workaround after using the `--nullable` option to generate the client, as nilable types are not supported for path parameters in Ballerina

4. Add `Accept` header (as `application/json`) to all the operations.
* The ZenDesk OpenAPI reference does not include the `Accept` header in the operations, but the server returns an
unsupported media type error if the `Accept` header is not included in the requests.
* The ZenDesk OpenAPI reference does not include the `Accept` header in the operations, but the server returns an unsupported media type error if the `Accept` header is not included in the requests.

5. Remove `servers` from the OpenAPI specification.
* Zendesk users are required to use their subdomain in the URL path to access the API.
* Therefore, the `servers` field is removed from the OpenAPI specification to make the server a required field when initializing the client.

## OpenAPI cli command

The following command was used to generate the Ballerina client from the OpenAPI specification. The command should be
executed from the repository root directory.
The following command was used to generate the Ballerina client from the OpenAPI specification. The command should be executed from the repository root directory.

```bash
bal openapi -i docs/spec/openapi.yaml --mode client --license docs/license.txt -o ballerina/ --nullable
Expand Down
Loading