import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { IAccessTokenSecretPair , IAccessTokenDto , IAccessToken , IEngagement , IUpworkApiConfig , IIntegrationMap , IntegrationEnum , IUpworkClientSecretPair } from '@gauzy/contracts' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( { providedIn : 'root' } ) export class UpworkService { constructor ( private http ) { } uploadTransaction ( formData ) { return this . http . post ( `${ API_PREFIX }/integrations/upwork/transactions` , formData ) ; } getAccessTokenSecretPair ( config , organizationId ) { return this . http . post < IAccessTokenSecretPair > ( `${ API_PREFIX }/integrations/upwork/token-secret-pair/${ organizationId }` , config ) ; } getAccessToken ( accessTokenDto , organizationId ) { return this . http . post < IAccessToken > ( `${ API_PREFIX }/integrations/upwork/access-token/${ organizationId }` , accessTokenDto ) ; } getContracts ( config ) { const data = JSON . stringify ( { config } ) ; return this . http . get < IEngagement [ ] > ( `${ API_PREFIX }/integrations/upwork/freelancer-contracts` , { params : { data } } ) ; } getConfig ( dto ) { const { integrationId , data } = dto ; return this . http . get < IUpworkApiConfig > ( `${ API_PREFIX }/integrations/upwork/config/${ integrationId }` , { params : { data } } ) ; } syncContracts ( syncContractsDto ) { return this . http . post < IIntegrationMap [ ] > ( `${ API_PREFIX }/integrations/upwork/sync-contracts` , syncContractsDto ) ; } syncContractsRelatedData ( dto ) { return this . http . post < IIntegrationMap [ ] > ( `${ API_PREFIX }/integrations/upwork/sync-contracts-related-data` , dto ) ; } getAllReports ( dto ) { const { integrationId , data } = dto ; return this . http . get < any > ( `${ API_PREFIX }/integrations/upwork/report/${ integrationId }` , { params : { data } } ) ; } checkRemeberState ( organizationId ) { return this . http . get < any > ( `${ API_PREFIX }/integration/check/state/${ IntegrationEnum . UPWORK }/${ organizationId }` ) ; } }