From 742af00156e0d34edd3c00b2e6e12a6ab4ecee2a Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 23 Aug 2023 12:09:45 +0530 Subject: [PATCH 1/5] Restructured notes open api specs and sequence diagram --- .../{Notes.yaml => AccountNotes.yaml} | 36 +++++++++++++++++++ .../CreateNote.mermaid | 0 .../GetNoteById.mermaid | 0 .../GetNotesList.mermaid | 0 4 files changed, 36 insertions(+) rename openapiSpecifications/{Notes.yaml => AccountNotes.yaml} (84%) rename sequenceDiagrams/{Accounts => AccountNotes}/CreateNote.mermaid (100%) rename sequenceDiagrams/{Accounts => AccountNotes}/GetNoteById.mermaid (100%) rename sequenceDiagrams/{Accounts => AccountNotes}/GetNotesList.mermaid (100%) diff --git a/openapiSpecifications/Notes.yaml b/openapiSpecifications/AccountNotes.yaml similarity index 84% rename from openapiSpecifications/Notes.yaml rename to openapiSpecifications/AccountNotes.yaml index c26e878..5b191f2 100644 --- a/openapiSpecifications/Notes.yaml +++ b/openapiSpecifications/AccountNotes.yaml @@ -182,3 +182,39 @@ paths: type: string format: date-time example: "2019-10-12T07:20:50.52Z" + delete: + description: Delete note for the given note id. + parameters: + - name: account_id + description: Account Id + in: path + required: true + schema: + type: string + - name: note_id + description: Note Id + in: path + required: true + schema: + type: string + responses: + '401': + description: Unauthorized access + content: + application/json: + schema: + $ref: 'Components.yaml#/components/schemas/response_401' + '404': + description: Not Found + content: + application/json: + schema: + $ref: 'Components.yaml#/components/schemas/response_404' + '500': + description: Something went wrong + content: + application/json: + schema: + $ref: 'Components.yaml#/components/schemas/response_500' + '200': + description: Success \ No newline at end of file diff --git a/sequenceDiagrams/Accounts/CreateNote.mermaid b/sequenceDiagrams/AccountNotes/CreateNote.mermaid similarity index 100% rename from sequenceDiagrams/Accounts/CreateNote.mermaid rename to sequenceDiagrams/AccountNotes/CreateNote.mermaid diff --git a/sequenceDiagrams/Accounts/GetNoteById.mermaid b/sequenceDiagrams/AccountNotes/GetNoteById.mermaid similarity index 100% rename from sequenceDiagrams/Accounts/GetNoteById.mermaid rename to sequenceDiagrams/AccountNotes/GetNoteById.mermaid diff --git a/sequenceDiagrams/Accounts/GetNotesList.mermaid b/sequenceDiagrams/AccountNotes/GetNotesList.mermaid similarity index 100% rename from sequenceDiagrams/Accounts/GetNotesList.mermaid rename to sequenceDiagrams/AccountNotes/GetNotesList.mermaid From 11937fac11ee693e8f89d6e443d384cc0c6e0870 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 23 Aug 2023 13:11:00 +0530 Subject: [PATCH 2/5] Updated success status code from 200 to 204 --- openapiSpecifications/AccountNotes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapiSpecifications/AccountNotes.yaml b/openapiSpecifications/AccountNotes.yaml index 5b191f2..e010781 100644 --- a/openapiSpecifications/AccountNotes.yaml +++ b/openapiSpecifications/AccountNotes.yaml @@ -216,5 +216,5 @@ paths: application/json: schema: $ref: 'Components.yaml#/components/schemas/response_500' - '200': + '204': description: Success \ No newline at end of file From 01135ee43c96cbd1e34eb9cb8f0167820642d1d0 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 23 Aug 2023 13:18:12 +0530 Subject: [PATCH 3/5] Added Delete Note Sequence Diagram --- .../AccountNotes/DeleteNote.mermaid | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sequenceDiagrams/AccountNotes/DeleteNote.mermaid diff --git a/sequenceDiagrams/AccountNotes/DeleteNote.mermaid b/sequenceDiagrams/AccountNotes/DeleteNote.mermaid new file mode 100644 index 0000000..17645bf --- /dev/null +++ b/sequenceDiagrams/AccountNotes/DeleteNote.mermaid @@ -0,0 +1,64 @@ +sequenceDiagram + title Delete Account Note + participant ui as SalesSparrow Client + participant api as SalesSparrow API + participant exceptionHandler as Global Exception Handler + participant validator as Param Validator(Interceptor) + participant controller as AccountNote Controller + participant service as DeleteNote Service + participant factory as DeleteNote Factory + participant crm as Salesforce DeleteNote Service + participant CompositeRequestWrapper as CompositeRequest(Wrapper) + participant salesforce as Salesforce + + ui->>api: Send request + note right of ui: Request:
DELETE {api_base_url}/v1/accounts/{account_id}/notes/{note_id}

path params:
account_id
note_id + + note over api: Validate and fetch current user data from cookie
set currentUser attribute in request.

Refer this document for interceptor sequence diagram
'./docs/sequenceDiagrams/Common/UserAuthIntercepter.mermaid' + break If currentUser not found + api-->>ui: Error Response
currentUser Not Found + end + + api->>validator: Validate path params + + break If mandatory params not present in the body + validator->>exceptionHandler: Throws exeption + exceptionHandler-->>ui:Return error response + end + + validator->>controller: Send validated params
params: noteId, accountId + + controller->>service: Call deleteNote method of DeleteNoteService
params: request, noteId, accountId + note over service: GetAttribute of currentUser from request
Which was set by interceptor + + service->>factory: Call deleteNote method of DeleteNoteFactory
params: currentUser, noteId + note over factory: Based on currentUser identify CRM + + factory->>crm: Call deleteNote method of particular CRM service
params: currentUser, noteId + + note over crm: fetch salesforceUserId from request currentUser + break If salesforceUserId is not present in currentUser. + crm->>exceptionHandler: Throws exeption + exceptionHandler-->>ui:Return error response + end + crm->>CompositeRequestWrapper: Send compositeBody to make request to salesforce
params:
List, salesforceUserId
+ + CompositeRequestWrapper->>salesforce: Make salesforce composite api call with commmon helper function

