"""API Client for ows-payment.""" import requests class PaymentAPIClient: """API Client for ows-payment.""" def __init__(self, base_url, headers): """Initialize ows_payment_APIClient class.""" self.base_url = base_url self.headers = headers def get_hello(self): """Execute a GET against healthcheck endpoint.""" endpoint = '{}/hello'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def post_payment_group(self, body): """Execute a POST against /payment-group endpoint.""" endpoint = '{}/payment-group'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def post_payment_group_payment_batch(self, body): """Execute a POST against /payment-group-payment-batch/ endpoint.""" endpoint = '{}/payment-group-payment-batch'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def post_payment_group_payment_batch_account_bulk(self, body): """POST against /payment-group-payment-batch-account/bulk/ .""" endpoint = '{}/payment-group-payment-batch-account/bulk/'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_payment_group(self, group_id): """Execute a GET against /payment-group/.""" endpoint = '{}/payment-group/{}'.format(self.base_url, group_id) return requests.get(endpoint, headers=self.headers) def post_group_payment(self, body): """Execute a POST against /payment-group-payment endpoint.""" endpoint = '{}/payment-group-payment'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def post_payment_accounts(self, payment_group_payment_id, body): """POST /payment-group-payment/{payment_group_payment_id}/accounts/ .""" endpoint = '{}/payment-group-payment/{}/accounts/'.format( self.base_url, payment_group_payment_id ) return requests.post(endpoint, headers=self.headers, json=body) def get_group_payment(self, group_payment_id): """Execute a GET against /payment-group-payment endpoint.""" endpoint = '{}/payment-group-payment/{}'.format(self.base_url, group_payment_id) return requests.get(endpoint, headers=self.headers) def get_reusable_groups(self): """Execute a GET against /payment-group/reusable-groups endpoint.""" endpoint = '{}/payment-group/reusable-groups'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def post_payment_group_payment_accounts_bulk(self, payment_group_payment_id, body): """POST against /payment-group-payment/{payment_group_payment_id}/accounts/ .""" endpoint = '{}/payment-group-payment/{}/accounts/'.format( self.base_url, payment_group_payment_id ) return requests.post(endpoint, headers=self.headers, json=[body]) def get_last_payment_for_account(self, account_id): """GET /payment-group-payment-account/last-payment/{account_id}/ .""" endpoint = '{}/payment-group-payment-account/last-payment/{}/'.format( self.base_url, account_id ) return requests.get(endpoint, headers=self.headers) def put_payment_group_payment(self, payment_group_payment_id, body): """PUT /payment-group-payment/{payment_group_payment_id} .""" endpoint = '{}/payment-group-payment/{}'.format( self.base_url, payment_group_payment_id ) return requests.put(endpoint, headers=self.headers, json=body) def delete_payment_group_payment(self, payment_group_payment_id): """DELETE /payment-group-payment/{payment_group_payment_id} endpoint.""" endpoint = '{}/payment-group-payment/{}'.format( self.base_url, payment_group_payment_id ) return requests.delete(endpoint, headers=self.headers) def get_accounts_with_pending_payments(self, payment_group_payment_id): """GET /payment-group-payment//accounts/pending .""" endpoint = '{}/payment-group-payment/{}/accounts/pending/'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_payment_minimums(self): """Execute a GET against /payment-minimums endpoint.""" endpoint = '{}/payment-minimums'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def get_payment_minimums_for_currency(self, currency_id): """Execute a GET against /payment-minimum/ endpoint.""" endpoint = '{}/payment-minimums/{}'.format(self.base_url, currency_id) return requests.get(endpoint, headers=self.headers) def put_payment_minimums(self, body): """Execute a PUT against /payment-minimums endpoint.""" endpoint = '{}/payment-minimums'.format(self.base_url) return requests.put(endpoint, headers=self.headers, json=body) def get_payment_group_payment_account(self, payment_group_payment_account_id): """GET /payment-group-payment-account/.""" endpoint = '{}/payment-group-payment-account/{}'.format( self.base_url, payment_group_payment_account_id ) return requests.get(endpoint, headers=self.headers) def put_payment_group_payment_account(self, payment_group_payment_account_id, body): """PUT /payment-group-payment-account/.""" endpoint = '{}/payment-group-payment-account/{}'.format( self.base_url, payment_group_payment_account_id ) return requests.put(endpoint, headers=self.headers, json=body) def delete_payment_group_payment_account(self, payment_group_payment_account_id): """DELETE /payment-group-payment-account/.""" endpoint = '{}/payment-group-payment-account/{}'.format( self.base_url, payment_group_payment_account_id ) return requests.delete(endpoint, headers=self.headers) def get_reference_tax_withholding(self): """GET /reference-tax-withholding/.""" endpoint = '{}/reference-tax-withholding/'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def get_pending_payments_by_account_id(self, account_id): """GET /payment-group-payment-account/pending-payment/{account_id}/.""" endpoint = '{}/payment-group-payment-account/pending-payment/{}'.format( self.base_url, account_id ) return requests.get(endpoint, headers=self.headers) def download_report_by_report_id(self, report_payment_group_payment_id): """Download the specified report from S3.""" endpoint = '{}/report-payment-group-payment/{}/download'.format( self.base_url, report_payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_reports_by_payment_group_payment(self, payment_group_payment_id): """Get list of reports for the specified payment_group_payment.""" endpoint = '{}/payment-group-payment/{}/reports'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def upsert_report_payment_group_payment(self, payment_group_payment_id, body): """Upsert report_payment_group_payment.""" endpoint = '{}/payment-group-payment/{}/report'.format( self.base_url, payment_group_payment_id ) return requests.put(endpoint, headers=self.headers, json=body) def get_program_currency_totals_by_payment_id(self, payment_group_payment_id): """Get amount totals grouped by Payoneer Program id.""" endpoint = '{}/payment-group-payment/{}/program-currency-totals/'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_report_by_report_id(self, report_payment_group_payment_id): """Get report by report id.""" endpoint = '{}/report-payment-group-payment/{}/'.format( self.base_url, report_payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def delete_report_by_report_id(self, report_payment_group_payment_id): """DELETE report by report id.""" endpoint = '{}/report-payment-group-payment/{}/'.format( self.base_url, report_payment_group_payment_id ) return requests.delete(endpoint, headers=self.headers) def get_payment_batches_by_payment_id_and_status( self, payment_group_payment_id, payment_batch_status ): """Get payment batches for a Payment Group Payment and batch status.""" endpoint = '{}/payment-group-payment/{}/payment-batches/{}/'.format( self.base_url, payment_group_payment_id, payment_batch_status ) return requests.get(endpoint, headers=self.headers) def get_payment_batches_by_payment_id(self, payment_group_payment_id): """Get a list of payment batches for a specified Payment Group Payment.""" endpoint = '{}/payment-group-payment/{}/payment-batches/'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_payment_status_overview(self, payment_group_payment_id): """Get a list of payment batches for a specified Payment Group Payment.""" endpoint = '{}/payment-group-payment/{}/payment-status-overview/'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_payment_group_payments(self): """GET /payment-group-payment .""" endpoint = '{}/payment-group-payment'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def get_payment_group_payment_overview(self, payment_group_payment_id): """GET /payment-group-payment/{payment_group_payment_id}/overview/ .""" endpoint = '{}/payment-group-payment/{}/overview'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_payment_group_payment_accounts(self, payment_group_payment_id): """GET /payment-group-payment/{payment_group_payment_id}/accounts/ .""" endpoint = '{}/payment-group-payment/{}/accounts'.format( self.base_url, payment_group_payment_id ) return requests.get(endpoint, headers=self.headers) def get_payment_minimums_by_currency(self): """GET /payment-minimums/by-currency/ .""" endpoint = '{}/payment-minimums/by-currency'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def post_payment_contract_advance(self, contract_advance_id, body): """POST /payment/advance/ .""" endpoint = '{}/payment/advance/{}'.format(self.base_url, contract_advance_id) return requests.post(endpoint, headers=self.headers, json=body) def put_payment_contract_advance(self, worksheet_payment_contract_advance_id, body): """PUT /payment/advance/worksheet/ .""" endpoint = '{}/payment/advance/worksheet/{}'.format( self.base_url, worksheet_payment_contract_advance_id ) return requests.put(endpoint, headers=self.headers, json=body) def get_payment_contract_advance(self, worksheet_payment_contract_advance_id): """GET /payment/advance/worksheet/ .""" endpoint = '{}/payment/advance/worksheet/{}'.format( self.base_url, worksheet_payment_contract_advance_id ) return requests.get(endpoint, headers=self.headers) def delete_payment_contract_advance(self, worksheet_payment_contract_advance_id): """DELETE /payment/advance/worksheet/ .""" endpoint = '{}/payment/advance/worksheet/{}'.format( self.base_url, worksheet_payment_contract_advance_id ) return requests.delete(endpoint, headers=self.headers) def get_payments_advances(self): """GET /payments/advances .""" endpoint = '{}/payments/advances'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def post_worksheet_dataloader(self, body): """POST /payment/advance/worksheet/dataloader .""" endpoint = '{}/payment/advance/worksheet/dataloader'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def delete_worksheet_payable_balance_after_tax_bulk(self, event_id): """DELETE /worksheet-payable-balance-after-tax/event//bulk .""" endpoint = '{}/worksheet-payable-balance-after-tax/event/{}/bulk'.format( self.base_url, event_id ) return requests.delete(endpoint, headers=self.headers) def delete_worksheet_account_contract_closing_balance_bulk(self, event_id): """DELETE /worksheet-account-contract-closing-balance/event//bulk/ .""" endpoint = ( f'{self.base_url}/worksheet-account-contract-closing-balance/' f'event/{event_id}/bulk' ) return requests.delete(endpoint, headers=self.headers) def post_worksheet_account_contract_closing_balance_bulk( self, event_id, statement_period_id, entity_id, body ): """POST /worksheet-account-contract-closing-balance bulk .""" endpoint = ( f'{self.base_url}/worksheet-account-contract-closing-balance/' f'event/{event_id}/' f'statement-period/{statement_period_id}/payment-entity/{entity_id}/bulk/' ) return requests.post(endpoint, headers=self.headers, json=body) def post_worksheet_payable_balance_after_tax_bulk( self, event_id, statement_period_id, body ): """POST /worksheet-payable-balance-after-tax bulk .""" endpoint = ( f'{self.base_url}/worksheet-payable-balance-after-tax/' f'event/{event_id}/statement-period/{statement_period_id}/bulk/' ) return requests.post(endpoint, headers=self.headers, json=body) def get_worksheet_account_contract_closing_balance_by_statement_period_id( self, statement_period_id, **kwargs ): """GET /worksheet-account-contract-closing-balance/statement-period/{statement_period_id>}/""" # noqa endpoint = ( f'{self.base_url}' f'/worksheet-account-contract-closing-balance/statement-period/' f'{statement_period_id}/' ) return requests.get(endpoint, params=kwargs) def get_worksheet_payable_balance_after_tax(self, statement_period_id): """GET /worksheet-payable-balance-after-tax/statement-period/""" # noqa endpoint = ( f'{self.base_url}' f'/worksheet-payable-balance-after-tax/statement-period/' f'{statement_period_id}/' ) return requests.get(endpoint, headers=self.headers) def post_worksheet_account_contract_payable_details_bulk( self, event_id, statement_period_id, body ): """POST /worksheet-account-contract-payable-details bulk .""" endpoint = ( f'{self.base_url}/worksheet-account-contract-payable-details/' f'event/{event_id}/statement-period/{statement_period_id}/bulk/' ) return requests.post(endpoint, headers=self.headers, json=body) def delete_worksheet_account_contract_payable_details(self, event_id): """DELETE /worksheet-account-contract-payable-details/event/ .""" endpoint = ( f'{self.base_url}/worksheet-account-contract-payable-details/' f'event/{event_id}' ) return requests.delete(endpoint, headers=self.headers) def get_worksheet_payable_balance_after_tax_by_event(self, event_id): """GET /worksheet-payable-balance-after-tax/event/ .""" # noqa endpoint = ( f'{self.base_url}' f'/worksheet-payable-balance-after-tax/event/' f'{event_id}/' ) return requests.get(endpoint, headers=self.headers) def get_payment_group_payment_account_credit_details( self, payment_group_payment_account_id, payment_type ): """GET /payment-group-payment-account/{payment_group_payment_account_id}/{payment_type}/credit .""" # noqa endpoint = ( f'{self.base_url}' f'/payment-group-payment-account/{payment_group_payment_account_id}/' f'{payment_type}/credit' ) return requests.get(endpoint, headers=self.headers) def get_payment_group_payment_batch_debit_details( self, payment_group_payment_batch_id, payment_type ): """GET /payment-group-payment-batch/{payment_group_payment_batch_id}/{payment_type}/debit .""" # noqa endpoint = ( f'{self.base_url}' f'/payment-group-payment-batch/{payment_group_payment_batch_id}/' f'{payment_type}/debit' ) return requests.get(endpoint, headers=self.headers) def get_worksheet_account_contract_payable_details_by_period( self, statement_period_id, body ): """POST /worksheet-account-contract-payable-details/statement-period/ .""" # noqa endpoint = ( f'{self.base_url}' f'/worksheet-account-contract-payable-details/statement-period/' f'{statement_period_id}' ) return requests.post(endpoint, headers=self.headers, json=body) def post_tax_corrections(self, body): """POST /tax-corrections/bulk .""" endpoint = '{}/tax-corrections/bulk/'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_tax_corrections(self, correction_type, correction_status, body): """POST /tax-corrections/{correction_type}/{correction_status} .""" # noqa endpoint = ( f'{self.base_url}' f'/tax-corrections/{correction_type}/{correction_status}' f'/?limit=1&offset=0' ) return requests.post(endpoint, headers=self.headers, json=body) def delete_tax_corrections(self, body): """DELETE /tax-corrections/bulk .""" endpoint = '{}/tax-corrections/bulk/'.format(self.base_url) return requests.delete(endpoint, headers=self.headers, json=body) def post_worksheet_account_contract_closing_balance_dataloader(self, body): """POST /worksheet-account-contract-closing-balance/by_payment_account_ids/dataloader .""" # noqa endpoint = ( f'{self.base_url}' f'/worksheet-account-contract-closing-balance' f'/by-payment-account-ids/dataloader' ) return requests.post(endpoint, headers=self.headers, json=body) def post_worksheet_account_contract_closing_balance_taxable_revenue_copy( self, event_id ): """POST /worksheet-account-contract-closing-balance/event/{event_id}/taxable-revenue/copy/ .""" # noqa endpoint = ( f'{self.base_url}' f'/worksheet-account-contract-closing-balance' f'/event/{event_id}' f'/taxable-revenue/copy/' ) return requests.post(endpoint, headers=self.headers) def post_worksheet_account_contract_taxable_revenue_bulk(self, event_id, body): """POST /worksheet-account-contract-taxable-revenue/event//bulk/ .""" endpoint = ( '{}/worksheet-account-contract-taxable-revenue/event/{}/bulk/'.format( self.base_url, event_id ) ) return requests.post(endpoint, headers=self.headers, json=body) def get_taxable_revenue_by_statement_period_id(self, statement_period_id): """GET /worksheet-account-contract-taxable-revenue/statement-period/ .""" endpoint = ( '{}/worksheet-account-contract-taxable-revenue/statement-period/{}'.format( self.base_url, statement_period_id ) ) return requests.post(endpoint, headers=self.headers) def delete_taxable_revenue_by_event_id(self, event_id): """DELETE /worksheet-account-contract-taxable-revenue/event/ .""" endpoint = '{}/worksheet-account-contract-taxable-revenue/event/{}/'.format( self.base_url, event_id ) return requests.delete(endpoint, headers=self.headers) def post_tax_corrections_vat_bulk(self, body): """POST /tax-corrections/vat/bulk/ .""" endpoint = '{}/tax-corrections/vat/bulk/'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_tax_corrections_vat_list(self, correction_status, body, params=None): """POST /tax-corrections/vat// .""" endpoint = '{}/tax-corrections/vat/{}/'.format(self.base_url, correction_status) return requests.post(endpoint, headers=self.headers, json=body, params=params) def delete_tax_corrections_vat_list(self, body): """DELETE /tax-corrections/vat/bulk/ .""" endpoint = '{}/tax-corrections/vat/bulk/'.format(self.base_url) return requests.delete(endpoint, headers=self.headers, json=body) def post_reference_payment_type_dataloader(self, body): """POST /reference-payment-type/dataloader .""" endpoint = '{}/reference-payment-type/dataloader'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def payment_search_search(self, body): """POST /payment-search/search.""" endpoint = '{}/payment-search/search'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body)