Exemplo n.º 1
0
 def get(self, user_id, **kwargs):
     addresses_data = list(
         map(
             lambda address: formatter.make(address, formatting.
                                            address_format),
             api.get_user_addresses(user_id)))
     return addresses_data
Exemplo n.º 2
0
    def post(self, user_id, **kwargs):
        data = request.get_json()
        address_string = data.get("address")
        address = api.get_or_create_address(user_id, address_string)
        address_data = formatter.make(address, formatting.address_format)

        return address_data
Exemplo n.º 3
0
 def get(self, user_id, address_id, **kwargs):
     address = api.get_user_address(user_id, address_id)
     if address is None:
         raise APIException(404, 'Not found')
     address = api.update_user_address(user_id, address_id)
     address_data = formatter.make(address, formatting.address_format)
     return address_data
Exemplo n.º 4
0
    def put(self, user_id):
        user_data = request.get_json()
        firstname = user_data.get("firstname")
        lastname = user_data.get("lastname")
        api.update_user(user_id, firstname, lastname)
        user_data = formatter.make(current_user, data_format.user_format)

        return user_data
Exemplo n.º 5
0
    def post(self):
        data = request.get_json()
        username = data.get("username")
        password = data.get("password")
        if api.authenticate(username, password):
            user_data = formatter.make(current_user, formatting.user_format)

            return user_data

        raise APIException(401, "Incorrect login")
Exemplo n.º 6
0
    def get(self, user_id, address_id, **kwargs):
        address = api.get_user_address(user_id, address_id)
        if address is None:
            raise APIException(404, 'Not found')

        address_transactions = api.get_user_address_transactions(
            user_id, address_id)
        address_transactions_data = list(
            map(
                lambda adtx: formatter.make(
                    adtx, formatting.address_transaction_format),
                address_transactions))

        return address_transactions_data
Exemplo n.º 7
0
    def get(self):
        if not current_user.is_authenticated:
            raise APIException(401, "Unauthorized")
        user_data = formatter.make(current_user, formatting.user_format)

        return user_data