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 e9ad0a0 commit 0d3a7ca
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 156 deletions.
12 changes: 5 additions & 7 deletions packages/sdk/src/endpoints/AttributesEndpoint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
ConnectorAttribute,
ConnectorAttributes,
ConnectorIdentityAttribute,
ConnectorRequest,
ConnectorResponse,
CreateAndShareRelationshipAttributeRequest,
CreateAttributeRequest,
CreateIdentityAttributeRequest,
ExecuteIQLQueryRequest,
ExecuteIdentityAttributeQueryRequest,
Expand All @@ -13,18 +13,16 @@ import {
GetAttributesRequest,
GetValidAttributesRequest,
NotifyPeerAboutIdentityAttributeSuccessionRequest,
ShareAttributeRequest,
ShareIdentityAttributeRequest,
SucceedAttributeRequest,
SucceedAttributeResponse,
SucceedIdentityAttributeRequest,
SucceedRelationshipAttributeAndNotifyPeerRequest
} from "../types";
import { CreateAttributeResponse } from "../types/attributes/requests/CreateAttributeResponse";
import { Endpoint } from "./Endpoint";

export class AttributesEndpoint extends Endpoint {
public async createAttribute(request: CreateAttributeRequest): Promise<ConnectorResponse<CreateAttributeResponse>> {
public async createAttribute(request: ConnectorIdentityAttribute): Promise<ConnectorResponse<ConnectorAttribute>> {
return await this.post("/api/v2/Attributes", request);
}

Expand All @@ -48,9 +46,9 @@ export class AttributesEndpoint extends Endpoint {
return await this.post("/api/v2/Attributes/SucceedRelationshipAttributeAndNotifyPeer", request);
}

public async shareAttribute(request: ShareAttributeRequest): Promise<ConnectorResponse<CreateAttributeResponse>> {
return await this.post("/api/v2/Attributes/ShareAttribute", request);
}
// public async shareAttribute(request: ShareAttributeRequest): Promise<ConnectorResponse<CreateAttributeResponse>> {
// return await this.post("/api/v2/Attributes/ShareAttribute", request);
// }

public async shareIdentityAttribute(request: ShareIdentityAttributeRequest): Promise<ConnectorResponse<ConnectorRequest>> {
return await this.post("/api/v2/Attributes/ShareIdentityAttribute", request);
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/src/types/attributes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from "./IdentityAttributeQuery";
export * from "./RelationshipAttributeQuery";
export * from "./ThirdPartyAttributeQuery";
export * from "./requests/CreateAndShareRelationshipAttributeRequest";
export * from "./requests/CreateAttributeRequest";
export * from "./requests/CreateIdentityAttributeRequest";
export * from "./requests/ExecuteIQLQueryRequest";
export * from "./requests/ExecuteIdentityAttributeQueryRequest";
Expand Down

This file was deleted.

This file was deleted.

38 changes: 16 additions & 22 deletions src/modules/coreHttpApi/controllers/AttributesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ export class AttributesController extends BaseController {
@POST
@Accept("application/json")
public async createAttribute(request: any): Promise<Return.NewResource<Envelope>> {
// TODO: remove createAndShareRelationshipAttribute
// TODO: restore original payload structure
let result: any;
if (request.value) {
result = await this.consumptionServices.attributes.createIdentityAttribute({ content: request });
} else {
result = await this.consumptionServices.attributes.createAndShareRelationshipAttribute(request);
}
const attributeValue = request.value; // Legacy API recieves whole Relationship Attribute => extract attribute value for new use case
const result = await this.consumptionServices.attributes.createIdentityAttribute(attributeValue);
return this.created(result);
}

Expand Down Expand Up @@ -72,20 +66,20 @@ export class AttributesController extends BaseController {
return this.created(result);
}

@POST
@Path("/ShareAttribute")
@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 {
result = await this.consumptionServices.attributes.notifyPeerAboutIdentityAttributeSuccession(request);
}
return this.created(result);
}
// @POST
// @Path("/ShareAttribute")
// @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 {
// result = await this.consumptionServices.attributes.notifyPeerAboutIdentityAttributeSuccession(request);
// }
// return this.created(result);
// }

@POST
@Path("/ShareIdentityAttribute")
Expand Down
157 changes: 78 additions & 79 deletions src/modules/coreHttpApi/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,20 @@ paths:
/api/v2/Attributes:
post:
operationId: createAttribute
description: Create an Identity Attribute or create and share a Relationship Attribute
description: Create an Attribute
tags:
- Attributes
requestBody:
content:
application/json:
schema:
oneOf: # TODO: Okay to use oneOf here?
- $ref: "#/components/schemas/CreateIdentityAttributeRequest"
- $ref: "#/components/schemas/CreateAndShareRelationshipAttributeRequest"

additionalProperties: false
properties:
content:
"$ref": "#/components/schemas/IdentityAttribute"
required:
- content
type: object
responses:
201:
description: Success
Expand All @@ -302,13 +305,9 @@ paths:
type: object
properties:
result:
oneOf:
- type: object
nullable: false
$ref: "#/components/schemas/IdentityAttribute"
- type: object
nullable: false
$ref: "#/components/schemas/Request"
type: object
nullable: false
$ref: "#/components/schemas/Attribute"
required:
- result
headers:
Expand Down Expand Up @@ -506,73 +505,73 @@ paths:
403:
$ref: "#/components/responses/Forbidden"

/api/v2/Attributes/ShareAttribute:
post:
operationId: shareAttribute
description: Share an Identity Attribute or notify peer about succession of Identity Attribute
tags:
- Attributes
requestBody:
content:
application/json:
schema:
oneOf:
- type: object
required:
- "@type"
- attributeId
- peer
properties:
"@type":
enum:
- "Share"
attributeId:
$ref: "#/components/schemas/AttributeID"
peer:
$ref: "#/components/schemas/Address"
requestMetadata:
$ref: "#/components/schemas/RequestMetadata"
- type: object
required:
- "@type"
- attributeId
- peer
properties:
"@type":
enum:
- "Notify"
attributeId:
$ref: "#/components/schemas/AttributeID"
peer:
$ref: "#/components/schemas/Address"

responses:
200:
description: Success
content:
application/json:
schema:
type: object
properties:
result:
nullable: false
type: object
$ref: "#/components/schemas/Request"
required:
- result
headers:
X-Response-Duration-ms:
schema:
$ref: "#/components/schemas/HeaderContent_X-Response-Duration-ms"
X-Response-Time:
schema:
$ref: "#/components/schemas/HeaderContent_X-Response-Time"
401:
$ref: "#/components/responses/Unauthorized"
403:
$ref: "#/components/responses/Forbidden"
404:
$ref: "#/components/responses/NotFound"
# /api/v2/Attributes/ShareAttribute:
# post:
# operationId: shareAttribute
# description: Share an Identity Attribute or notify peer about succession of Identity Attribute
# tags:
# - Attributes
# requestBody:
# content:
# application/json:
# schema:
# oneOf:
# - type: object
# required:
# - "@type"
# - attributeId
# - peer
# properties:
# "@type":
# enum:
# - "Share"
# attributeId:
# $ref: "#/components/schemas/AttributeID"
# peer:
# $ref: "#/components/schemas/Address"
# requestMetadata:
# $ref: "#/components/schemas/RequestMetadata"
# - type: object
# required:
# - "@type"
# - attributeId
# - peer
# properties:
# "@type":
# enum:
# - "Notify"
# attributeId:
# $ref: "#/components/schemas/AttributeID"
# peer:
# $ref: "#/components/schemas/Address"

# responses:
# 200:
# description: Success
# content:
# application/json:
# schema:
# type: object
# properties:
# result:
# nullable: false
# type: object
# $ref: "#/components/schemas/Request"
# required:
# - result
# headers:
# X-Response-Duration-ms:
# schema:
# $ref: "#/components/schemas/HeaderContent_X-Response-Duration-ms"
# X-Response-Time:
# schema:
# $ref: "#/components/schemas/HeaderContent_X-Response-Time"
# 401:
# $ref: "#/components/responses/Unauthorized"
# 403:
# $ref: "#/components/responses/Forbidden"
# 404:
# $ref: "#/components/responses/NotFound"

/api/v2/Attributes/NotifyPeerAboutIdentityAttributeSuccession:
post:
Expand Down
Loading

0 comments on commit 0d3a7ca

Please sign in to comment.