Skip to content

28 add gettimeslots function #29

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

Merged
merged 3 commits into from
Oct 16, 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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Oracle Field Service Proxy

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)
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)

## Prerequisites

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

`getActivities()`: Get existing activities

`updateActivity(activityId, activityData)`: Update activity details

`createActivity(activityData)`: Create activity

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

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

### Metadata: Property Management
### Metadata:

`getTimeslots()` : Get a list of configured timeslots

_Property Management_

`getProperties()`: Get existing properties

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"name": "@ofs-users/proxy",
"type": "module",
"version": "1.10.2",
"version": "1.11.0",
"description": "A Javascript proxy to access Oracle Field Service via REST API",
"main": "dist/ofs.es.js",
"module": "dist/ofs.es.js",
Expand Down
7 changes: 7 additions & 0 deletions src/OFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
OFSPropertyDetails,
OFSPropertyListResponse,
OFSGetPropertiesParams,
OFSTimeslotsResponse,
} from "./model";

export * from "./model";
Expand Down Expand Up @@ -566,4 +567,10 @@ export class OFS {
const partialURL = `/rest/ofscMetadata/v1/properties/${data.label}`;
return this._patch(partialURL, data);
}

//Meta: Timeslots
async getTimeslots(): Promise<OFSTimeslotsResponse> {
const partialURL = `/rest/ofscMetadata/v1/timeSlots`;
return this._get(partialURL);
}
}
21 changes: 19 additions & 2 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,26 @@ export interface OFSGetPropertiesParams {
offset?: number;
type?: number;
}
class OFSPropertyList {
export class OFSPropertyList {
items: OFSPropertyDetails[] = [];
limit: number = 0;
offset: number = 0;
totalResults: number = 0;
}

export class OFSTimeslot {
active: boolean = false;
isAllDay: boolean = false;
timeEnd: string = "";
timeStart: string = "";
label: string = "";
name: string = "";
}
export class OFSTimeslotsList {
items: OFSTimeslot[] = [];
limit: number = 0;
offset: number = 0;
totalResults: number = 0;
}
export class OFSSubscriptionResponse extends OFSResponse {
data: SubscriptionListResponse = {
totalResults: 0,
Expand Down Expand Up @@ -146,3 +159,7 @@ export class OFSPropertyDetailsResponse extends OFSResponse {
export class OFSPropertyListResponse extends OFSResponse {
data: OFSPropertyList = new OFSPropertyList();
}

export class OFSTimeslotsResponse extends OFSResponse {
data: OFSTimeslotsList = new OFSTimeslotsList();
}
16 changes: 16 additions & 0 deletions test/general/meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ var testConfig: any;
interface MetaTestConfiguration {
numberOfProperties: number;
numberOfResourceProperties: number;
numberOfTimeslots: number;
}
const TEST_CONFIG: Map<string, MetaTestConfiguration> = new Map<string, any>();
TEST_CONFIG.set("23.11", {
numberOfProperties: 464,
numberOfResourceProperties: 34,
numberOfTimeslots: 9,
});

// Setup info
Expand Down Expand Up @@ -286,3 +288,17 @@ test("Update custom property", async () => {
throw error;
}
});

test("Get a list of configured timeslots", async () => {
var result = await myProxy.getTimeslots();
try {
expect(result.status).toBe(200);
expect(result.status).toBe(200);
expect(result.data.items.length).toBe(testConfig.numberOfTimeslots);
expect(result.data.offset).toBe(0);
expect(result.data.limit).toBe(100);
} catch (error) {
console.error(result);
throw error;
}
});