コード例 #1
0
def subsidies_get(status=None):  # noqa: E501
    """Returns a list of subsidies.

     # noqa: E501


    :rtype: List[SubsidyBase]
    """
    response = service.subsidies.read_all(status)
    output = [SubsidyBase().from_dict(doc) for doc in response]
    return output
コード例 #2
0
def process_row(row: pd.Series, master_id: str):
    phnum = service.utils.format_phone_number(row['Mobiel nummer'])

    citizen = {
        'name': row['Voornaam'] + ' ' + row['Achternaam'],
        'email': row['Email'],
        'phone_number': phnum
    }

    try:
        CitizenBase.from_dict(citizen)
    except:
        raise service.exceptions.BadRequestException('Invalid Citizen input')

    citizen = service.citizens.create(citizen)

    subsidy = {
        'name': row['Subsidienaam'],
        'recipient': citizen,
        'comment': row['Referentie veld'],
        'start_date': row['Begindatum'],
        'end_date': row['Einddatum'],
        'amount': float(row['Bedrag']),
        'master': {
            'id': master_id
        },
    }

    try:
        SubsidyBase.from_dict(subsidy)
    except:
        service.citizens.delete(citizen['id'])
        raise service.exceptions.BadRequestException('Invalid Subsidy input')

    try:
        subsidy = service.subsidies.create(subsidy)
    except Exception as e:
        service.citizens.delete(citizen['id'])
        raise e

    return {'citizen': citizen, 'subsidy': subsidy}
コード例 #3
0
    def test_subsidies_post(self):
        """Test case for subsidies_post

        Create a new subsidy
        """
        body = SubsidyBase()
        response = self.client.open(
            '/v1/subsidies',
            method='POST',
            data=json.dumps(body),
            content_type='application/nl.kpmg.v1.subsidy-base+json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
コード例 #4
0
    def test_subsidies_id_put(self):
        """Test case for subsidies_id_put

        Re-upload a subsidy's information
        """
        body = SubsidyBase()
        response = self.client.open(
            '/v1/subsidies/{id}'.format(id='id_example'),
            method='PUT',
            data=json.dumps(body),
            content_type='application/nl.kpmg.v1.subsidy+json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
コード例 #5
0
def subsidies_get(status=None):  # noqa: E501
    """List all subsidies

    Subsidies are listed without their transactions. To get the transaction for the account associated with a particular subsidy, please use `GET /subsidies/{id}`. # noqa: E501

    :param status: The subsidy status filter can have the following values:  * **PENDING_ACCOUNT**: The citizen does not yet have a profile at a supported bank, and so has not received the subsidy  * **PENDING_ACCEPT**: The citizen does have an available bank profile, but has not yet accepted the request to access the subsidy account  * **OPEN**: The citizen has access to the subsidy  * **SHARE_CLOSED**: The citizen has canceled their access to the subsidy account and can no longer access the funds  * **CLOSED**: The subsidy has been ended via the subsidy service and the associated bank account is closed  * **ALL**: Lists all subsidies regardless of status.  If `status` left blank or not provided, this endpoint will list all PENDING_* and OPEN subsidies.
    :type status: str

    :rtype: List[SubsidyBase]
    """
    response = service.subsidies.read_all(status)
    output = [SubsidyBase().from_dict(doc) for doc in response]
    return output
コード例 #6
0
def subsidies_id_patch(id, body):  # noqa: E501
    """Edit a subsidy's information

     # noqa: E501

    :param id: 
    :type id: str
    :param body: subsidy properties to be updated
    :type body: dict | bytes

    :rtype: Subsidy
    """
    if connexion.request.is_json:
        body = SubsidyBase.from_dict(connexion.request.get_json())  # noqa: E501
    raise service.exceptions.NotImplementedException('Not yet implemented')
コード例 #7
0
def subsidies_post(body):  # noqa: E501
    """Create a new subsidy

    When creating a new subsidy, the following steps are carried out:  1. A new bank account is created under the configured bank profile  2. The subsidy amount is transferred from the indicated `master` to the new account  3. A share request is sent to the recipient   For these reasons, the following fields are required in the body:  * `master.id` or `master.iban` (the master must exist in the database)  * `recipient.id` or `recipient.phone_number` (the recipient must exist in the database)  * `amount`   The remaining fields will be created by the server. Note that `start_date` and `end_date` are not yet implemented and so will be ignored.   If the citizen has a bank profile at a supported bank and the share request was successfully sent, the `status` will come back as PENDING_ACCEPT. Otherwise, the `status` will come back as PENDING_ACCOUNT. The system will periodically attempt to resend the share request in case the citizen has created a bank profile. # noqa: E501

    :param body: The subsidy to create
    :type body: dict | bytes

    :rtype: Subsidy
    """
    if connexion.request.is_json:
        body = SubsidyBase.from_dict(connexion.request.get_json())  # noqa: E501

    response = service.subsidies.create(body.to_dict())
    return Subsidy.from_dict(response)
コード例 #8
0
def subsidies_id_put(id, body):  # noqa: E501
    """Re-upload a subsidy's information

     # noqa: E501

    :param id: 
    :type id: str
    :param body: subsidy details
    :type body: dict | bytes

    :rtype: Subsidy
    """
    if connexion.request.is_json:
        body = SubsidyBase.from_dict(connexion.request.get_json())  # noqa: E501
    raise service.exceptions.NotImplementedException('Not yet implemented')
コード例 #9
0
def subsidies_post(body):  # noqa: E501
    """Create a new subsidy

     # noqa: E501

    :param body: subsidy to add
    :type body: dict | bytes

    :rtype: Subsidy
    """
    if connexion.request.is_json:
        body = SubsidyBase.from_dict(
            connexion.request.get_json())  # noqa: E501

    response = service.subsidies.create(body.to_dict())
    return Subsidy.from_dict(response)