Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added openAPI specification, Sequence Diagram And Postman collection for delete notes api #10

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
'204':
description: Success
2 changes: 1 addition & 1 deletion openapiSpecifications/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


31 changes: 31 additions & 0 deletions postman/AI-Sales-Sparrow.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
64 changes: 64 additions & 0 deletions sequenceDiagrams/AccountNotes/DeleteNote.mermaid
Original file line number Diff line number Diff line change
@@ -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: <br>DELETE {api_base_url}/v1/accounts/{account_id}/notes/{note_id}<br><br>path params: <br>account_id<br>note_id

note over api: Validate and fetch current user data from cookie<br>set currentUser attribute in request.<br><br>Refer this document for interceptor sequence diagram <br> './docs/sequenceDiagrams/Common/UserAuthIntercepter.mermaid'
break If currentUser not found
api-->>ui: Error Response<br>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<br>params: noteId, accountId

controller->>service: Call deleteNote method of DeleteNoteService<br> params: request, noteId, accountId
note over service: GetAttribute of currentUser from request<br>Which was set by interceptor

service->>factory: Call deleteNote method of DeleteNoteFactory<br>params: currentUser, noteId
note over factory: Based on currentUser identify CRM

factory->>crm: Call deleteNote method of particular CRM service<br>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<br>params: <br> List<requestType, url, referenceId>, salesforceUserId <br>

CompositeRequestWrapper->>salesforce: Make salesforce composite api call with commmon helper function<br><br>Refer this document for commmon helper function sequence diagram <br> './docs/sequenceDiagrams/Common/OAuthRequestHelper.mermaid'
note right of CompositeRequestWrapper: Request: POST {instance_url}/services/data/v58.0/composite <br><br>Params: <br> method: DELETE<br> url: "/services/data/v58.0/sobjects/ContentNote/${noteId}"<br>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: <br> {}<br><br>Response headers:<br> cookie
27 changes: 17 additions & 10 deletions sequenceDiagrams/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)