Skip to content
Merged
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
16 changes: 7 additions & 9 deletions src/@seed/api/salesforce/salesforce.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export class SalesforceService {
return response
}),
catchError((error: HttpErrorResponse) => {
// TODO need to figure out error handling
return this._errorService.handleError(error, 'Error fetching organization')
return this._errorService.handleError(error, 'Error fetching Salesforce config')
}),
)
}
Expand All @@ -64,22 +63,20 @@ export class SalesforceService {
return response
}),
catchError((error: HttpErrorResponse) => {
// TODO need to figure out error handling
return this._errorService.handleError(error, 'Error fetching organization')
return this._errorService.handleError(error, 'Error fetching Salesforce mappings')
}),
)
}

create(organizationId: number, config: SalesforceConfig): Observable<SalesforceConfig> {
console.log('Creating: ', config)
const url = `/api/v3/salesforce_configs/?organization_id=${organizationId}`
return this._httpClient.post<SalesforceConfigResponse>(url, { ...config }).pipe(
map((response) => {
this._config.next(response.salesforce_config)
return response.salesforce_config
}),
catchError((error: HttpErrorResponse) => {
return this._errorService.handleError(error, 'Error fetching organization')
return this._errorService.handleError(error, 'Error creating Salesforce config')
}),
)
}
Expand All @@ -93,7 +90,7 @@ export class SalesforceService {
return response.salesforce_config
}),
catchError((error: HttpErrorResponse) => {
return this._errorService.handleError(error, 'Error fetching organization')
return this._errorService.handleError(error, 'Error updating Salesforce config')
}),
)
}
Expand All @@ -119,10 +116,11 @@ export class SalesforceService {
return response
}),
catchError((error: HttpErrorResponse) => {
return this._errorService.handleError(error, `Salesforce Mapping could not be created: ${error.message}`)
return this._errorService.handleError(error, 'Error creating Salesforce mapping')
}),
)
}

updateMapping(organizationId: number, mapping: SalesforceMapping): Observable<SalesforceMappingResponse> {
const url = `/api/v3/salesforce_mappings/${mapping.id}/?organization_id=${organizationId}`
return this._httpClient.put<SalesforceMappingResponse>(url, { ...mapping }).pipe(
Expand All @@ -131,7 +129,7 @@ export class SalesforceService {
return response
}),
catchError((error: HttpErrorResponse) => {
return this._errorService.handleError(error, `Salesforce Mapping could not be created: ${error.message}`)
return this._errorService.handleError(error, 'Error updating Salesforce mapping')
}),
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/@seed/api/salesforce/salesforce.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type SalesforceConfigsResponse = {
export type SalesforceMapping = {
id: number;
organization_id: number;
column: 10;
column: number;
salesforce_fieldname: string;
}

Expand Down
Loading
Loading