Skip to content

Commit 952d68a

Browse files
authored
Merge pull request #12 from oracle-samples/feature-get-users
Feature get users
2 parents 4185b73 + 51cfc4e commit 952d68a

File tree

5 files changed

+2791
-4
lines changed

5 files changed

+2791
-4
lines changed

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.5.1",
8+
"version": "1.6.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: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ export class OFS {
5151
return "Basic " + hash;
5252
}
5353

54-
private _get(partialURL: string): Promise<OFSResponse> {
54+
private _get(
55+
partialURL: string,
56+
params: any = undefined
57+
): Promise<OFSResponse> {
5558
var theURL = new URL(partialURL, this._baseURL);
59+
if (params != undefined) {
60+
const urlSearchParams = new URLSearchParams(params);
61+
theURL.search = urlSearchParams.toString();
62+
}
5663
var myHeaders = new Headers();
5764
myHeaders.append("Authorization", this.authorization);
5865
var requestOptions = {
@@ -271,6 +278,20 @@ export class OFS {
271278
return this._patch(partialURL, data);
272279
}
273280

281+
// Core: User Management
282+
async getUsers(
283+
offset: number = 0,
284+
limit: number = 100
285+
): Promise<OFSResponse> {
286+
const partialURL = "/rest/ofscCore/v1/users";
287+
return this._get(partialURL, { offset: offset, limit: limit });
288+
}
289+
290+
async getUserDetails(uname: string): Promise<OFSResponse> {
291+
const partialURL = `/rest/ofscCore/v1/users/${uname}`;
292+
return this._get(partialURL);
293+
}
294+
274295
// Metadata: Plugin Management
275296
async importPlugins(file?: PathLike, data?: string): Promise<OFSResponse> {
276297
const partialURL =

0 commit comments

Comments
 (0)