public async Task UpdateAmountAsync(Guid OverdraftDetailID, decimal Amount, List <ConceptRelationUpdateAmountDTO> ConceptRelationsAmountApplied,
                                            Guid instanceID, Guid identityWorkID)
        {
            var parameters = new UpdateAmountConceptDetailParams()
            {
                Amount                        = Amount,
                OverdraftDetailID             = OverdraftDetailID,
                ConceptRelationsAmountApplied = ConceptRelationsAmountApplied,
                InstanceID                    = instanceID,
                IdentityWorkID                = identityWorkID
            };

            var result = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                            new Uri($"{_cotorraUri}/CalculateFormula"), new object[] { parameters }).ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                return(i.Result);
            });


            return;
        }
        /// <summary>
        /// Get IdentityUser by Email
        /// </summary>
        /// <param name="authorizationHeader"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public async Task <Guid?> GetIdentityUserAsync(string authorizationHeader, string email)
        {
            if (!String.IsNullOrEmpty(email))
            {
                var result = await ServiceHelperExtensions.CallRestServiceAsync(
                    Format.JSON,
                    RestMethod.GET,
                    authorizationHeader,
                    new Uri($"{_userHost}api/Users/{email}"),
                    new object[] { }).ContinueWith((i) =>
                {
                    if (i.Exception != null)
                    {
                        throw i.Exception;
                    }
                    return(i.Result);
                });

                if (!String.IsNullOrEmpty(result))
                {
                    var identityPlatform = JsonConvert.DeserializeObject <IdentityPlatform>(result);
                    return(identityPlatform.ID);
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
        public async Task <NOMSurveyReplyResult> CreateAsync(NOMSurveyReplyParams nOMSurveyReplyParams)
        {
            string serializedResult = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                                         new Uri($"{_cotorraUri}"), new object[] { nOMSurveyReplyParams });

            if (!String.IsNullOrEmpty(serializedResult))
            {
                return(JsonConvert.DeserializeObject <NOMSurveyReplyResult>(serializedResult));
            }
            return(default);
예제 #4
0
        public async Task <List <LicenseInfoP> > GetLicensesUserAsync(string userToken)
        {
            List <LicenseInfoP> licenses = new List <LicenseInfoP>();
            var strResult = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, userToken,
                                                                               new Uri(UriUserServices + "api/UserLicenses"));

            var result = JsonSerializer.DeserializeObject <List <LicensesInfoDTO> >(strResult);
            var dest   = mapperForLicense.Map <List <LicensesInfoDTO>, List <LicenseInfoP> >(result);

            return(dest);
        }
예제 #5
0
        public async Task <List <Overdraft> > Calculate(CalculateSettlementProcessParams parameters)
        {
            var result = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                            new Uri($"{_cotorraUri}/Calculate"), new object[] { parameters }).ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }
                return(i.Result);
            });

            return(JsonConvert.DeserializeObject <List <Overdraft> >(result));
        }
예제 #6
0
        public async Task <string> GenerateSettlementLetter(GenerateSettlementLetterParams parameters)
        {
            var result = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                            new Uri($"{_cotorraUri}/GenerateSettlementLetter"), new object[] { parameters }).ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }
                return(i.Result);
            });

            return(JsonConvert.DeserializeObject <string>(result));
        }
예제 #7
0
 public async Task DispatchAsync(Guid actionID, Guid registerID)
 {
     DispatchAsyncParams parameters = new DispatchAsyncParams()
     {
         ActionID = actionID, RegisterID = registerID
     };
     var result = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, _authorizationHeader,
                                                                     new Uri($"{_cotorraUri}/GetIntent"), new object[] { parameters }).ContinueWith((i) =>
     {
         if (i.Exception != null)
         {
             throw i.Exception;
         }
         return(i.Result);
     });
 }
예제 #8
0
        public static async Task <string> LoginAsync(string username, string password, string loginURI)
        {
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            var userCredentials = new UserCredential()
            {
                Name = username, Password = password
            };
            var loginUserParams = new LoginUserParams();

            loginUserParams.UserCredential = userCredentials;
            var resultdeserealizedJson = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, "", new Uri(loginURI), loginUserParams);

            var resultdeserealized = JsonSerializer.DeserializeObject <LoginResult>(resultdeserealizedJson);

            return(resultdeserealized.AccessToken.AuthorizationHeader);
        }
