Skip to content

Commit de37679

Browse files
authored
Merge pull request #29 from oracle-samples/28-add-gettimeslots-function
28 add gettimeslots function
2 parents a529e59 + d515393 commit de37679

File tree

6 files changed

+51
-9
lines changed

6 files changed

+51
-9
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Oracle Field Service Proxy
22

3-
A Javascript proxy to access Oracle Field Service cloud via REST API. For more information about the REST API please visit [the oficial documentation](https://www.oracle.com/pls/topic/lookup?ctx=en/cloud/saas/field-service&ID=field-service)
3+
A Javascript proxy to access Oracle Field Service cloud via REST API. For more information about the REST API please visit [the official documentation](https://www.oracle.com/pls/topic/lookup?ctx=en/cloud/saas/field-service&ID=field-service)
44

55
## Prerequisites
66

@@ -26,8 +26,6 @@ In order to use this library you need to have access to an Oracle Field Service
2626

2727
`getActivities()`: Get existing activities
2828

29-
`updateActivity(activityId, activityData)`: Update activity details
30-
3129
`createActivity(activityData)`: Create activity
3230

3331
`deleteActivity(activityId)`: Delete activity
@@ -80,7 +78,11 @@ In order to use this library you need to have access to an Oracle Field Service
8078

8179
`importPlugins(file?, data?)`: Import plugin by path or via an XML string
8280

83-
### Metadata: Property Management
81+
### Metadata:
82+
83+
`getTimeslots()` : Get a list of configured timeslots
84+
85+
_Property Management_
8486

8587
`getProperties()`: Get existing properties
8688

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"name": "@ofs-users/proxy",
77
"type": "module",
8-
"version": "1.10.2",
8+
"version": "1.11.0",
99
"description": "A Javascript proxy to access Oracle Field Service via REST API",
1010
"main": "dist/ofs.es.js",
1111
"module": "dist/ofs.es.js",

src/OFS.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
OFSPropertyDetails,
1414
OFSPropertyListResponse,
1515
OFSGetPropertiesParams,
16+
OFSTimeslotsResponse,
1617
} from "./model";
1718

1819
export * from "./model";
@@ -566,4 +567,10 @@ export class OFS {
566567
const partialURL = `/rest/ofscMetadata/v1/properties/${data.label}`;
567568
return this._patch(partialURL, data);
568569
}
570+
571+
//Meta: Timeslots
572+
async getTimeslots(): Promise<OFSTimeslotsResponse> {
573+
const partialURL = `/rest/ofscMetadata/v1/timeSlots`;
574+
return this._get(partialURL);
575+
}
569576
}

src/model.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,26 @@ export interface OFSGetPropertiesParams {
109109
offset?: number;
110110
type?: number;
111111
}
112-
class OFSPropertyList {
112+
export class OFSPropertyList {
113113
items: OFSPropertyDetails[] = [];
114114
limit: number = 0;
115115
offset: number = 0;
116116
totalResults: number = 0;
117117
}
118-
118+
export class OFSTimeslot {
119+
active: boolean = false;
120+
isAllDay: boolean = false;
121+
timeEnd: string = "";
122+
timeStart: string = "";
123+
label: string = "";
124+
name: string = "";
125+
}
126+
export class OFSTimeslotsList {
127+
items: OFSTimeslot[] = [];
128+
limit: number = 0;
129+
offset: number = 0;
130+
totalResults: number = 0;
131+
}
119132
export class OFSSubscriptionResponse extends OFSResponse {
120133
data: SubscriptionListResponse = {
121134
totalResults: 0,
@@ -146,3 +159,7 @@ export class OFSPropertyDetailsResponse extends OFSResponse {
146159
export class OFSPropertyListResponse extends OFSResponse {
147160
data: OFSPropertyList = new OFSPropertyList();
148161
}
162+
163+
export class OFSTimeslotsResponse extends OFSResponse {
164+
data: OFSTimeslotsList = new OFSTimeslotsList();
165+
}

test/general/meta.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ var testConfig: any;
1818
interface MetaTestConfiguration {
1919
numberOfProperties: number;
2020
numberOfResourceProperties: number;
21+
numberOfTimeslots: number;
2122
}
2223
const TEST_CONFIG: Map<string, MetaTestConfiguration> = new Map<string, any>();
2324
TEST_CONFIG.set("23.11", {
2425
numberOfProperties: 464,
2526
numberOfResourceProperties: 34,
27+
numberOfTimeslots: 9,
2628
});
2729

2830
// Setup info
@@ -286,3 +288,17 @@ test("Update custom property", async () => {
286288
throw error;
287289
}
288290
});
291+
292+
test("Get a list of configured timeslots", async () => {
293+
var result = await myProxy.getTimeslots();
294+
try {
295+
expect(result.status).toBe(200);
296+
expect(result.status).toBe(200);
297+
expect(result.data.items.length).toBe(testConfig.numberOfTimeslots);
298+
expect(result.data.offset).toBe(0);
299+
expect(result.data.limit).toBe(100);
300+
} catch (error) {
301+
console.error(result);
302+
throw error;
303+
}
304+
});

0 commit comments

Comments
 (0)