Пример #1
0
        public static CampaignIntroModel GetCampaignIntro(int employerId, int campaignId)
        {
            var campaignIntro = new CampaignIntroModel();

            var requestUrl = string.Format("v1/Animation/Campaign/Intro/{0}/{1}/{2}",
                                           employerId, campaignId, "AnzovinHandshakeId".GetConfigurationValue());

            var request = new HttpRequestMessage(HttpMethod.Get, requestUrl);

            try {
                using (var client = BaseService.GetClient()) {
                    var response = client.SendAsync(request).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        campaignIntro = response.Content.ReadAsAsync <CampaignIntroModel>().Result;
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null ?
                                           exc.Message :
                                           exc.InnerException.InnerException == null ?
                                           exc.InnerException.Message : exc.InnerException.InnerException.Message);
            }
            return(campaignIntro ?? new CampaignIntroModel());
        }
Пример #2
0
        public static AuthorizationResponse GetAuthorizationByCchId(int employerId, int cchId)
        {
            var authResponse = new AuthorizationResponse();

            var requestUrl = string.Format("v1/Animation/Membership/LoginById/{0}/{1}/{2}",
                                           employerId, cchId,
                                           "AnzovinHandshakeId".GetConfigurationValue());

            var request = new HttpRequestMessage(HttpMethod.Get, requestUrl);

            try {
                using (var client = BaseService.GetClient()) {
                    var response = client.SendAsync(request).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        authResponse = response.Content.ReadAsAsync <AuthorizationResponse>().Result;
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null
                        ? exc.Message
                        : exc.InnerException.InnerException == null
                            ? exc.InnerException.Message
                            : exc.InnerException.InnerException.Message);
            }
            return(authResponse);
        }
Пример #3
0
        public static async Task <MemberCardDataModel> GetCardDetail(int employerId, string token)
        {
            var memberData = new MemberCardDataModel();
            var requestUrl = string.Format("v1/Animation/Card/MemberData?employerId={0}&token={1}", employerId, token);
            var request    = new HttpRequestMessage(HttpMethod.Get, requestUrl);

            try {
                using (var client = BaseService.GetClient()) {
                    var response = await client.SendAsync(request);

                    if (response.IsSuccessStatusCode)
                    {
                        memberData = response.Content.ReadAsAsync <MemberCardDataModel>().Result;
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null ?
                                           exc.Message :
                                           exc.InnerException.InnerException == null ?
                                           exc.InnerException.Message : exc.InnerException.InnerException.Message);
            }
            return(memberData);
        }
Пример #4
0
        public static ExperienceLogResponse LogInitialEvent(int employerId)
        {
            var experienceResponse = new ExperienceLogResponse();
            var experienceLog      = new ExperienceLogRequest()
            {
                EmployerId = employerId,
                EventName  = "StartWebsite",
                LogComment = string.Format("Animations Website launched ")
            };

            var requestUrl = string.Format("v1/Animation/Experience/LogInitial/{0}",
                                           "AnzovinHandshakeId".GetConfigurationValue());

            try {
                using (var client = BaseService.GetClient()) {
                    var response = client.PostAsJsonAsync(requestUrl, experienceLog).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        experienceResponse = response.Content.ReadAsAsync <ExperienceLogResponse>().Result;
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null ?
                                           exc.Message :
                                           exc.InnerException.InnerException == null ?
                                           exc.InnerException.Message : exc.InnerException.InnerException.Message);
                experienceResponse.ExperienceUserId = Guid.NewGuid().ToString();
            }
            return(experienceResponse);
        }
Пример #5
0
        public static VideoCampaignModel GetVideoCampaign
            (int campaignId, int employerId)
        {
            var videoCampaign = new VideoCampaignModel();

            var requestUrl = string.Format("v1/PComm/VideoCampaign/{0}/{1}/{2}",
                                           "HandshakeId".GetConfigurationValue(),
                                           employerId, campaignId);

            var request = new HttpRequestMessage(HttpMethod.Get, requestUrl);

            // request.Content = null;
            try {
                using (var client = BaseService.GetClient()) {
                    var response = client.SendAsync(request).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        videoCampaign = response.Content.ReadAsAsync <VideoCampaignModel>().Result;
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null ?
                                           exc.Message :
                                           exc.InnerException.InnerException == null ?
                                           exc.InnerException.Message : exc.InnerException.InnerException.Message);
            }
            return(videoCampaign ?? new VideoCampaignModel());
        }
Пример #6
0
        public static AuthorizationResponse GetAuthorization(string lastName, string dateOfBirth, string lastFour)
        {
            var authResponse = new AuthorizationResponse();

            lastName = lastName.Replace(" ", "_");

            var request = new AuthMemberDataRequest {
                LastName    = lastName,
                DateOfBirth = dateOfBirth,
                LastFourSsn = lastFour
            };

            string requestUrl = string.Format("v1/Animation/Membership/Register1/{0}",
                                              "AnzovinHandshakeId".GetConfigurationValue());

            try {
                using (var client = BaseService.GetClient()) {
                    var response = client.PostAsJsonAsync(requestUrl, request).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        authResponse = response.Content.ReadAsAsync <AuthorizationResponse>().Result;
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null ?
                                           exc.Message :
                                           exc.InnerException.InnerException == null ?
                                           exc.InnerException.Message : exc.InnerException.InnerException.Message);
            }
            return(authResponse);
        }
Пример #7
0
        public static CampaignSessionModel GetCampaignSession(CampaignSessionModel campaignSession)
        {
            var userContent     = new UserContentRecord();
            var contentResponse = new UserContentResponse();
            /// Call new p_GetCampaignIntro
            /// and new p_GetCampaignContents

            var requestUrl = string.Format("v1/Animation/UserContent/UserContent/1/{0}",
                                           campaignSession.CampaignContentId);

            var request = new HttpRequestMessage(HttpMethod.Get, requestUrl);

            try {
                using (var client = BaseService.GetClient()) {
                    if (client.DefaultRequestHeaders.Contains("AuthHash"))
                    {
                        client.DefaultRequestHeaders.Remove("AuthHash");
                    }

                    client.DefaultRequestHeaders.Add("AuthHash", campaignSession.AuthorizationHash);

                    var response = client.SendAsync(request).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        contentResponse = response.Content.ReadAsAsync <UserContentResponse>().Result;
                        userContent     = contentResponse.Results.FirstOrDefault();

                        if (userContent != null)
                        {
                            campaignSession.AnimationTopic     = userContent.ContentName;
                            campaignSession.JavaScriptFileName = userContent.ContentFileLocation;
                            campaignSession.BannerImageName    = userContent.ContentImageFileName;
                            campaignSession.MemberContentData  = userContent.MemberContentData;
                        }
                    }
                }
            }
            catch (Exception exc) {
                HelperService.LogAnonEvent(ExperienceEvents.Error,
                                           exc.InnerException == null ?
                                           exc.Message :
                                           exc.InnerException.InnerException == null ?
                                           exc.InnerException.Message : exc.InnerException.InnerException.Message);
            }
            return(campaignSession ?? new CampaignSessionModel());
        }