Skip to content

Commit f09a50b

Browse files
authored
Merge pull request #40 from ctrl-hub/appointment-fixes
appointment fixes
2 parents 65f39e4 + d00075e commit f09a50b

File tree

8 files changed

+58
-1
lines changed

8 files changed

+58
-1
lines changed

dist/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type { InternalResponse } from './types/Response';
55
/**
66
* Models
77
*/
8+
export { Appointment } from './models/Appointment';
89
export { Contact } from './models/Contact';
910
export { CustomerAccount } from './models/CustomerAccount';
1011
export { CustomerInteraction } from './models/CustomerInteraction';

dist/index.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,47 @@ class Street extends BaseModel {
11671167
}
11681168
}
11691169

1170+
// src/models/Appointment.ts
1171+
class Appointment extends BaseModel {
1172+
type = "appointments";
1173+
appointment_type = "";
1174+
start_time = "";
1175+
end_time = "";
1176+
notes = "";
1177+
jsonApiMapping() {
1178+
return {
1179+
attributes: ["appointment_type", "start_time", "end_time", "notes"],
1180+
relationships: {
1181+
customer_interaction: "customer-interactions",
1182+
operation: "operations"
1183+
}
1184+
};
1185+
}
1186+
static relationships = [
1187+
{
1188+
name: "customer_interaction",
1189+
type: "single",
1190+
modelType: "customer-interactions"
1191+
},
1192+
{
1193+
name: "operation",
1194+
type: "single",
1195+
modelType: "operations"
1196+
}
1197+
];
1198+
constructor(data) {
1199+
super(data);
1200+
this.appointment_type = data?.attributes?.appointment_type ?? data?.appointment_type ?? "";
1201+
this.start_time = data?.attributes?.start_time ?? data?.start_time ?? "";
1202+
this.end_time = data?.attributes?.end_time ?? data?.end_time ?? "";
1203+
this.notes = data?.attributes?.notes ?? data?.notes ?? "";
1204+
}
1205+
}
1206+
11701207
// src/utils/Hydrator.ts
11711208
class Hydrator {
11721209
modelMap = {
1210+
appointments: Appointment,
11731211
contacts: Contact,
11741212
"customer-accounts": CustomerAccount,
11751213
"customer-interactions": CustomerInteraction,
@@ -2089,5 +2127,6 @@ export {
20892127
CustomerAccount,
20902128
Contact,
20912129
ClientConfig,
2092-
Client
2130+
Client,
2131+
Appointment
20932132
};

dist/models/Appointment.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export declare class Appointment extends BaseModel implements Partial<JsonApiMap
99
notes: string;
1010
jsonApiMapping(): {
1111
attributes: string[];
12+
relationships: {
13+
customer_interaction: string;
14+
operation: string;
15+
};
1216
};
1317
static relationships: RelationshipDefinition[];
1418
constructor(data?: any);

dist/models/Appointment.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export class Appointment extends BaseModel {
88
jsonApiMapping() {
99
return {
1010
attributes: ['appointment_type', 'start_time', 'end_time', 'notes'],
11+
relationships: {
12+
customer_interaction: 'customer-interactions',
13+
operation: 'operations',
14+
}
1115
};
1216
}
1317
static relationships = [

dist/utils/Hydrator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ import { WorkOrder } from '@models/WorkOrder';
3131
import { Operation } from '@models/Operation';
3232
import { OperationTemplate } from '@models/OperationTemplate';
3333
import { Street } from '@models/Street';
34+
import { Appointment } from '@models/Appointment';
3435
export class Hydrator {
3536
modelMap = {
37+
appointments: Appointment,
3638
contacts: Contact,
3739
"customer-accounts": CustomerAccount,
3840
'customer-interactions': CustomerInteraction,

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type { InternalResponse } from './types/Response';
66
/**
77
* Models
88
*/
9+
export { Appointment } from './models/Appointment';
910
export { Contact } from './models/Contact';
1011
export { CustomerAccount } from './models/CustomerAccount';
1112
export { CustomerInteraction } from './models/CustomerInteraction';

src/models/Appointment.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export class Appointment extends BaseModel implements Partial<JsonApiMapping> {
1313
jsonApiMapping() {
1414
return {
1515
attributes: ['appointment_type', 'start_time', 'end_time', 'notes'],
16+
relationships: {
17+
customer_interaction: 'customer-interactions',
18+
operation: 'operations',
19+
}
1620
};
1721
}
1822

src/utils/Hydrator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ import { WorkOrder } from '@models/WorkOrder';
3434
import { Operation } from '@models/Operation';
3535
import { OperationTemplate } from '@models/OperationTemplate';
3636
import { Street } from '@models/Street';
37+
import { Appointment } from '@models/Appointment';
3738

3839
export class Hydrator {
3940
private modelMap: Record<string, new (data?: any) => Model> = {
41+
appointments: Appointment,
4042
contacts: Contact,
4143
"customer-accounts": CustomerAccount,
4244
'customer-interactions': CustomerInteraction,

0 commit comments

Comments
 (0)