Beispiel #1
0
    def create_location(self, request):
        location = CreateLocation.call(data=request.data)

        if location.failed:
            return Response(errors=dict(errors=location.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(location.value, status=status.HTTP_201_CREATED)
Beispiel #2
0
    def update_profile(self, request):
        request_email = request.user
        artist = UpdateArtist.call(data=request.data, user_email=request_email)

        if artist.failed:
            return Response(errors=dict(errors=artist.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=artist.value, status=status.HTTP_200_OK)
    def upload(self, request, format=None):

        user_email = request.user
        uploads = upload_song_action.UploadSong.call(data=request.data,
                                                     user_email=user_email)
        if uploads.failed:
            return Response(errors=dict(errors=uploads.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=uploads.value, status=status.HTTP_200_OK)
Beispiel #4
0
    def send_sms(self, request, otp=None):
        data = request.data

        send_otp = PhoneOtpAction.call(otp=otp, data=data)

        if send_otp.failed:
            return Response(errors=dict(errors=send_otp.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=send_otp.value, status=status.HTTP_200_OK)
Beispiel #5
0
    def get_all_artists(self, request):
        """
            This method gets all the details of all artists
        """
        result = AllArtists.call()
        if result.failed:
            return Response(errors=dict(errors=result.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=result.value, status=status.HTTP_200_OK)
Beispiel #6
0
    def get_artist_via_id(self, request, artist_id):
        """
            This method gets all the details of a specific artist using their ID.
        """
        result = ArtistDetail.call(artist_id=artist_id)

        if result.failed:
            return Response(errors=dict(errors=result.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=result.value, status=status.HTTP_200_OK)
Beispiel #7
0
    def verify(self, request):
        email = strip_and_lower(request.data.get('email', ''))
        otp_code = request.data.get('otp_code', '')

        verify_email = VerifyEmailVerify.call(email=email, otp=otp_code)

        if verify_email.failed:
            return Response(errors=dict(errors=verify_email.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=verify_email.value)
Beispiel #8
0
    def send(self, request, otp=None):
        email = strip_and_lower(request.data.get('email', ''))

        otp = SendOTP.call(email=email, otp=otp)

        if otp.value:
            return Response(data={"otp": otp.value},
                            status=status.HTTP_201_CREATED)
        else:
            return Response(errors=dict(errors={"error": otp.error.value}),
                            status=status.HTTP_400_BAD_REQUEST)
Beispiel #9
0
    def get_artist_account(self, request):
        user = request.user

        result = ArtistAccount.call(user=user)

        if result.failed:
            return Response(
                errors=dict(errors=result.error.value),
                status=status.HTTP_400_BAD_REQUEST
            )
        return Response(data=result.value, status=status.HTTP_200_OK)
Beispiel #10
0
    def get_artist_analytics_via_id(self, request, artist_id):
        """
            This method gets the data analytics of a specific artist using their ID.
        """
        info = ArtistSongPerMonth.call(artist_id=artist_id)

        if info.failed:
            return Response(errors=dict(errors=info.error.value),
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(data=info.value, status=status.HTTP_200_OK)
Beispiel #11
0
    def get_artist(self, request):
        """
        This method gets all the details of a specific artist using their login token.
        """
        user = request.user
        result = ArtistProfile.call(user=user)

        if result.failed:
            return Response(errors=dict(errors=result.error.value),
                            status=status.HTTP_400_BAD_REQUEST)
        return Response(data=result.value, status=status.HTTP_200_OK)
Beispiel #12
0
    def register_admin(self, request):
        admin = RegisterAdmin.call(data=request.data)

        if admin.failed:
            return Response(
                errors=dict(error=admin.error.value),
                status=status.HTTP_400_BAD_REQUEST,
            )

        return Response(
            data=admin.value,
            status=status.HTTP_201_CREATED
        )
Beispiel #13
0
    def register(self, request):
        artist = Register.call(data=request.data)
        
        if artist.failed:
            return Response(
                errors=dict(errors=artist.error.value),
                status=status.HTTP_400_BAD_REQUEST
            )

        return Response(
            data=artist.value, 
            status=status.HTTP_201_CREATED
        )
Beispiel #14
0
    def logout(self, request):
        logout_user = LogoutAction.call(request=request)

        if logout_user.failed:
            return Response(
                errors=dict(error=logout_user.error.value),
                status=status.HTTP_400_BAD_REQUEST,
            )

        return Response(
            data=logout_user.value,
            status=status.HTTP_200_OK
        )
Beispiel #15
0
 def login(self, request):
     '''Generates a token based on the email and password passed in as parameters.
     e.g: {'email': 'enter_email_here', 'password': '******'}'''
     login_details = Login.call(data=request.data)
     if login_details.failed:
         return Response(
             errors=dict(errors=login_details.error.value),
             status=status.HTTP_400_BAD_REQUEST
         )
     return Response(
         data=login_details.value,
         status=status.HTTP_200_OK
     )
Beispiel #16
0
    def change(self, request):
        """ 
        This method updates the user's password and returns an appropriate response.
        """
        user = request.user
        data = request.data
        result = password_update_action.UpdatePassword.call(user=user, data=data)

        if result.failed:
            return Response(
                errors=dict(errors=result.error.value),
                status=status.HTTP_400_BAD_REQUEST
            )
        return Response(data=result.value, status=status.HTTP_201_CREATED)
Beispiel #17
0
    def create_account(self, request):

        account_details = AccountVerification.call(data=request.data)
        if account_details.failed:
            return Response(errors=dict(errors=account_details.error.value), status=status.HTTP_400_BAD_REQUEST)

        res = account_details.value
        user_data = res.get('data')
        account_number, account_name = user_data.get('account_number'), user_data.get('account_name')
        bank_name, bank_code = request.data.get('bank_name'), request.data.get('bank_code')
        user_id = request.user.id
        save_data = CreateAccount.call(account_name=account_name, account_number=account_number,
                                       bank_name=bank_name, bank_code=bank_code, user_id=user_id)

        if save_data.failed:
            return Response(errors=dict(errors=save_data.error.value), status=status.HTTP_400_BAD_REQUEST)
        return Response(data=save_data.value, status=status.HTTP_201_CREATED)
Beispiel #18
0
    def reset(self, request):
        """This reset password view collects the data from the user and calls the ResetPassword Action
        to perform the necessary validations on the data."""
        data = request.data

        result = ResetPassword.call(data=data)

        # If the action fails, it should return the error with its status
        if result.failed:
            return Response(
                errors=dict(errors=result.error.value),
                status=status.HTTP_400_BAD_REQUEST
            )

        # else it should return the data with its status
        return Response(
            data=result.value,
            status=status.HTTP_201_CREATED
        )
Beispiel #19
0
    def update_account(self, request):
        request_email = request.user
        account_details = AccountVerification.call(data=request.data)

        if account_details.failed:
            return Response(errors=dict(errors=account_details.error.value), status=status.HTTP_400_BAD_REQUEST)

        res = account_details.value
        account_data = res.get('data')

        bank_data = dict(
            account_number=account_data.get('account_number'),
            account_name=account_data.get('account_name'),
            bank_name=request.data.get('bank_name'),
            bank_code=request.data.get('bank_code')
        )

        account = UpdateAccount.call(user_email=request_email, bank_data=bank_data)

        if account.failed:
            return Response(errors=dict(errors=account.error.value), status=status.HTTP_400_BAD_REQUEST)

        return Response(data=account.value, status=status.HTTP_200_OK)
Beispiel #20
0
 def get_location(self, request):
     result = GetLocation.call()
     return Response(result.value, status=status.HTTP_200_OK)
Beispiel #21
0
 def get_accounts(self, request):
     result = GetAccount.call()
     return Response(result.value, status=status.HTTP_200_OK)
Beispiel #22
0
 def get_bank_list(self, request):
     banks = BankList.call()
     return Response({'banks': banks.value}, status=status.HTTP_200_OK)