@withaevum/sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +621 -0
- package/dist/analytics.d.ts +17 -0
- package/dist/analytics.js +46 -0
- package/dist/availability.d.ts +39 -0
- package/dist/availability.js +164 -0
- package/dist/bookings.d.ts +42 -0
- package/dist/bookings.js +148 -0
- package/dist/calendar.d.ts +13 -0
- package/dist/calendar.js +65 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.js +162 -0
- package/dist/customers.d.ts +33 -0
- package/dist/customers.js +83 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.js +54 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/offerings.d.ts +107 -0
- package/dist/offerings.js +437 -0
- package/dist/orgs.d.ts +24 -0
- package/dist/orgs.js +30 -0
- package/dist/payments.d.ts +33 -0
- package/dist/payments.js +26 -0
- package/dist/providers.d.ts +57 -0
- package/dist/providers.js +108 -0
- package/dist/types.d.ts +687 -0
- package/dist/types.js +2 -0
- package/dist/webhooks.d.ts +176 -0
- package/dist/webhooks.js +153 -0
- package/package.json +52 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AevumClient } from './client';
|
|
2
|
+
import type { Customer, CreateCustomerParams, UpdateCustomerParams, ListCustomersParams, ListCustomersResponse, CustomerHistoryResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Customers API methods
|
|
5
|
+
*/
|
|
6
|
+
export declare class CustomersAPI {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: AevumClient);
|
|
9
|
+
/**
|
|
10
|
+
* List customers for the organization
|
|
11
|
+
*/
|
|
12
|
+
list(params?: ListCustomersParams): Promise<ListCustomersResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Get a single customer by ID
|
|
15
|
+
*/
|
|
16
|
+
get(customerId: string): Promise<Customer>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new customer (or merge if email exists)
|
|
19
|
+
*/
|
|
20
|
+
create(params: CreateCustomerParams): Promise<Customer>;
|
|
21
|
+
/**
|
|
22
|
+
* Update an existing customer
|
|
23
|
+
*/
|
|
24
|
+
update(customerId: string, params: UpdateCustomerParams): Promise<Customer>;
|
|
25
|
+
/**
|
|
26
|
+
* Get customer booking history with analytics
|
|
27
|
+
*/
|
|
28
|
+
getHistory(customerId: string): Promise<CustomerHistoryResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete a customer
|
|
31
|
+
*/
|
|
32
|
+
delete(customerId: string): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Customers API methods
|
|
3
|
+
*/
|
|
4
|
+
export class CustomersAPI {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* List customers for the organization
|
|
10
|
+
*/
|
|
11
|
+
async list(params) {
|
|
12
|
+
const query = {};
|
|
13
|
+
if (params?.q) {
|
|
14
|
+
query.q = params.q;
|
|
15
|
+
}
|
|
16
|
+
if (params?.providerId) {
|
|
17
|
+
query.providerId = params.providerId;
|
|
18
|
+
}
|
|
19
|
+
if (params?.page !== undefined) {
|
|
20
|
+
query.page = params.page;
|
|
21
|
+
}
|
|
22
|
+
if (params?.pageSize !== undefined) {
|
|
23
|
+
query.pageSize = params.pageSize;
|
|
24
|
+
}
|
|
25
|
+
return this.client.request('GET', '/api/v1/orgs/{orgId}/customers', { query });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get a single customer by ID
|
|
29
|
+
*/
|
|
30
|
+
async get(customerId) {
|
|
31
|
+
const response = await this.client.request('GET', `/api/v1/orgs/{orgId}/customers/${customerId}`);
|
|
32
|
+
return response.customer;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a new customer (or merge if email exists)
|
|
36
|
+
*/
|
|
37
|
+
async create(params) {
|
|
38
|
+
const body = {};
|
|
39
|
+
if (params.name !== undefined) {
|
|
40
|
+
body.name = params.name;
|
|
41
|
+
}
|
|
42
|
+
if (params.email !== undefined) {
|
|
43
|
+
body.email = params.email;
|
|
44
|
+
}
|
|
45
|
+
if (params.phone !== undefined) {
|
|
46
|
+
body.phone = params.phone;
|
|
47
|
+
}
|
|
48
|
+
if (params.userId !== undefined) {
|
|
49
|
+
body.userId = params.userId;
|
|
50
|
+
}
|
|
51
|
+
const response = await this.client.request('POST', '/api/v1/orgs/{orgId}/customers', { body });
|
|
52
|
+
return response.customer;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update an existing customer
|
|
56
|
+
*/
|
|
57
|
+
async update(customerId, params) {
|
|
58
|
+
const body = {};
|
|
59
|
+
if (params.name !== undefined) {
|
|
60
|
+
body.name = params.name;
|
|
61
|
+
}
|
|
62
|
+
if (params.email !== undefined) {
|
|
63
|
+
body.email = params.email;
|
|
64
|
+
}
|
|
65
|
+
if (params.phone !== undefined) {
|
|
66
|
+
body.phone = params.phone;
|
|
67
|
+
}
|
|
68
|
+
const response = await this.client.request('PATCH', `/api/v1/orgs/{orgId}/customers/${customerId}`, { body });
|
|
69
|
+
return response.customer;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get customer booking history with analytics
|
|
73
|
+
*/
|
|
74
|
+
async getHistory(customerId) {
|
|
75
|
+
return this.client.request('GET', `/api/v1/orgs/{orgId}/customers/${customerId}/history`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Delete a customer
|
|
79
|
+
*/
|
|
80
|
+
async delete(customerId) {
|
|
81
|
+
await this.client.request('DELETE', `/api/v1/orgs/{orgId}/customers/${customerId}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Aevum SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class AevumError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when an API request fails
|
|
9
|
+
*/
|
|
10
|
+
export declare class AevumAPIError extends AevumError {
|
|
11
|
+
readonly status: number;
|
|
12
|
+
readonly code?: string;
|
|
13
|
+
readonly issues?: Array<{
|
|
14
|
+
path: string[];
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
constructor(message: string, status: number, code?: string, issues?: Array<{
|
|
18
|
+
path: string[];
|
|
19
|
+
message: string;
|
|
20
|
+
}>);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown for authentication failures (401, 403)
|
|
24
|
+
*/
|
|
25
|
+
export declare class AevumAuthenticationError extends AevumAPIError {
|
|
26
|
+
constructor(message: string, status?: number);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown for validation errors (400)
|
|
30
|
+
*/
|
|
31
|
+
export declare class AevumValidationError extends AevumAPIError {
|
|
32
|
+
constructor(message: string, issues?: Array<{
|
|
33
|
+
path: string[];
|
|
34
|
+
message: string;
|
|
35
|
+
}>);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when a resource is not found (404)
|
|
39
|
+
*/
|
|
40
|
+
export declare class AevumNotFoundError extends AevumAPIError {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// packages/sdk/src/errors.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base error class for all Aevum SDK errors
|
|
4
|
+
*/
|
|
5
|
+
export class AevumError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'AevumError';
|
|
9
|
+
Object.setPrototypeOf(this, AevumError.prototype);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when an API request fails
|
|
14
|
+
*/
|
|
15
|
+
export class AevumAPIError extends AevumError {
|
|
16
|
+
constructor(message, status, code, issues) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'AevumAPIError';
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.issues = issues;
|
|
22
|
+
Object.setPrototypeOf(this, AevumAPIError.prototype);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error thrown for authentication failures (401, 403)
|
|
27
|
+
*/
|
|
28
|
+
export class AevumAuthenticationError extends AevumAPIError {
|
|
29
|
+
constructor(message, status = 401) {
|
|
30
|
+
super(message, status);
|
|
31
|
+
this.name = 'AevumAuthenticationError';
|
|
32
|
+
Object.setPrototypeOf(this, AevumAuthenticationError.prototype);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Error thrown for validation errors (400)
|
|
37
|
+
*/
|
|
38
|
+
export class AevumValidationError extends AevumAPIError {
|
|
39
|
+
constructor(message, issues) {
|
|
40
|
+
super(message, 400, 'validation_error', issues);
|
|
41
|
+
this.name = 'AevumValidationError';
|
|
42
|
+
Object.setPrototypeOf(this, AevumValidationError.prototype);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Error thrown when a resource is not found (404)
|
|
47
|
+
*/
|
|
48
|
+
export class AevumNotFoundError extends AevumAPIError {
|
|
49
|
+
constructor(message = 'Resource not found') {
|
|
50
|
+
super(message, 404, 'not_found');
|
|
51
|
+
this.name = 'AevumNotFoundError';
|
|
52
|
+
Object.setPrototypeOf(this, AevumNotFoundError.prototype);
|
|
53
|
+
}
|
|
54
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { AevumClient } from './client';
|
|
2
|
+
export { BookingsAPI } from './bookings';
|
|
3
|
+
export { OfferingsAPI } from './offerings';
|
|
4
|
+
export { CustomersAPI } from './customers';
|
|
5
|
+
export { ProvidersAPI } from './providers';
|
|
6
|
+
export { OrgsAPI } from './orgs';
|
|
7
|
+
export { CalendarAPI } from './calendar';
|
|
8
|
+
export { AnalyticsAPI } from './analytics';
|
|
9
|
+
export { AvailabilityAPI } from './availability';
|
|
10
|
+
export { PaymentsAPI } from './payments';
|
|
11
|
+
export { verifyWebhook, WebhookVerificationError, extractWebhookSignature, isBookingEvent, isPaymentEvent, isBookingCreatedEvent, isBookingUpdatedEvent, isBookingCancelledEvent, isBookingConfirmedEvent, isPaymentSucceededEvent, isPaymentFailedEvent, isPaymentRefundedEvent, isWebhookTestEvent, } from './webhooks';
|
|
12
|
+
export type { WebhookEvent, WebhookEventType, BookingCreatedEvent, BookingUpdatedEvent, BookingCancelledEvent, BookingConfirmedEvent, PaymentSucceededEvent, PaymentFailedEvent, PaymentRefundedEvent, WebhookTestEvent, } from './webhooks';
|
|
13
|
+
export * from './types';
|
|
14
|
+
export * from './errors';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// packages/sdk/src/index.ts
|
|
2
|
+
export { AevumClient } from './client';
|
|
3
|
+
export { BookingsAPI } from './bookings';
|
|
4
|
+
export { OfferingsAPI } from './offerings';
|
|
5
|
+
export { CustomersAPI } from './customers';
|
|
6
|
+
export { ProvidersAPI } from './providers';
|
|
7
|
+
export { OrgsAPI } from './orgs';
|
|
8
|
+
export { CalendarAPI } from './calendar';
|
|
9
|
+
export { AnalyticsAPI } from './analytics';
|
|
10
|
+
export { AvailabilityAPI } from './availability';
|
|
11
|
+
export { PaymentsAPI } from './payments';
|
|
12
|
+
export { verifyWebhook, WebhookVerificationError, extractWebhookSignature, isBookingEvent, isPaymentEvent, isBookingCreatedEvent, isBookingUpdatedEvent, isBookingCancelledEvent, isBookingConfirmedEvent, isPaymentSucceededEvent, isPaymentFailedEvent, isPaymentRefundedEvent, isWebhookTestEvent, } from './webhooks';
|
|
13
|
+
export * from './types';
|
|
14
|
+
export * from './errors';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { AevumClient } from './client';
|
|
2
|
+
import type { Offering, CreateOfferingParams, UpdateOfferingParams, ListOfferingsParams, CreateSimpleOfferingParams, CreateRecurringWeeklyOfferingParams, CreateRecurringDailyOfferingParams, CreateSimpleOfferingEndpointParams } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Offerings API methods
|
|
5
|
+
*/
|
|
6
|
+
export declare class OfferingsAPI {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: AevumClient);
|
|
9
|
+
/**
|
|
10
|
+
* List offerings for the organization
|
|
11
|
+
*/
|
|
12
|
+
list(params?: ListOfferingsParams): Promise<Offering[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Get a single offering by ID
|
|
15
|
+
*/
|
|
16
|
+
get(offeringId: string): Promise<Offering>;
|
|
17
|
+
/**
|
|
18
|
+
* Update an existing offering
|
|
19
|
+
*/
|
|
20
|
+
update(offeringId: string, params: UpdateOfferingParams): Promise<Offering>;
|
|
21
|
+
/**
|
|
22
|
+
* Delete an offering
|
|
23
|
+
*/
|
|
24
|
+
delete(offeringId: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Create a new offering
|
|
27
|
+
*/
|
|
28
|
+
create(params: CreateOfferingParams): Promise<Offering>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a simple offering (basic 1:1 offering using provider availability schedules)
|
|
31
|
+
* This is the simplest way to create an offering - it uses provider availability
|
|
32
|
+
* instead of fixed times or recurrence patterns.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const offering = await client.offerings.createSimple({
|
|
37
|
+
* name: 'Therapy Session',
|
|
38
|
+
* duration_minutes: 60,
|
|
39
|
+
* price_cents: 15000,
|
|
40
|
+
* description: 'One-on-one therapy session',
|
|
41
|
+
* providerIds: [providerId]
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
createSimple(params: CreateSimpleOfferingParams): Promise<Offering>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a weekly recurring offering with specific days and time slots
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const offering = await client.offerings.createRecurringWeekly({
|
|
52
|
+
* name: 'Weekly Therapy',
|
|
53
|
+
* duration_minutes: 60,
|
|
54
|
+
* days: ['monday', 'wednesday', 'friday'],
|
|
55
|
+
* timeSlots: [{ start: '09:00', end: '17:00' }],
|
|
56
|
+
* price_cents: 15000,
|
|
57
|
+
* providerIds: [providerId]
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
createRecurringWeekly(params: CreateRecurringWeeklyOfferingParams): Promise<Offering>;
|
|
62
|
+
/**
|
|
63
|
+
* Create a daily recurring offering with time slots
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const offering = await client.offerings.createRecurringDaily({
|
|
68
|
+
* name: 'Daily Consultation',
|
|
69
|
+
* duration_minutes: 30,
|
|
70
|
+
* timeSlots: [
|
|
71
|
+
* { start: '09:00', end: '12:00' },
|
|
72
|
+
* { start: '14:00', end: '17:00' }
|
|
73
|
+
* ],
|
|
74
|
+
* price_cents: 5000,
|
|
75
|
+
* providerIds: [providerId]
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
createRecurringDaily(params: CreateRecurringDailyOfferingParams): Promise<Offering>;
|
|
80
|
+
/**
|
|
81
|
+
* Create an offering using the simplified endpoint
|
|
82
|
+
* This method calls the /simple endpoint which provides preset-based configuration
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // Simple 1:1 offering
|
|
87
|
+
* const offering = await client.offerings.createFromSimple({
|
|
88
|
+
* name: 'Therapy Session',
|
|
89
|
+
* duration_minutes: 60,
|
|
90
|
+
* price_cents: 15000,
|
|
91
|
+
* preset: 'simple_1on1',
|
|
92
|
+
* provider_ids: [providerId]
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // Weekly recurring
|
|
96
|
+
* const weeklyOffering = await client.offerings.createFromSimple({
|
|
97
|
+
* name: 'Weekly Therapy',
|
|
98
|
+
* duration_minutes: 60,
|
|
99
|
+
* preset: 'recurring_weekly',
|
|
100
|
+
* weekly_days: ['monday', 'wednesday'],
|
|
101
|
+
* weekly_time_slots: [{ start: '09:00', end: '17:00' }],
|
|
102
|
+
* price_cents: 15000,
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
createFromSimple(params: CreateSimpleOfferingEndpointParams): Promise<Offering>;
|
|
107
|
+
}
|