Skip to content

Commit

Permalink
fix: subid
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayg10 committed Nov 12, 2024
1 parent dbcbc2c commit f063369
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/interface/api-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ paths:
content:
application/json:
schema:
$ref: '../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/ParticipantsTypeIDSubIDPostRequest.yaml'
$ref: '#/components/schemas/ParticipantsTypeIDPostPutRequest'
responses:
201:
description: Created
Expand Down Expand Up @@ -180,7 +180,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ParticipantsTypeIDPutRequest'
$ref: '#/components/schemas/ParticipantsTypeIDPostPutRequest'
responses:
200:
$ref: '../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/responses/200.yaml'
Expand Down Expand Up @@ -362,7 +362,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ParticipantsTypeIDPutRequest'
$ref: '#/components/schemas/ParticipantsTypeIDPostPutRequest'
responses:
200:
$ref: '../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/responses/200.yaml'
Expand Down Expand Up @@ -488,8 +488,8 @@ components:
identifier's type. For example, `PASSPORT`, `DRIVING_LICENSE`.
schemas:
ParticipantsTypeIDPutRequest:
title: ParticipantsTypeIDPutRequest
ParticipantsTypeIDPostPutRequest:
title: ParticipantsTypeIDPostPutRequest
description: PUT /participants/{Type}/{ID} object
type: object
properties:
Expand Down
10 changes: 5 additions & 5 deletions src/interface/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ParticipantsTypeIDSubIDPostRequest'
$ref: '#/components/schemas/ParticipantsTypeIDPostPutRequest'
responses:
'201':
description: Created
Expand Down Expand Up @@ -190,7 +190,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ParticipantsTypeIDPutRequest'
$ref: '#/components/schemas/ParticipantsTypeIDPostPutRequest'
responses:
'200':
$ref: '#/components/responses/200'
Expand Down Expand Up @@ -391,7 +391,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ParticipantsTypeIDPutRequest'
$ref: '#/components/schemas/ParticipantsTypeIDPostPutRequest'
responses:
'200':
$ref: '#/components/responses/200'
Expand Down Expand Up @@ -676,8 +676,8 @@ components:
A sub-identifier of the party identifier, or a sub-type of the party
identifier's type. For example, `PASSPORT`, `DRIVING_LICENSE`.
schemas:
ParticipantsTypeIDPutRequest:
title: ParticipantsTypeIDPutRequest
ParticipantsTypeIDPostPutRequest:
title: ParticipantsTypeIDPostPutRequest
description: PUT /participants/{Type}/{ID} object
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions src/interface/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { Schemas } from '@mojaloop/api-snippets/lib/fspiop/v1_1'

export interface ParticipantsTypeIDSubIDPut {
export interface ParticipantsTypeIDPostPutRequest {
fspId: Schemas.FspId
currency?: Schemas.Currency
extensionList?: Schemas.ExtensionList
partySubIdOrType?: Schemas.PartySubIdOrType
}
11 changes: 6 additions & 5 deletions src/server/handlers/participants/{Type}/{ID}.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Request, ResponseToolkit, ResponseObject } from '@hapi/hapi'
import { Context } from '~/server/plugins'
import { retrievePartyMapItem, createPartyMapItem, updatePartyMapItem, deletePartyMapItem } from '~/domain/participants'
import { Schemas } from '@mojaloop/api-snippets/lib/fspiop/v1_1'
import { PartyMapItem } from '~/model/MSISDN'
import * as Types from '~/interface/types'
import { IDTypeNotSupported } from '../../../../model/errors'
Expand All @@ -24,10 +23,11 @@ export async function post(_context: Context, request: Request, h: ResponseToolk
}

const partyId = request.params.ID
const payload = request.payload as Schemas.ParticipantsTypeIDSubIDPostRequest
const payload = request.payload as Types.ParticipantsTypeIDPostPutRequest
const partyMapItem: PartyMapItem = {
id: partyId,
fspId: payload.fspId
fspId: payload.fspId,
subId: payload.partySubIdOrType
}
await createPartyMapItem(partyMapItem)
return h.response().code(201)
Expand All @@ -39,10 +39,11 @@ export async function put(_context: Context, request: Request, h: ResponseToolki
}

const partyId = request.params.ID
const payload = request.payload as Types.ParticipantsTypeIDSubIDPut
const payload = request.payload as Types.ParticipantsTypeIDPostPutRequest
const partyMapItem: PartyMapItem = {
id: partyId,
fspId: payload.fspId
fspId: payload.fspId,
subId: payload.partySubIdOrType
}
await updatePartyMapItem(partyMapItem)
return h.response().code(200)
Expand Down
2 changes: 1 addition & 1 deletion src/server/handlers/participants/{Type}/{ID}/{SubId}.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function put(_context: Context, request: Request, h: ResponseToolki

const partyId = request.params.ID
const subId = request.params.SubId
const payload = request.payload as Types.ParticipantsTypeIDSubIDPut
const payload = request.payload as Types.ParticipantsTypeIDPostPutRequest
const partyMapItem: PartyMapItem = {
id: partyId,
subId,
Expand Down

0 comments on commit f063369

Please sign in to comment.