"""API Client for ows-abacus-account.""" import requests class AbacusAccountAPIClient: """API Client for ows-abacus-account.""" def __init__(self, base_url, headers): """Initialize ows_account_APIClient class.""" self.base_url = base_url self.headers = headers def post_account(self, body): """Execute a POST against /account endpoint.""" endpoint = '{}/account'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_accounts_by_search_term(self, body): """Execute a POST against /accounts endpoint (acts like GET).""" endpoint = '{}/accounts'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_account(self, account_id): """Execute a GET against /account/ endpoint.""" endpoint = '{}/account/{}'.format(self.base_url, account_id) return requests.get(endpoint, headers=self.headers) def get_account_dataloader(self, account_ids): """Execute a POST against /account/dataloader endpoint.""" endpoint = '{}/account/dataloader'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=account_ids) def put_account(self, account_id, body): """PUT /account/{account_id} .""" endpoint = '{}/account/{}'.format( self.base_url, account_id ) return requests.put(endpoint, json=body) def get_accounts(self): """Execute a GET against /accounts endpoint.""" endpoint = '{}/accounts'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def get_accounts_by_payee_id(self, body): """Execute a POST against /payees/accounts endpoint.""" endpoint = '{}/payees/accounts'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_tax_info_by_account_id(self, account_id): """GET /account/{account_id}/account-tax-info/ endpoint.""" endpoint = '{}/account/{}/account-tax-info'.format(self.base_url, account_id) return requests.get(endpoint, headers=self.headers) def post_account_tax_info(self, body): """Execute a POST against /account-tax-info endpoint.""" endpoint = '{}/account-tax-info'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_account_tax_info(self, account_tax_info_id): """GET /account-tax-info/{account_tax_info_id} endpoint.""" endpoint = '{}/account-tax-info/{}'.format(self.base_url, account_tax_info_id) return requests.get(endpoint, headers=self.headers) def put_account_tax_info(self, account_tax_info_id, body): """PUT /account-tax-info/{account_tax_info_id} endpoint.""" endpoint = '{}/account-tax-info/{}'.format(self.base_url, account_tax_info_id) return requests.put(endpoint, headers=self.headers, json=body) def get_eligible_accounts(self, params): """GET /eligible-accounts endpoint.""" endpoint = '{}/eligible-accounts'.format(self.base_url) return requests.get(endpoint, headers=self.headers, params=params) def get_payment_hold(self, account_id): """Execute a GET against /account//payment-hold endpoint.""" endpoint = '{}/account/{}/payment-hold'.format(self.base_url, account_id) return requests.get(endpoint, headers=self.headers) def post_payment_hold(self, account_id, body): """Execute a POST against /account//payment-hold endpoint.""" endpoint = '{}/account/{}/payment-hold'.format(self.base_url, account_id) return requests.post(endpoint, headers=self.headers, json=body) def get_payment_hold_history(self, account_id): """Execute a GET against /payment-hold-history endpoint.""" endpoint = '{}/account/{}/payment-hold-history'.format( self.base_url, account_id) return requests.get(endpoint, headers=self.headers) def post_account_payment_term(self, body): """Execute a POST against /account-payment-term endpoint.""" endpoint = '{}/account-payment-term/'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_account_payment_term_by_id(self, term_id): """Execute a GET against /account-payment-term/{term_id} endpoint.""" endpoint = '{}/account-payment-term/{}'.format(self.base_url, term_id) return requests.get(endpoint, headers=self.headers) def put_account_payment_term_by_id(self, term_id, body): """Execute a PUT against /account-payment-term/{term_id} endpoint.""" endpoint = '{}/account-payment-term/{}'.format(self.base_url, term_id) return requests.put(endpoint, headers=self.headers, json=body) def get_payment_term_by_account_id(self, account_id): """GET against /account/{account_id}/account-payment-term/ endpoint.""" endpoint = '{}/account/{}/account-payment-term'.format( self.base_url, account_id ) return requests.get(endpoint, headers=self.headers) def get_payment_term_by_account_id_dataloader(self, account_ids): """POST against /account/account-payment-term/dataloader endpoint.""" endpoint = '{}/account/account-payment-term/dataloader'.format( self.base_url ) return requests.post(endpoint, headers=self.headers, json=account_ids) def post_account_payment_term_template(self, template_id, body): """POST /account-payment-term-template/{template_id}/account-payment-term.""" endpoint = '{}/account-payment-term-template/{}/account-payment-term'.format( self.base_url, template_id ) return requests.post(endpoint, headers=self.headers, json=body) def get_payment_terms_snapshot(self, body): """POST /account-payment-terms/snapshot .""" endpoint = '{}/account-payment-terms/snapshot'.format(self.base_url) return requests.post(endpoint, json=body) def get_account_tax_info_snapshot(self, body): """POST /account-tax-info/snapshot .""" endpoint = '{}/account-tax-info/snapshot'.format(self.base_url) return requests.post(endpoint, json=body) def get_payment_payment_eligibility_status(self, account_id): """GET /account/payment-eligibility-status .""" endpoint = '{}/account/{}/payment-eligibility-status/'.format( self.base_url, account_id ) return requests.get(endpoint) def get_account_tax_info_history(self, account_id): """GET /account//account-tax-info-history .""" endpoint = '{}/account/{}/account-tax-info-history'.format( self.base_url, account_id ) return requests.get(endpoint) def post_account_payee(self, body): """POST /account-payee.""" endpoint = '{}/account-payee'.format( self.base_url ) return requests.post(endpoint, json=body) def get_account_payee(self, account_payee_id): """GET /account-payee/{account_payee_id .""" endpoint = '{}/account-payee/{}/'.format( self.base_url, account_payee_id ) return requests.get(endpoint) def get_account_payee_by_account_id(self, account_id): """GET /account/{account_id}/account-payee .""" endpoint = '{}/account/{}/account-payee'.format( self.base_url, account_id ) return requests.get(endpoint) def put_account_payee(self, account_payee_id, body): """PUT /account-payee.""" endpoint = '{}/account-payee/{}/'.format( self.base_url, account_payee_id ) return requests.put(endpoint, json=body) def get_account_payee_history_by_account_id( self, account_id ): """GET /account/{account_id}/account-payee-history/ .""" endpoint = '{}/account/{}/account-payee-history/'.format( self.base_url, account_id ) return requests.get(endpoint, headers=self.headers) def get_payoneer_programs(self): """GET /payoneer-program list.""" endpoint = '{}/payoneer-program'.format( self.base_url ) return requests.get(endpoint) def get_payoneer_program_by_id(self, program_id): """GET /payoneer-program/ .""" endpoint = '{}/payoneer-program/{}'.format( self.base_url, program_id ) return requests.get(endpoint) def get_payment_entity_payoneer_program_by_payment_entity_id( self, payment_entity_id ): """GET /payment-entity/{payment_entity_id}/payment-entity-payoneer-program .""" endpoint = '{}/payment-entity/{}/payment-entity-payoneer-program'.format( self.base_url, payment_entity_id ) return requests.get(endpoint) def get_sap_by_account_id(self, account_id): """GET /account/account_id/sap .""" endpoint = '{}/account/{}/sap'.format( self.base_url, account_id ) return requests.get(endpoint) def get_payment_entity_payoneer_programs(self): """GET /payment-entity-payoneer-programs .""" endpoint = '{}/payment-entity-payoneer-programs'.format(self.base_url) return requests.get(endpoint) def get_tax_info_by_account_ids(self, body): """GET /accounts/account-tax-info .""" endpoint = '{}/accounts/account-tax-info'.format(self.base_url) return requests.post(endpoint, json=body) def get_payoneer_program_move_type(self, from_program_id, to_program_id): """GET /payoneer-program-move-type .""" endpoint = '{}/payoneer-program-move-type'.format(self.base_url) return requests.get( endpoint, headers=self.headers, params={ 'from_program_id': from_program_id, 'to_program_id': to_program_id, }, )