Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Van Haerenborgh <dirk.vanhaerenborgh@aloxy.io>
  • Loading branch information
vhdirk committed Feb 5, 2021
1 parent 8d8835d commit 669d2b9
Showing 1 changed file with 25 additions and 38 deletions.
63 changes: 25 additions & 38 deletions javascript/lib/api/src/client/handles/things.ts
Expand Up @@ -66,13 +66,7 @@ export class DefaultThingsHandle implements WebSocketThingsHandle, HttpThingsHan
}

public getPolicyId(thingId: string, options?: MatchOptions): Promise<string> {
return this.requestFactory.fetchJsonRequest({
verb: 'GET',
parser: String,
id: thingId,
path: 'policyId',
requestOptions: options
});
return this.getStringAtPath(thingId, 'policyId', options);
}

public getAcl(thingId: string, options?: MatchOptions): Promise<Acl> {
Expand All @@ -96,13 +90,7 @@ export class DefaultThingsHandle implements WebSocketThingsHandle, HttpThingsHan
}

public getDefinition(thingId: string, options?: MatchOptions): Promise<string> {
return this.requestFactory.fetchJsonRequest({
verb: 'GET',
parser: String,
id: thingId,
path: 'definition',
requestOptions: options
});
return this.getStringAtPath(thingId, 'definition', options);
}

public deleteThing(thingId: string, options?: MatchOptions): Promise<GenericResponse> {
Expand All @@ -114,39 +102,19 @@ export class DefaultThingsHandle implements WebSocketThingsHandle, HttpThingsHan
}

public deleteAttributes(thingId: string, options?: MatchOptions): Promise<GenericResponse> {
return this.requestFactory.fetchRequest({
verb: 'DELETE',
id: thingId,
path: 'attributes',
requestOptions: options
});
return this.deleteItemAtPath(thingId, 'attributes', options);
}

public deleteAttribute(thingId: string, attributePath: string, options?: MatchOptions): Promise<GenericResponse> {
return this.requestFactory.fetchRequest({
verb: 'DELETE',
id: thingId,
path: `attributes/${attributePath}`,
requestOptions: options
});
return this.deleteItemAtPath(thingId, `attributes/${attributePath}`, options);
}

public deleteAclEntry(thingId: string, authorizationSubject: string, options?: MatchOptions): Promise<GenericResponse> {
return this.requestFactory.fetchRequest({
verb: 'DELETE',
id: thingId,
path: `acl/${authorizationSubject}`,
requestOptions: options
});
return this.deleteItemAtPath(thingId, `acl/${authorizationSubject}`, options);
}

public deleteDefinition(thingId: string, options?: MatchOptions): Promise<GenericResponse> {
return this.requestFactory.fetchRequest({
verb: 'DELETE',
id: thingId,
path: 'definition',
requestOptions: options
});
return this.deleteItemAtPath(thingId, 'definition', options);
}

public getThings(thingIds: string[], options?: GetThingsOptions): Promise<Thing[]> {
Expand Down Expand Up @@ -255,4 +223,23 @@ export class DefaultThingsHandle implements WebSocketThingsHandle, HttpThingsHan
payload: thing.toObject()
});
}

public getStringAtPath(thingId: string, path: string, options?: MatchOptions): Promise<string> {
return this.requestFactory.fetchJsonRequest({
path,
verb: 'GET',
parser: String,
id: thingId,
requestOptions: options
});
}

public deleteItemAtPath(thingId: string, path: string, options?: MatchOptions): Promise<GenericResponse> {
return this.requestFactory.fetchRequest({
path,
verb: 'DELETE',
id: thingId,
requestOptions: options
});
}
}

0 comments on commit 669d2b9

Please sign in to comment.