Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Gann committed Dec 12, 2023
1 parent 6028bd8 commit e9ad0a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
16 changes: 7 additions & 9 deletions src/modules/coreHttpApi/controllers/AttributesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class AttributesController extends BaseController {
@Path("/SucceedIdentityAttribute")
@Accept("application/json")
public async succeedIdentityAttribute(request: any): Promise<Return.NewResource<Envelope>> {
const result = await this.consumptionServices.attributes.succeedIdentityAttribute({ predecessorId: request.predecessorId, successorContent: request.successorContent });
const result = await this.consumptionServices.attributes.succeedIdentityAttribute(request);
return this.created(result);
}

Expand All @@ -57,9 +57,9 @@ export class AttributesController extends BaseController {
public async succeedAttribute(request: any): Promise<Return.NewResource<Envelope>> {
let result: any;
if (request.successorContent["@type"] === "IdentityAttribute") {
result = await this.consumptionServices.attributes.succeedIdentityAttribute({ predecessorId: request.id, successorContent: request.successorContent });
} else if (request.successorContent["@type"] === "RelationshipAttribute") {
result = await this.consumptionServices.attributes.succeedRelationshipAttributeAndNotifyPeer({ predecessorId: request.id, successorContent: request.successorContent });
result = await this.consumptionServices.attributes.succeedIdentityAttribute(request);
} else {
result = await this.consumptionServices.attributes.succeedRelationshipAttributeAndNotifyPeer(request);
}
return this.created(result);
}
Expand All @@ -68,10 +68,7 @@ export class AttributesController extends BaseController {
@Path("/SucceedRelationshipAttributeAndNotifyPeer")
@Accept("application/json")
public async succeedRelationshipAttributeAndNotifyPeer(request: any): Promise<Return.NewResource<Envelope>> {
const result = await this.consumptionServices.attributes.succeedRelationshipAttributeAndNotifyPeer({
predecessorId: request.predecessorId,
successorContent: request.successorContent
});
const result = await this.consumptionServices.attributes.succeedRelationshipAttributeAndNotifyPeer(request);
return this.created(result);
}

Expand All @@ -80,10 +77,11 @@ export class AttributesController extends BaseController {
@Accept("application/json")
public async shareAttribute(request: any): Promise<Return.NewResource<Envelope>> {
// TODO: Remove?
// TODO: Distinguish between cases by loading attribute and checking if succeeded => remove @type
let result: any;
if (request.successorContent["@type"] === "Share") {
result = await this.consumptionServices.attributes.shareIdentityAttribute(request);
} else if (request.successorContent["@type"] === "Notify") {
} else {
result = await this.consumptionServices.attributes.notifyPeerAboutIdentityAttributeSuccession(request);
}
return this.created(result);
Expand Down
5 changes: 3 additions & 2 deletions src/modules/coreHttpApi/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ paths:
- predecessorId
- successorContent
properties:
"@type":
"@type": # TODO: Simplify with: https://stackoverflow.com/questions/49391808/reusing-references-to-models-but-redefining-required-properties?rq=4
enum:
- IdentityAttribute # TODO: Usage of this enum okay? => Determines that this property has to be of type IdentityAttribute
- IdentityAttribute
predecessorId:
$ref: "#/components/schemas/AttributeID"
successorContent:
Expand All @@ -721,6 +721,7 @@ paths:
- type: object
additionalProperties: false
required:
- "@type"
- predecessorId
- successorContent
properties:
Expand Down

0 comments on commit e9ad0a0

Please sign in to comment.