-
Notifications
You must be signed in to change notification settings - Fork 4
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
[Refactor]: Opportunity Api calling methods #71
base: refactor/api_call
Are you sure you want to change the base?
Conversation
@@ -102,7 +102,12 @@ const Projects = { | |||
} | |||
|
|||
const Opportunities = { | |||
list: () => requests.get<Opportunity[]>('opportunities'), | |||
list: (params?: URLSearchParams) => requests.get<Opportunity[]>('opportunities', params), | |||
post: (body: Opportunity) => requests.post<Opportunity>('opportunities', body), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'body: Opportunity' - Is this right approach to write?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body is good, but to be more specific it should be opportunity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, please read the requested changes and let's discuss any confusing concepts here or in the meeting. thanks 🚀
@@ -102,7 +102,12 @@ const Projects = { | |||
} | |||
|
|||
const Opportunities = { | |||
list: () => requests.get<Opportunity[]>('opportunities'), | |||
list: (params?: URLSearchParams) => requests.get<Opportunity[]>('opportunities', params), | |||
post: (body: Opportunity) => requests.post<Opportunity>('opportunities', body), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body is good, but to be more specific it should be opportunity
src/utils/agent.ts
Outdated
list: () => requests.get<Opportunity[]>('opportunities'), | ||
list: (params?: URLSearchParams) => requests.get<Opportunity[]>('opportunities', params), | ||
post: (body: Opportunity) => requests.post<Opportunity>('opportunities', body), | ||
getCount: () => requests.get<Object>('opportunities/count'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're going get number
rather than Object
list: (params?: URLSearchParams) => requests.get<Opportunity[]>('opportunities', params), | ||
post: (body: Opportunity) => requests.post<Opportunity>('opportunities', body), | ||
getCount: () => requests.get<Object>('opportunities/count'), | ||
getDetails: (id: string) => requests.get<Opportunity>(`opportunities/${id}`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id should be number
post: (body: Opportunity) => requests.post<Opportunity>('opportunities', body), | ||
getCount: () => requests.get<Object>('opportunities/count'), | ||
getDetails: (id: string) => requests.get<Opportunity>(`opportunities/${id}`), | ||
update: (id: string, body: Opportunity) => requests.put<Opportunity>(`opportunities/${id}`, body), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id should be number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body is suppose to have all the interface properties set to optional because when send a put request to an api you only want to change specific fields and not everything.
check this out, maybe you'll learn something great with these utility types
https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype
getCount: () => requests.get<Object>('opportunities/count'), | ||
getDetails: (id: string) => requests.get<Opportunity>(`opportunities/${id}`), | ||
update: (id: string, body: Opportunity) => requests.put<Opportunity>(`opportunities/${id}`, body), | ||
delete: (id: string) => requests.delete<Object>(`opportunities/${id}`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id should be number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the id is technically a number but it's not a huge deal if you keep it string
No description provided.