예제 #9
0
        public async Task <SignDocumentResult <ICFDINomProvider> > StampDocumetAsync(
            SignDocumentResult <ICFDINomProvider> signDocumentResult, FiscalStampingVersion fiscalStampingVersion, string xml)
        {
            var stampingResult = String.Empty;

            var stampingRequest_CFDI33Nom12 = new StampingRequest_CFDI33Nom12();

            stampingRequest_CFDI33Nom12.Version         = VERSION;
            stampingRequest_CFDI33Nom12.PACDocumentType = PAC_DOCUMENT_TYPE;
            stampingRequest_CFDI33Nom12.Body            = new CFDIRequest_CFDI33Nom12()
            {
                XmlString = xml
            };
            stampingRequest_CFDI33Nom12.AdditionalInformation.Add(new AdditionalInformation_CFDI33Nom12(PAC_ATTRIBUTE_TITLE_RFC, signDocumentResult.EmployerRFC));
            stampingRequest_CFDI33Nom12.AdditionalInformation.Add(new AdditionalInformation_CFDI33Nom12(PAC_ATTRIBUTE_TITLE_PRODUCT, PAC_ATTRIBUTE_VALUE_PRODUCT));
            stampingRequest_CFDI33Nom12.AdditionalInformation.Add(new AdditionalInformation_CFDI33Nom12(PAC_ATTRIBUTE_TITLE_PRODUCT_VERSION, PAC_ATTRIBUTE_VALUE_PRODUCT_VERSION));
            stampingRequest_CFDI33Nom12.AdditionalInformation.Add(new AdditionalInformation_CFDI33Nom12(PAC_ATTRIBUTE_TITLE_PRODUCT_TYPE, PAC_ATTRIBUTE_VALUE_PRODUCT_TYPE));
            stampingRequest_CFDI33Nom12.Token = "";

            //call service async
            await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, null,
                                                               new Uri($"{StampingUri}"), new object[] { stampingRequest_CFDI33Nom12 })
            .ContinueWith((i) =>
            {
                if (i.Result.Contains("FAIL") || i.Result.Contains("An error has occurred"))
                {
                    throw new CotorraException(90001, "90001", i.Result, null);
                }

                stampingResult = i.Result;
            });

            var stampingResult_CFDI33Nom12 = JsonSerializer.DeserializeObject <StampingResult_CFDI33Nom12>(stampingResult);

            //TFD
            var responseList = stampingResult_CFDI33Nom12.ResponseList_CFDI33Nom12.FirstOrDefault();
            var tfd          = SerializerXml.DeserializeObject <TimbreFiscalDigital>(responseList.ResponseValue);

            var complementos = (signDocumentResult.CFDI as Comprobante).Complemento.ToList();

            //complementos.Add(new ComprobanteComplemento() { Any = new XmlElement[1] { GetElement(CreateXmlNom(tfd)) } });
            (signDocumentResult.CFDI as Comprobante).Complemento = complementos.ToArray();

            signDocumentResult.UUID = Guid.Parse(tfd.UUID);

            return(signDocumentResult);
        }
예제 #10
0
        public async Task <List <LicenseInfoP> > GetLicensesUserByAppAsync(string userToken, Guid appID)
        {
            List <LicenseInfoP> licenses = new List <LicenseInfoP>();
            var strResult = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, userToken,
                                                                               new Uri(UriUserServices + "api/UserLicenses"));

            var result = JsonSerializer.DeserializeObject <List <LicensesInfoDTO> >(strResult);

            result.ForEach(license =>
            {
                license.Apps = license.Apps.Where(x => x.AppID == appID).ToList();
            });

            var dest = mapperForLicense.Map <List <LicensesInfoDTO>, List <LicenseInfoP> >(result);

            return(dest);
        }