Refer this document for commmon helper function sequence diagram
'./docs/sequenceDiagrams/Common/OAuthRequestHelper.mermaid' + note right of CompositeRequestWrapper: Request: POST {instance_url}/services/data/v58.0/composite

Params:
method: DELETE
url: "/services/data/v58.0/sobjects/ContentNote/${noteId}"
referenceId: "DeleteNote" + + break If any error from salesforce + salesforce-->>CompositeRequestWrapper: Error + CompositeRequestWrapper->>exceptionHandler: Throws exeption + exceptionHandler-->>ui: Return error response + end + + salesforce-->>CompositeRequestWrapper: Response + CompositeRequestWrapper-->>crm: Response + + crm-->>factory: Response + factory-->>service: Response + service-->> controller: Response + controller-->>api: Response + + api-->>ui: Success:204 + note right of ui: Response body:
{}

Response headers:
cookie \ No newline at end of file From b8648d0420781650516e7a3ccdc5ca539c0dd202 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 23 Aug 2023 18:56:38 +0530 Subject: [PATCH 4/5] Added delete note api in postman collection --- .../AI-Sales-Sparrow.postman_collection.json | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/postman/AI-Sales-Sparrow.postman_collection.json b/postman/AI-Sales-Sparrow.postman_collection.json index 22c8590..f1d67fa 100644 --- a/postman/AI-Sales-Sparrow.postman_collection.json +++ b/postman/AI-Sales-Sparrow.postman_collection.json @@ -171,6 +171,37 @@ }, "response": [] }, + { + "name": "Delete Note", + "request": { + "method": "DELETE", + "header": [], + "body": { + "mode": "raw", + "raw": "", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host_url}}/api/v1/accounts/{{account-id}}/notes/{{note-id}}", + "host": [ + "{{host_url}}" + ], + "path": [ + "api", + "v1", + "accounts", + "{{account-id}}", + "notes", + "{{note-id}}" + ] + } + }, + "response": [] + }, { "name": "Note List", "protocolProfileBehavior": { From 94fc694feac75e63015a4a25e034e1024bd5f8db Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 23 Aug 2023 19:06:02 +0530 Subject: [PATCH 5/5] Added account notes docs link to index files --- openapiSpecifications/index.md | 2 +- sequenceDiagrams/index.md | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/openapiSpecifications/index.md b/openapiSpecifications/index.md index c158bab..80de1ff 100644 --- a/openapiSpecifications/index.md +++ b/openapiSpecifications/index.md @@ -7,7 +7,7 @@ Below you will find a list of all OpenAPI specifications. Each specification is - [Auth](./Auth/Index.yaml) - [Auth: Salesforce](./Auth/Salesforce.yaml) - [Accounts](./Accounts.yaml) -- [Notes](./Notes.yaml) +- [AccountNotes](./AccountNotes.yaml) - [Users](./Users.yaml) diff --git a/sequenceDiagrams/index.md b/sequenceDiagrams/index.md index 615e44d..d13674f 100644 --- a/sequenceDiagrams/index.md +++ b/sequenceDiagrams/index.md @@ -4,20 +4,27 @@ Welcome to the Sequence Diagrams Documentation for SalesSparrow API. Here you will find all the sequence diagrams for the API endpoints. - Auth - - [Salesforce Connect](./Auth/SalesforceConnect.mermaid) - - [Redirect Url](./Auth/RedirectUrl.mermaid) - - [Logout](./Auth/Logout.mermaid) + - [Salesforce Connect](./Auth/SalesforceConnect.mermaid) + - [Redirect Url](./Auth/RedirectUrl.mermaid) + - [Logout](./Auth/Logout.mermaid) + - Accounts - - [Get Accounts](./Accounts/GetAccounts.mermaid) - - [Create Note](./Accounts/CreateNote.mermaid) - - [Get Notes List](./Accounts/GetNotesList.mermaid) - - [Get Note By Id](./Accounts/GetNoteById.mermaid) + - [Get Accounts](./Accounts/GetAccounts.mermaid) + - [Create Note](./Accounts/CreateNote.mermaid) + - [Get Notes List](./Accounts/GetNotesList.mermaid) + - [Get Note By Id](./Accounts/GetNoteById.mermaid) + +- Account Notes + - [Get Account Note By Id](./AccountNotes/GetNoteById.mermaid) + - [Get Account Notes List](./AccountNotes/GetNotesList.mermaid) + - [Create Account Note](./AccountNotes/CreateNote.mermaid) + - [Delete Account Note](./AccountNotes/DeleteNote.mermaid) - User - - [Get Current User](./User/GetCurrentUser.mermaid) + - [Get Current User](./User/GetCurrentUser.mermaid) - Common - - [OAuth Request Helper](./Common/OAuthRequestHelper.mermaid) - - [User Auth Interceptor](./Common/UserAuthIntercepter.mermaid) + - [OAuth Request Helper](./Common/OAuthRequestHelper.mermaid) + - [User Auth Interceptor](./Common/UserAuthIntercepter.mermaid) - [Salesforce OAuth Api Flow](./SalesforceOAuthApiFlow.mermaid)