Skip to content

Commit a529e59

Browse files
authored
Merge pull request #27 from oracle-samples/26-add-move-activity
26 add move activity
2 parents 006ef8b + 13d5d57 commit a529e59

File tree

4 files changed

+89
-25
lines changed

4 files changed

+89
-25
lines changed

README.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ In order to use this library you need to have access to an Oracle Field Service
88

99
## Installation
1010

11-
1211
1. Add the dependency to your project
13-
14-
`npm install <LOCAL REPOSITORY DIR>` (if you have cloned the repository)
1512

16-
`npm install https://github.com/oracle-samples/ofs-proxy-js.git` (when installing directly from GitHub)
13+
`npm install <LOCAL REPOSITORY DIR>` (if you have cloned the repository)
14+
15+
`npm install https://github.com/oracle-samples/ofs-proxy-js.git` (when installing directly from GitHub)
1716

18-
`npm install @ofs-users/proxy` (when installing from npm)
17+
`npm install @ofs-users/proxy` (when installing from npm)
1918

2019
2. To use the library in your code:
2120

22-
`import {OFS} from "@ofs-users/proxy"`
21+
`import {OFS} from "@ofs-users/proxy"`
2322

2423
## Functions implemented (may not be complete)
2524

@@ -35,6 +34,28 @@ In order to use this library you need to have access to an Oracle Field Service
3534

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

37+
`moveActivity(activityId, activityData)`: Move activity
38+
39+
`delayActivity(activityId, activityData)`: Delay activity
40+
41+
`reopenActivity(activityId, activityData)`: Reopen activity
42+
43+
`startActivity(activityId, activityData)`: Start activity
44+
45+
`suspendActivity(activityId, activityData)`: Suspend activity
46+
47+
`completeActivity(activityId, activityData)`: Complete activity
48+
49+
`cancelActivity(activityId, activityData)`: Cancel activity
50+
51+
`notDoneActivity(activityId, activityData)`: Set activity to Not Done status
52+
53+
`startPrework(activityId, activityData)`: Start activity prework
54+
55+
`stopTravel(activityId, activityData)`: Stop Travel ( From Enroute to Pending )
56+
57+
`enrouteActivity(activityId, activityData)`: Stop Travel ( From Pending to Enroute )
58+
3859
`setActivityFileProperty(activityId, propertyId, file)`: Set file property
3960

4061
`getActivityFilePropertyMetadata(activityId, propertyId)`: Get file property metadata
@@ -75,13 +96,13 @@ Please see the `docs/` directory for documentation and a simple example
7596

7697
## Version History
7798

78-
| Version | Comments |
79-
| ---------| ----------- |
80-
| 0.1| Added `getActivityDetails`, `updateActivity`, `getSubscriptions` |
81-
| 1.1| Added `importPlugins` |
82-
| 1.2| Added `createActivity`, `deleteActivity` |
83-
| 1.6| Added `getUsers`, `getUserDetails`, `getAllUsers` |
84-
| 1.8| Added `getProperties`, `getPropertyDetails`, `updateProperty` `createReplaceProperty` |
99+
| Version | Comments |
100+
| ------- | ------------------------------------------------------------------------------------- |
101+
| 0.1 | Added `getActivityDetails`, `updateActivity`, `getSubscriptions` |
102+
| 1.1 | Added `importPlugins` |
103+
| 1.2 | Added `createActivity`, `deleteActivity` |
104+
| 1.6 | Added `getUsers`, `getUserDetails`, `getAllUsers` |
105+
| 1.8 | Added `getProperties`, `getPropertyDetails`, `updateProperty` `createReplaceProperty` |
85106

86107
## Contributing
87108

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"name": "@ofs-users/proxy",
77
"type": "module",
8-
"version": "1.9.0",
8+
"version": "1.10.2",
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",
@@ -65,7 +65,7 @@
6565
"typescript": "^4.9.4"
6666
},
6767
"dependencies": {
68-
"@ofs-users/proxy": "^1.8.2",
68+
"@ofs-users/proxy": "^1.9.0",
6969
"tslib": "^2.4.1"
7070
}
7171
}

src/OFS.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,47 @@ export class OFS {
370370
const partialURL = `/rest/ofscCore/v1/activities/${aid}`;
371371
return this._patch(partialURL, data);
372372
}
373-
373+
async moveActivity(aid: number, data: any): Promise<OFSResponse> {
374+
return this._executeActivityAction(aid, data, "move");
375+
}
376+
async delayActivity(aid: number, data: any): Promise<OFSResponse> {
377+
return this._executeActivityAction(aid, data, "delay");
378+
}
379+
async reopenActivity(aid: number, data: any): Promise<OFSResponse> {
380+
return this._executeActivityAction(aid, data, "reopen");
381+
}
382+
async startActivity(aid: number, data: any): Promise<OFSResponse> {
383+
return this._executeActivityAction(aid, data, "start");
384+
}
385+
async suspendActivity(aid: number, data: any): Promise<OFSResponse> {
386+
return this._executeActivityAction(aid, data, "suspend");
387+
}
388+
async completeActivity(aid: number, data: any): Promise<OFSResponse> {
389+
return this._executeActivityAction(aid, data, "complete");
390+
}
391+
async stopTravel(aid: number, data: any): Promise<OFSResponse> {
392+
return this._executeActivityAction(aid, data, "stopTravel");
393+
}
394+
async cancelActivity(aid: number, data: any): Promise<OFSResponse> {
395+
return this._executeActivityAction(aid, data, "cancel");
396+
}
397+
async startPrework(aid: number, data: any): Promise<OFSResponse> {
398+
return this._executeActivityAction(aid, data, "startPrework");
399+
}
400+
async enrouteActivity(aid: number, data: any): Promise<OFSResponse> {
401+
return this._executeActivityAction(aid, data, "enroute");
402+
}
403+
async notDoneActivity(aid: number, data: any): Promise<OFSResponse> {
404+
return this._executeActivityAction(aid, data, "notDone");
405+
}
406+
private async _executeActivityAction(
407+
aid: number,
408+
data: any,
409+
action: any
410+
): Promise<OFSResponse> {
411+
const partialURL = `/rest/ofscCore/v1/activities/${aid}/custom-actions/${action}`;
412+
return this._post(partialURL, data);
413+
}
374414
async getActivityFilePropertyContent(
375415
aid: number,
376416
propertyLabel: string,

0 commit comments

Comments
 (0)