Conversation
- Generalize common API calls. - Add API calls for organizations.
Examples of code changes depending on that: - `client.deletePerson()` -> `client.persons.delete()` - `client.getAllPersonFields()` -> `client.persons.fields.getAll()` - `client.getAllPersonFilters()` -> `client.persons.filters.getAll()`
…export' into feature/pipedrive-organizations-export
evantahler
left a comment
There was a problem hiding this comment.
Good start!
The next step would be to add tests for exporting Orginizations. We should re-orginize the test suite to have an export record test for both Profiles and Organizations. We use nock to actually record the the HTTP requests locally so we can ensure that the API is being used the way we expect.
Also a suggestion for the linter - if you are using VSCode, install the prettier plugin and your files will be auto-formatter on save.
| type Entity = 'persons' | 'organizations'; | ||
| type EntityField = 'personFields' | 'organizationFields'; | ||
| type FilterType = 'people' | 'org'; | ||
|
|
||
| const EntityFieldMapping: Record<Entity, EntityField> = { | ||
| persons: "personFields", | ||
| organizations: "organizationFields", | ||
| }; | ||
|
|
||
| const FilterTypeMapping: Record<Entity, FilterType> = { | ||
| persons: "people", | ||
| organizations: "org", | ||
| }; |
bleonard
left a comment
There was a problem hiding this comment.
Looking like a good start of re-use.
| daterange: "date", | ||
|
|
||
| // TODO | ||
| time: null, // time in the format of "00:00:00" |
There was a problem hiding this comment.
@pauloouriques is mapping many of these to string. I think we can do that here too for time
There was a problem hiding this comment.
By looking to this function
function formatVar(value) {
if (value === undefined) {
return null;
}
if (value instanceof Date) {
return value.toISOString();
}
return value;
}Mapping dates are applicable because there is a type Date, in our case here, how to detect time values??
There was a problem hiding this comment.
We don;t have the type of "time" but making this a string will allow the user to come up with their own string property in the right format and be able to set the remote field.
bleonard
left a comment
There was a problem hiding this comment.
Looking good. interested in any refactorings that we should do.
| this.request.interceptors.response.use( | ||
| (response) => response, | ||
| (error) => { | ||
| if (error.code === "ECONNRESET") { |
There was a problem hiding this comment.
Any idea why this was happening? is it different than rate limiting?
There was a problem hiding this comment.
This happens when you have local network issues and trying to send many requests in a few amount of time!
bleonard
left a comment
There was a problem hiding this comment.
maybe more complex but it's DRY'd up. Few notes on caching in particular. Some likely issues if those keys are shared across types.
…export' into feature/pipedrive-organizations-export
Change description
Checklists
Development
Impact
Please explain any security, performance, migration, or other impacts if relevant:
Code review