Ejemplo n.º 1
0
        public static async Task <bool> SetAnottation <T>(List <string> listURIs, string userId)
        {
            try
            {
                string uri      = "LoadEmotionProfile";
                var    _request = new Model.Request <List <string> >()
                {
                    Obj              = listURIs,
                    userId           = userId,
                    usuarioinstagram = "MetricasInsights"
                };

                var myContent = JsonConvert.SerializeObject(_request);

                using (var clientPost = new HttpClient())
                {
                    clientPost.DefaultRequestHeaders.Accept.Clear();
                    clientPost.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var content = new StringContent(myContent, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await clientPost.PostAsync(_urlBaseApi + uri, content);

                    response.EnsureSuccessStatusCode();

                    return(response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK);
                }
            }
            catch (Exception ex)
            {
                WriteErrorLog("SetAnottation " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static async Task <bool> SetDataGraphAsync <T>(string accessToken, string uri, string userId, string usuarioinstagram, T story)
        {
            try
            {
                var _storyRequest = new Model.Request <T>()
                {
                    Obj              = story,
                    userId           = userId,
                    usuarioinstagram = usuarioinstagram
                };

                var myContent = JsonConvert.SerializeObject(_storyRequest);

                using (var clientPost = new HttpClient())
                {
                    clientPost.DefaultRequestHeaders.Accept.Clear();
                    clientPost.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var content = new StringContent(myContent, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await clientPost.PostAsync(_urlBaseApi + uri, content);

                    response.EnsureSuccessStatusCode();

                    return(response.StatusCode == System.Net.HttpStatusCode.Created);
                }
            }
            catch (Exception ex)
            {
                WriteErrorLog("SetDataGraphAsync " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static async Task <bool> SetUserBloqueioAsync(string accessToken, string uri,
                                                             string userId, string description, bool retry, string status)
        {
            try
            {
                var bloqueio = new Model.UserBloqueios
                {
                    AccessToken = accessToken,
                    Description = description,
                    Retry       = retry,
                    Status      = status
                };

                var _request = new Model.Request <Model.UserBloqueios>()
                {
                    Obj              = bloqueio,
                    userId           = userId,
                    usuarioinstagram = ""
                };

                var myContent = JsonConvert.SerializeObject(_request);

                using (var clientPost = new HttpClient())
                {
                    clientPost.DefaultRequestHeaders.Accept.Clear();
                    clientPost.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var content = new StringContent(myContent, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await clientPost.PostAsync(_urlBaseApi + uri,
                                                                              content);

                    response.EnsureSuccessStatusCode();

                    return(response.StatusCode == System.Net.HttpStatusCode.Created);
                }
            }
            catch (Exception ex)
            {
                WriteErrorLog("SetUserBloqueioAsync " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static async Task <T> GetListarMediasWithEmotionalByAgenciaAsync <T>(string userId)

        {
            try
            {
                string uri      = "ListarMediasWithEmotionalByAgenciaAsync";
                var    _request = new Model.Request <string>()
                {
                    Obj              = "",
                    userId           = userId,
                    usuarioinstagram = "MetricasInsights"
                };

                var myContent = JsonConvert.SerializeObject(_request);

                using (var clientPost = new HttpClient())
                {
                    clientPost.DefaultRequestHeaders.Accept.Clear();
                    clientPost.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var content = new StringContent(myContent, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await clientPost.PostAsync(_urlBaseApi + uri, content);

                    if (!response.IsSuccessStatusCode)
                    {
                        return(default(T));
                    }

                    var result = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <T>(result));
                }
            }
            catch (Exception ex)
            {
                WriteErrorLog("GetListarMediasWithEmotionalByAgenciaAsync: " + ex.Message);
                return(default(T));
            }
        }