import requests
from .exceptions import ParameterError

class InvoiceAPI:
    def __init__(self, app_id, api_key=None, timeout=10, stage="PROD"):
        self.app_id = app_id
        self.api_key = api_key
        if stage == "PROD":
            self.endpoint = "https://api.einvoice.nat.gov.tw"
        else:
            self.endpoint = "https://wwwtest.einvoice.nat.gov.tw"
        self.timeout = timeout


    def get_winning_number(self, invTerm, version="0.2", action="QryWinningList"):
        url = self.endpoint + "/PB2CAPIVAN/invapp/InvApp"

    def get_invoice_header(self, invNum, invDate, version="0.5", inv_type="QRCode", action="qryInvHeader", generation="V2"):
        if inv_type not in ["QRCode", "Barcode"]:
            raise ParameterError(parameter_name="type", message="type should be 'QRCode' or 'Barcode'")


if __name__ == '__main__':
    invoice_api = InvoiceAPI(app_id='123')
    invoice_api.get_invoice_header(invNum="111", invDate="200")