예제 #11
0
        public void DisperseAsync(List <ActionSubscription> actionSubscriptions, object data)
        {
            actionSubscriptions.ForEach(actionSubscription =>
            {
                ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, "",
                                                             new Uri(actionSubscription.PostBack), new object[] { data });
                //new Uri(actionSubscription.PostBack), new object[] { data }).ContinueWith((i) =>
                //{
                //    if (i.Exception != null)
                //    {
                //        throw i.Exception;
                //    }

                //    return i.Result;
                //});
            });
        }
예제 #12
0
        public async Task <List <Overdraft> > AuthorizationAsync(AuthorizationParams authorizationParams)
        {
            //call service async
            var result = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                            new Uri($"{_cotorraUri}/Authorize"), new object[] { authorizationParams }).ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                return(i.Result);
            });

            var overdraft = JsonConvert.DeserializeObject <List <Overdraft> >(result);

            return(overdraft);
        }
        public async Task <string> GetIntent(GetIntentParams parameters)
        {
            string result = null;

            //call service async
            await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, _authorizationHeader,
                                                               new Uri($"{_cotorraUri}/GetIntent/{parameters.IdentityWorkID}/{parameters.InstanceID}/{parameters.Utterance}"),
                                                               new object[] { })
            .ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                result = i.Result;
            });

            return(result);
        }
        public async Task <InitializationResult> InitializeAsync(string authTkn, Guid licenseServiceID, string socialReason,
                                                                 string RFC, PayrollCompanyConfiguration payrollCompanyConfiguration, EmployerRegistration employerRegistration)
        {
            var createParmas = new InitializationParams()
            {
                AuthTkn          = authTkn,
                LicenseServiceID = licenseServiceID,
                SocialReason     = socialReason,
                RFC = RFC,
                PayrollCompanyConfiguration = payrollCompanyConfiguration,
                EmployerRegistration        = employerRegistration
            };

            string serializedResult = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                                                         new Uri($"{_cotorraUri}"), new object[] { createParmas });

            if (!String.IsNullOrEmpty(serializedResult))
            {
                return(JsonConvert.DeserializeObject <InitializationResult>(serializedResult));
            }
            return(default);
예제 #15
0
        public async Task <GetPreviewCancelationAckURLResult> GetPreviewCancelationAckURLAsync(Guid cancelationResponseXMLID, Guid instanceID)
        {
            //call service async
            string result = null;

            //call service async
            await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, _authorizationHeader,
                                                               new Uri($"{_cotorraUri}/GetPreviewCancelationAckURLAsync/{cancelationResponseXMLID}/{instanceID}"),
                                                               new object[] { })
            .ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                result = i.Result;
            });

            return(JsonConvert.DeserializeObject <GetPreviewCancelationAckURLResult>(result));
        }
예제 #16
0
        public async Task <GetPreviewUrlResult> GetPreviewUrlByUUIDAsync(Guid instanceId, Guid UUID)
        {
            var serializer = new ExpressionSerializer(new Serialize.Linq.Serializers.JsonSerializer());

            //call service async
            string result = null;

            //call service async
            await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, _authorizationHeader,
                                                               new Uri($"{_cotorraUri}/GetPreviewUrlByUUIDAsync/{instanceId}/{UUID}"),
                                                               new object[] { })
            .ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                result = i.Result;
            });

            return(JsonConvert.DeserializeObject <GetPreviewUrlResult>(result));
        }
예제 #17
0
        public async Task <GetPreviewResult> GetPreviewByOverdraft(GetPreviewParams getPreviewParams)
        {
            var serializer = new ExpressionSerializer(new Serialize.Linq.Serializers.JsonSerializer());

            //call service async
            string result = null;

            //call service async
            await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.GET, _authorizationHeader,
                                                               new Uri($"{_cotorraUri}/GetPreviewByOverdraft/{getPreviewParams.IdentityWorkID}/{getPreviewParams.InstanceID}/{getPreviewParams.OverdraftID}"),
                                                               new object[] { })
            .ContinueWith((i) =>
            {
                if (i.Exception != null)
                {
                    throw i.Exception;
                }

                result = i.Result;
            });

            return(JsonConvert.DeserializeObject <GetPreviewResult>(result));
        }