Ejemplo n.º 1
0
def add_proof_to_customer_account(identifier, proof_type, proof_content):
    try:
        customer = customer_repository.retreive_customer_by_identifier(
            identifier)
        customer_repository.create_proof(customer, proof_type, proof_content)
    except Customer.DoesNotExist:
        raise CustomerException('Client introuvable')
    except Exception as e:
        logger.error(e)
        raise InternalException('Enregistrement document impossible')
    return {}
Ejemplo n.º 2
0
def update_pin(payload: dict):
    try:
        customer_update_pin_validator.load(payload)
    except ValidationError as e:
        raise PayloadException(str(e))

    identifier = payload.get('customer_identifier')
    password = payload.get('customer_identifier')
    try:
        customer = customer_repository.retreive_customer_by_identifier(
            identifier)
        customer_repository.set_customer_password(customer, password)
    except Customer.DoesNotExist:
        raise CustomerException('Client introuvable')

    except Exception:
        raise InternalException('Erreur Enregistrement adresse de livraison')
    return {}
Ejemplo n.º 3
0
def add_customer_delivery_address(payload: dict):
    _validate_customer_add_delivery_address_payload(payload)
    identifier = payload.get('customer_identifier')
    address = payload.get('address')
    city = payload.get('city')
    phone_number = payload.get('phone_number')

    try:
        customer = customer_repository.retreive_customer_by_identifier(
            identifier)
        customer_repository.add_delivery_address(customer, address, city,
                                                 phone_number)
    except Customer.DoesNotExist:
        raise CustomerException('Client introuvable')

    except Exception:
        raise InternalException('Erreur Enregistrement adresse de livraison')
    return {}
Ejemplo n.º 4
0
def add_product_to_customer_favoris(payload):
    try:
        customer_add_favoris_validator.validate(payload)
    except ValidationError as e:
        raise PayloadException(str(e))

    identifier = payload.get('customer_identifier')
    product_id = payload.get('product_id')

    try:
        customer = customer_repository.retreive_customer_by_identifier(
            identifier)
        product = get_product_by_id(product_id)
        customer_repository.add_product_to_customer_favoris(customer, product)
    except Customer.DoesNotExist:
        raise CustomerException('Client introuvable')
    except Product.DoesNotExist:
        raise ProductException('Produit introuvable')
    except Exception:
        raise InternalException('Erreur Enregistrement Favoris')
    return {}
Ejemplo n.º 5
0
def get_customer_by_identifier(identifier):
    try:
        return customer_repository.retreive_customer_by_identifier(identifier)
    except Customer.DoesNotExist:
        raise CustomerException('Client introuvable')