import { Injectable } from '@angular/core'; import { HttpRestService } from '@core/services/http-rest.service'; import { AddOrgAPI } from '@core/typings/api/add-org.typing'; import { ApplicantForOrg } from '@core/typings/applicant.typing'; import { ClassificationForOrgs, CompanyOrgDetail, NonprofitAdditionalDataApi, NonprofitDataApi, NonprofitProfileSummary, NonprofitTop10, NonprofitTopLevelStats, OrgForDash } from '@core/typings/organization.typing'; import { AwardForOrg } from '@features/awards/typings/award.typing'; import { BucketSearchAPIResponse, OrganizationSearchResponse, PaginatedResponse, PaginationOptions, SearchFilter, SearchResult } from '@yourcause/common'; @Injectable({ providedIn: 'root' }) export class NonprofitResources { constructor ( private httpRestService: HttpRestService ) { } getNonprofitByGuid (guid: string): Promise { const endpoint = `/api/lookup/GetNppOrganization?nonprofitGuid=${guid}`; return this.httpRestService.get(endpoint); } getNonprofitAdditionalDataByGuid (guid: string): Promise { const endpoint = `/api/lookup/GetNonprofitAdditionalData?nonprofitGuid=${guid}`; return this.httpRestService.get(endpoint); } getIdByNonprofitGuid (guid: string) { const endpoint = `api/portal/applicant/organization/GetIdByNonprofitGuid?nonprofitGuid=${guid}`; return this.httpRestService.get(endpoint); } getCompanyOrgDetail (id: number): Promise { const endpoint = `api/manager/organizations/${id}`; return this.httpRestService.get(endpoint); } getOrgSummary (id: number): Promise { const endpoint = `api/manager/applicationsdashboard/GetOrgSummary/${id}`; return this.httpRestService.get(endpoint); } getApplicantsForOrg ( id: number, paginationOptions: PaginationOptions ): Promise { const endpoint = `api/manager/applicationsdashboard/GetApplicantsForOrg/${id}`; return this.httpRestService.post(endpoint, { paginationOptions }); } getAwardsForOrg ( id: number, paginationOptions: PaginationOptions ): Promise { const endpoint = `api/manager/applicationsdashboard/GetAwardsForOrg/${id}`; return this.httpRestService.post(endpoint, { paginationOptions }); } async getNonprofitStats ( programCycleIds: number[] ): Promise { const endpoint = 'api/manager/insights/organization/stats'; return this.httpRestService.post(endpoint, { programCycleIds }); } async getNonprofits ( programCycleIds: number[] ): Promise { const endpoint = 'api/manager/insights/organization/topten'; return this.httpRestService.post(endpoint, { programCycleIds }); } async getClassifications ( programCycleIds: number[] ): Promise { const endpoint = 'api/manager/insights/organization/classifications'; return this.httpRestService.post(endpoint, { programCycleIds }); } async getOrgsForInsights ( paginationOptions: PaginationOptions, programCycleIds: number[], isCsv = false ) { const endpoint = 'api/manager/insights/organizations'; return this.httpRestService.post(endpoint, { paginationOptions, programCycleIds }, isCsv ? { Accept: 'text/csv' } : undefined ); } searchPublicNonprofits ( searchText: string, searchFilters: SearchFilter[] = [], pageNumber: number, rowsPerPage: number ) { const endpoint = 'api/lookup/SearchNpp'; return this.httpRestService.post(endpoint, { searchText, searchFilters, pageNumber, rowsPerPage }); } searchNonprofitsWithinBucket ( terms: string, page: number, pageSize: number, clientId: number, bucketId: string, filters?: { state: string; country: string; } ): Promise { const endpoint = '/api/Charity/search/' + clientId + '/buckets/' + bucketId; return this.httpRestService.post(endpoint, { terms, page, pageSize, filters }); } searchPrivateOrgs ( clientId: number, paginationOptions: PaginationOptions ): Promise<{records: OrganizationSearchResponse[]; recordCount: number}> { const endpoint = '/api/portal/applicant/ClientOrganizations'; return this.httpRestService.post(endpoint, { clientId, paginationOptions }); } getVettingStatus (nonprofitGuid: string) { const endpoint = `api/VettingController/GetNppNonprofitVettingStatus?nonprofitGuid=${nonprofitGuid}`; return this.httpRestService.get(endpoint); } addOrVetOrganization (payload: AddOrgAPI.AddOrVetOrgPayload) { const endpoint = `api/VettingController/AddOrVetOrganization`; return this.httpRestService.post(endpoint, payload); } submitVettingRequestByApplicant (payload: AddOrgAPI.SubmitEdVettingRequestPayload) { /// for orgs found in NPP Int Search that are not vetted const endpoint = `api/VettingController/SubmitEdVettingRequestByApplicant`; return this.httpRestService.post(endpoint, payload); } }