Skip to content
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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Runnable examples are available in the [`examples/`](./examples) directory:

- [`examples/basic_usage.js`](./examples/basic_usage.js) - Client setup, connections, integrations, and webhooks
- [`examples/proxy_api.js`](./examples/proxy_api.js) - Proxy API GET request with a connection
- [`examples/unify_api.js`](./examples/unify_api.js) - Unify Chat, Git, and PM endpoint usage
- [`examples/unify_api.js`](./examples/unify_api.js) - Unify Chat, Git, and Ticketing endpoint usage
- [`examples/README.md`](./examples/README.md) - Setup and execution instructions

## Quick Start
Expand Down Expand Up @@ -840,20 +840,20 @@ console.log('Releases:', result.data);
}
```

#### Project Management API
#### Ticketing API

The PM API provides a unified interface for project management platforms like Jira, Linear, and Asana.
The Ticketing API provides a unified interface for ticketing and project management platforms like Jira, Linear, and Asana.

##### List Issues
##### List Tickets

```javascript
const result = await unify.pm.issues({
const result = await unify.ticketing.tickets({
limit: 100,
after: null,
include_raw: false,
});

console.log('Issues:', result.data);
console.log('Tickets:', result.data);
```

**Response:**
Expand All @@ -880,7 +880,7 @@ console.log('Issues:', result.data);
**Filtering and sorting:**

```javascript
const openIssues = result.data.filter(issue => issue.status === 'open');
const openTickets = result.data.filter(ticket => ticket.status === 'open');
const sortedByDate = result.data.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
```

Expand Down Expand Up @@ -950,7 +950,7 @@ src/
│ ├── base.ts # Base Unify class
│ ├── chat.ts # Chat Unify API
│ ├── git.ts # Git Unify API
│ └── pm.ts # PM Unify API
│ └── ticketing.ts # Ticketing Unify API
└── __tests__/ # Test files
```

Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ node examples/unify_api.js

- `basic_usage.js` — initialize the SDK and list connections, integrations, and webhooks
- `proxy_api.js` — send a GET request through the Proxy API
- `unify_api.js` — call Unify Chat, Git, and PM endpoints
- `unify_api.js` — call Unify Chat, Git, and Ticketing endpoints
6 changes: 3 additions & 3 deletions examples/unify_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ try {
}

try {
const issues = await unify.pm.issues({ limit: 10 });
console.log(`PM issues: ${issues.data?.length ?? 0}`);
const tickets = await unify.ticketing.tickets({ limit: 10 });
console.log(`Ticketing tickets: ${tickets.data?.length ?? 0}`);
} catch (error) {
console.error(`Failed to fetch PM issues: ${error.message}`);
console.error(`Failed to fetch tickets: ${error.message}`);
}
26 changes: 13 additions & 13 deletions src/__tests__/unify.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Unify } from '../unify';
import { Chat } from '../unify/chat';
import { Git } from '../unify/git';
import { PM } from '../unify/pm';
import { Ticketing } from '../unify/ticketing';

// Mock the global fetch function
global.fetch = jest.fn();
Expand Down Expand Up @@ -63,23 +63,23 @@ describe('Unify', () => {
});
});

describe('pm getter', () => {
it('should return a PM instance', () => {
const pm = unify.pm;
expect(pm).toBeInstanceOf(PM);
describe('ticketing getter', () => {
it('should return a Ticketing instance', () => {
const ticketing = unify.ticketing;
expect(ticketing).toBeInstanceOf(Ticketing);
});

it('should create a new PM instance each time', () => {
const pm1 = unify.pm;
const pm2 = unify.pm;
expect(pm1).not.toBe(pm2);
it('should create a new Ticketing instance each time', () => {
const ticketing1 = unify.ticketing;
const ticketing2 = unify.ticketing;
expect(ticketing1).not.toBe(ticketing2);
});

it('should initialize PM with correct apiKey and connectionId', () => {
const pm = unify.pm;
it('should initialize Ticketing with correct apiKey and connectionId', () => {
const ticketing = unify.ticketing;
// Access protected properties for testing
expect((pm as any).apiKey).toBe(apiKey);
expect((pm as any).connectionId).toBe(connectionId);
expect((ticketing as any).apiKey).toBe(apiKey);
expect((ticketing as any).connectionId).toBe(connectionId);
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/unify.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chat } from './unify/chat';
import { Git } from './unify/git';
import { PM } from './unify/pm';
import { Ticketing } from './unify/ticketing';

export class Unify {
constructor(
Expand All @@ -23,9 +23,9 @@ export class Unify {
}

/**
* Access the PM API for the connection.
* Access the Ticketing API for the connection.
*/
get pm() {
return new PM(this.apiKey, this.connectionId);
get ticketing() {
return new Ticketing(this.apiKey, this.connectionId);
}
}
14 changes: 7 additions & 7 deletions src/unify/pm.ts → src/unify/ticketing.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Base, type Params, type Response } from './base';

export class PM extends Base {
protected namespace = 'pm';
export class Ticketing extends Base {
protected namespace = 'ticketing';

/**
* Fetch issues
* @param limit - Maximum number of issues to retrieve.
* Fetch tickets
* @param limit - Maximum number of tickets to retrieve.
* @param after - Cursor for pagination.
* @param include_raw - Whether to include raw response data.
* @returns A promise that resolves to the fetch response.
*/
async issues({ limit = 100, after, include_raw = false }: Params = {}) {
const url = this.buildUrl('issues', { limit, after, include_raw });
async tickets({ limit = 100, after, include_raw = false }: Params = {}) {
const url = this.buildUrl('tickets', { limit, after, include_raw });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep ticket listing on the live API route

The published Unify Swagger page (https://unify.bundleup.io/) still advertises GET /v1/pm/issues and does not expose /v1/ticketing/tickets; with this change tickets() now builds /v1/ticketing/tickets, so ticket listing calls from the SDK will hit an unavailable route for current deployments. Please retain the live pm/issues route or add a compatibility fallback until the server migration is deployed.

Useful? React with 👍 / 👎.


const response = await fetch(url, { headers: this.headers });

if (!response.ok) {
throw new Error(`Failed to fetch ${this.namespace}/issues: ${response.statusText}`);
throw new Error(`Failed to fetch ${this.namespace}/tickets: ${response.statusText}`);
}

const data = await response.json();
Expand Down
Loading