예제 #1
0
        public HttpResponseMessage GetUserNotifications(HttpRequestMessage pRequest)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            if (token != null)
            {
                PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        var notifications = campaignBL.GetUserNotifications(personVerified);
                        if (notifications != null)
                        {
                            NotificationsInteractor interactor = new NotificationsInteractor();
                            var notifResponse = interactor.CreateNotificationsResponse(notifications);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, notifResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Expired token or not valid credentials.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
        public HttpResponseMessage Validate(HttpRequestMessage request, [FromBody] BuildValidationReqBody pBuildValidation)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token);

            if (token == null)
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
            else
            {
                if (!String.IsNullOrEmpty(pBuildValidation.appVersionName) && !String.IsNullOrEmpty(pBuildValidation.platformName))
                {
                    PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

                    if (personVerified != null)
                    {
                        if (!personVerified.IsValidToken)
                        {
                            response.HttpCode = 401;
                            response.Message  = "Authentication token has expired.";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                        }
                        else
                        {
                            var build = buildBL.BuildVersion(pBuildValidation.appVersionName, pBuildValidation.platformName);
                            BuildValidatorInteractor interactor    = new BuildValidatorInteractor();
                            BuildResponse            buildResponse = interactor.CreateBuildResponse(build);
                            if (buildResponse.Valid)
                            {
                                return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, buildResponse));
                            }
                            else
                            {
                                return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, buildResponse));
                            }
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Token authorization expired or not valid";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 400;
                    response.Message  = "Client build version and platform name are required";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
            }
        }
        public HttpResponseMessage InsertBankDeposit(HttpRequestMessage pRequest, [FromBody] BankDepositoReqBody pDepositData)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        PurchaseEN purchase = new PurchaseEN();
                        purchase.Amount = pDepositData.monto;
                        purchase.BankID = Convert.ToInt32(pDepositData.banco);

                        var result = purchaseBL.InsertPurchase(purchase, personVerified, pDepositData.nombre, pDepositData.comprobante, pDepositData.fecha);

                        if (result)
                        {
                            string newToken        = personBL.RenewAuthToken(personVerified);
                            var    depositResponse = interactor.CreatorDepositResponse(result, newToken);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, depositResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
        public HttpResponseMessage GetActivePromotion(HttpRequestMessage pRequest)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token);

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        var promotion = promoBL.GetActivePromotion(personVerified.CountryID);

                        if (promotion != null)
                        {
                            PromotionInteractor interactor = new PromotionInteractor();

                            var promoResponse = interactor.CreatePromosResponse(promotion);

                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, promoResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization oken must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
예제 #5
0
        public HttpResponseMessage Get(HttpRequestMessage pRequest)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        var userBags = bagBL.GetUserBags(personVerified.PersonID);

                        if (userBags != null)
                        {
                            string newToken     = personBL.RenewAuthToken(personVerified);
                            var    bagsResponse = interactor.CreateBagResponse(userBags, newToken, personVerified.PersonID);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, bagsResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
예제 #6
0
        public HttpResponseMessage Get(HttpRequestMessage pRequest, string data)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        List <ProductEN> products = productsBL.GetProductsByCountryID(personVerified);

                        if (products != null)
                        {
                            ProductsResponse productsResponse = interactor.CreateProductsResponse(products);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, productsResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
예제 #7
0
        public HttpResponseMessage GetBanks(HttpRequestMessage request)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token);

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        List <BankEN> theBanksList = bankBL.GetBankList(personVerified.CountryID);

                        if (theBanksList != null)
                        {
                            BankResponse bankResponse = interactor.CreateBankResponse(theBanksList);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, bankResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
예제 #8
0
        public HttpResponseMessage GetSalesHistory(HttpRequestMessage request, string when)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (personVerified != null)
            {
                if (!String.IsNullOrEmpty(when))
                {
                    if (personVerified.IsValidToken)
                    {
                        List <SaleEN> salesList = saleBL.GetIntervalPersonSaleHistory(personVerified, when);

                        if (salesList != null)
                        {
                            var historyResult = interactor.createHistoryResultsResponse(salesList, personBL.RenewAuthToken(personVerified));
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, historyResult));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 400;
                    response.Message  = "Time interval parameter must be not null.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
            }
            else
            {
                response.HttpCode = 401;
                response.Message  = "Token authorization has expired or is not valid";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
            }
        }
예제 #9
0
        public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] BalanceRequest requestBody)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (!string.IsNullOrEmpty(requestBody.VendorEmail))
            {
                if (personVerified.IsValidToken)
                {
                    var inf = balanceRequestBL.RequestBalance(requestBody.VendorEmail);

                    if (inf != null)
                    {
                        var responseSucces = interactor.createSuccessResponse(inf);

                        return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSucces));
                    }
                    else
                    {
                        response.HttpCode = 404;
                        response.Message  = "Seller not found";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Authentication token has expired.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Email parameter must not be null.";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
예제 #10
0
        public HttpResponseMessage Topup(HttpRequestMessage request, [FromBody] TopupRequest pOperatorData, string data, decimal amount, int code)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token);

            if (token == null)
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
            else
            {
                if (!String.IsNullOrEmpty(pOperatorData.Operador) && pOperatorData.IdCountry <= 0)
                {
                    response.HttpCode = 400;
                    response.Message  = "Operator name and ID must be provided";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
                else if (String.IsNullOrEmpty(data))
                {
                    response.HttpCode = 400;
                    response.Message  = "Malformed URL: Phone number must be provided";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
                else if (amount == 0)
                {
                    response.HttpCode = 400;
                    response.Message  = "Malformed URL: Amount must be provided";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
                else
                {
                    PersonEN person = personBL.VerifyPersonAuthentication(token);

                    if (person != null)
                    {
                        TopupInteractor    interactor = new TopupInteractor();
                        TopupTransactionEN result     = topupBL.SendTopup(person, pOperatorData.Operador, amount, data, code);
                        var bags = topupBL.GetUserBags(person.PersonID);

                        var responseTopup = interactor.CreateTopupResponse(result, bags);


                        if (String.Equals(result.Message, Values.Ok))
                        {
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseTopup));
                        }
                        else if (String.Equals(result.Message, Values.Success))
                        {
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseTopup));
                        }
                        else if (String.Equals(result.Message, Values.NoCreditLeft))
                        {
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.ServiceUnavailable, responseTopup));
                        }
                        else if (String.Equals(result.Message, Values.InvalidProduct))
                        {
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, responseTopup));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 500;
                        response.Message  = "Something went wrong";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                    }
                }
            }
        }
        public HttpResponseMessage AddPersonGamerProfile(HttpRequestMessage pRequest, [FromBody] GamerProfileReq pGamerProfile)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        if (!String.IsNullOrEmpty(pGamerProfile.Nickname))
                        {
                            SimpleTextResponse  nicknameResponse = new SimpleTextResponse();
                            HttpResponseMessage responseMessage;

                            switch (personBL.AddPersonNickname(personVerified, pGamerProfile.Nickname).Message)
                            {
                            case "error":
                                nicknameResponse.Message = "Something went wrong";
                                nicknameResponse.result  = false;
                                responseMessage          = Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, nicknameResponse);
                                break;

                            case "inserted":
                                nicknameResponse.Message = "Operation completed succesfully";
                                nicknameResponse.result  = true;
                                responseMessage          = Request.CreateResponse <IResponse>(HttpStatusCode.OK, nicknameResponse);
                                break;

                            case "conflict":
                                nicknameResponse.Message = "Nickname already exist";
                                nicknameResponse.result  = false;
                                responseMessage          = Request.CreateResponse <IResponse>(HttpStatusCode.NotAcceptable, nicknameResponse);
                                break;

                            default:
                                nicknameResponse.Message = "Something went wrong";
                                nicknameResponse.result  = false;
                                responseMessage          = Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, nicknameResponse);
                                break;
                            }

                            return(responseMessage);
                        }
                        else
                        {
                            response.HttpCode = 400;
                            response.Message  = "Nickname is required.";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
        public HttpResponseMessage AssociateFacebook(HttpRequestMessage pRequest, [FromBody] UserFacebookReqBody pFacebookData)
        {
            IEnumerable <string> token = null;

            pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        var validateRequest = interactor.ValidateRequest(pFacebookData);

                        if (validateRequest.result)
                        {
                            SimpleTextResponse  simpleResponse = new SimpleTextResponse();
                            HttpResponseMessage httpResponse   = new HttpResponseMessage();

                            FacebookEN facebookData = new FacebookEN();
                            facebookData.Email             = pFacebookData.email;
                            facebookData.FacebookProfileID = pFacebookData.profileID;
                            facebookData.FacebookUserID    = pFacebookData.userID;
                            facebookData.Firstname         = pFacebookData.firstname;
                            facebookData.Lastname          = pFacebookData.lastname;
                            facebookData.MiddleName        = pFacebookData.middlename;
                            facebookData.PersonID          = personVerified.PersonID;
                            facebookData.Phone             = pFacebookData.phoneNumber;
                            facebookData.URL = pFacebookData.facebookURL;

                            switch (facebookBL.AssociateFacebook(facebookData))
                            {
                            case "updated":
                                simpleResponse.result  = true;
                                simpleResponse.Message = "Facebook Profile has been Updated";
                                httpResponse           = pRequest.CreateResponse <IResponse>(HttpStatusCode.OK, simpleResponse);
                                break;

                            case "inserted":
                                simpleResponse.result  = true;
                                simpleResponse.Message = "Operation completed succesfully";
                                httpResponse           = pRequest.CreateResponse <IResponse>(HttpStatusCode.OK, simpleResponse);
                                break;

                            case "error":
                                simpleResponse.result  = false;
                                simpleResponse.Message = "Something went wrong";
                                httpResponse           = pRequest.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, simpleResponse);
                                break;

                            default:
                                simpleResponse.result  = false;
                                simpleResponse.Message = "Something went wrong";
                                httpResponse           = pRequest.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, simpleResponse);
                                break;
                            }

                            return(httpResponse);
                        }
                        else
                        {
                            response.HttpCode = 400;
                            response.Message  = "Authentication token has expired.";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, validateRequest));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }