-
Notifications
You must be signed in to change notification settings - Fork 118
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
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.
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", | ||
}; |
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.
👍 really good typing!
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.
Looking like a good start of re-use.
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.
Looking good!
daterange: "date", | ||
|
||
// TODO | ||
time: null, // time in the format of "00:00:00" |
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
plugins/@grouparoo/pipedrive/src/lib/export/organizations/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
plugins/@grouparoo/pipedrive/src/lib/export/persons/destinationMappingOptions.ts
Show resolved
Hide resolved
plugins/@grouparoo/pipedrive/src/lib/export/persons/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why this was happening? is it different than rate limiting?
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.
This happens when you have local network issues and trying to send many requests in a few amount of time!
plugins/@grouparoo/pipedrive/src/lib/export-organizations/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
plugins/@grouparoo/pipedrive/src/lib/export-organizations/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
plugins/@grouparoo/pipedrive/src/lib/export-organizations/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
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.
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.
plugins/@grouparoo/pipedrive/src/lib/common/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
plugins/@grouparoo/pipedrive/src/lib/common/destinationMappingOptions.ts
Outdated
Show resolved
Hide resolved
…export' into feature/pipedrive-organizations-export
Change description
Checklists
Development
Impact
Please explain any security, performance, migration, or other impacts if relevant:
Code review