"""API Client for ows-royalties.""" import requests class RoyaltiesAPIClient: """API Client for ows-royalties.""" def __init__(self, base_url, headers): """Initialize ows_royalties_APIClient class.""" self.base_url = base_url self.headers = headers def get_accounting_periods(self): """Execute a GET against /accounting-periods endpoint.""" endpoint = '{}/accounting-periods'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def get_accounting_period_runs(self, period_id): """Execute a POST against /accounting-period/{id}/accounting-runs.""" endpoint = '{}/accounting-period/{}/accounting-runs'.format( self.base_url, period_id ) return requests.get(endpoint) def post_contract(self, body): """Execute a POST against /contract endpoint.""" endpoint = '{}/contract'.format(self.base_url) return requests.post(endpoint, headers=self.headers, json=body) def get_contract(self, contract_id): """Execute a GET against /contract/ endpoint.""" endpoint = '{}/contract/{}'.format(self.base_url, contract_id) return requests.get(endpoint, headers=self.headers) def get_contracts(self): """Execute a GET against /contracts endpoint.""" endpoint = '{}/contracts'.format(self.base_url) return requests.get(endpoint, headers=self.headers) def generate_contract_body(self, contract_name, contract_type='distribution'): """Generate a body for POST /contract endpoint.""" return { 'contract_name': contract_name, 'contract_type': contract_type, 'term_start': '2019-06-01', 'term_end': '2020-06-01', 'reference_signing_entity_id': 1, }