#!/usr/bin/python3

import argparse

import requests
import zeep
from zeep.transports import Transport
from zeep.wsse.username import UsernameToken

WSSE = UsernameToken('maelis-webservice', 'maelis-password')
WSDL_URL = 'https://demo-toulouse.sigec.fr/maelisws-toulouse-recette/services/FamilyService?wsdl'


def read_family(family_id, verbose):
    session = requests.Session()
    session.verify = False
    transport = Transport(session=session)
    settings = zeep.Settings(strict=False, xsd_ignore_sequence_order=True)
    client = zeep.Client(WSDL_URL, transport=transport, wsse=WSSE, settings=settings)

    result = client.service.readFamily(
        dossierNumber=family_id,
        # schoolYear=
        # incomeYear=2022,  # <-- pour filtrer les quotients sur cette année
        # referenceYear=2020,
    )
    print(result)


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--verbose', '-v', type=int, default=2, help='display errors')
    parser.add_argument('family_id', help='196544', nargs='?', default='196544')
    args = parser.parse_args()
    read_family(args.family_id, verbose=args.verbose)
