Exemple #1
0
    def _from_json_array_nested(cls, response_raw):
        """
        :type response_raw: client.BunqResponseRaw

        :rtype: bunq.sdk.client.BunqResponse[cls]
        """

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        value = converter.deserialize(cls, obj[cls._FIELD_RESPONSE])

        return client.BunqResponse(value, response_raw.headers)
Exemple #2
0
    def _process_for_uuid(cls, response_raw):
        """
        :type response_raw: client.BunqResponseRaw

        :rtype: client.BunqResponse[str]
        """

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        uuid = converter.deserialize(
            Uuid, cls._unwrap_response_single(obj, cls._FIELD_UUID))

        return client.BunqResponse(uuid.uuid, response_raw.headers)
Exemple #3
0
    def _process_for_id(cls, response_raw):
        """
        :type response_raw: client.BunqResponseRaw

        :rtype: client.BunqResponse[int]
        """

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        id_ = converter.deserialize(
            Id, cls._unwrap_response_single(obj, cls._FIELD_ID))

        return client.BunqResponse(id_.id_, response_raw.headers)
Exemple #4
0
    def _from_json(cls, response_raw, wrapper=None):
        """
        :type response_raw: client.BunqResponseRaw
        :type wrapper: str|None

        :rtype: client.BunqResponse[cls]
        """

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        value = converter.deserialize(
            cls, cls._unwrap_response_single(obj, wrapper))

        return client.BunqResponse(value, response_raw.headers)
Exemple #5
0
    def _from_json_list(cls, response_raw, wrapper=None):
        """
        :type response_raw: client.BunqResponseRaw
        :type wrapper: str|None

        :rtype: client.BunqResponse[list[cls]]
        """

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        array = obj[cls._FIELD_RESPONSE]
        array_deserialized = []

        for item in array:
            item_unwrapped = item if wrapper is None else item[wrapper]
            item_deserialized = converter.deserialize(cls, item_unwrapped)
            array_deserialized.append(item_deserialized)

        pagination = converter.deserialize(client.Pagination,
                                           obj[cls._FIELD_PAGINATION])

        return client.BunqResponse(array_deserialized, response_raw.headers,
                                   pagination)