Example #1
0
        public ListOrder RetornarOrdens(Usuario u, Int32 ofset)
        {
            ListOrder o;
            Parameter at = new Parameter();
            Parameter seller = new Parameter();
            Parameter offset = new Parameter();
            List<Parameter> param = new List<Parameter>();

            //Alimentando parametros
            at.Name = "access_token";
            at.Value = m.AccessToken;

            seller.Name = "seller";
            seller.Value = u.id;

            offset.Name = "offset";
            offset.Value = ofset;

            //Adicionando na lista
            param.Add(seller);
            param.Add(at);
            param.Add(offset);

            RestResponse resp = (RestResponse)m.Get("/orders/search", param);
            //offset
            if (resp.StatusCode == System.Net.HttpStatusCode.OK)
            {

                var a = new JsonSerializerSettings();
                o = JsonConvert.DeserializeObject<ListOrder>(resp.Content);

                return o;
            }
            else
            {
                throw new Exception("Falha ao tentar recuperar a lista de ordens");
            }
        }
        public Usuario RetornaUsuario()
        {
            try
            {

                Usuario u = new Usuario();
                Parameter at = new Parameter();
                List<Parameter> param = new List<Parameter>();

                //Alimentando parametros
                at.Name = "access_token";
                at.Value = m.AccessToken;

                //Adicionando na lista
                param.Add(at);

                RestResponse resp = (RestResponse)m.Get("/users/me", param);

                if (resp.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var a = new JsonSerializerSettings();
                    u = JsonConvert.DeserializeObject<Usuario>(resp.Content);

                    FinalizaML(m.AccessToken, m.RefreshToken);
                    return u;
                }
                else
                {
                    throw new Exception(String.Format("Usuario não encontrado. {0} codigo: {1} {0}", Environment.NewLine));
                }

            }
            catch (Exception ex)
            {

                throw new Exception(String.Format("Erro na rotina RetornaUsuario. {0} codigo: {1} {0}", Environment.NewLine), ex);
            }
        }
Example #3
0
        public Usuario RetornaUsuarioLogado()
        {
            Usuario u = new Usuario();
            Parameter at = new Parameter();
            List<Parameter> param = new List<Parameter>();

            //Alimentando parametros
            at.Name = "access_token";
            at.Value = m.AccessToken;

            //Adicionando na lista
            param.Add(at);

            RestResponse resp = (RestResponse)m.Get("/users/me", param);

            if (resp.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var a = new JsonSerializerSettings();
                u = JsonConvert.DeserializeObject<Usuario>(resp.Content);
            }

            return u;
        }
        public ML_Usuario ConverteUsuario(Usuario us)
        {
            //DADOS DA BASE DA CLASSE
            ML_Usuario u = new ML_Usuario();

            try
            {

                u.country_id = us.country_id;
                u.email = us.email;
                u.first_name = us.first_name;
                u.id = us.id;
                u.last_name = us.last_name;
                u.logo = us.logo;
                u.nickname = us.nickname;
                u.permalink = us.permalink;
                u.points = us.points;
                //u.registration_date = us.registration_date;
                u.seller_experience = us.seller_experience;
                u.site_id = us.site_id;
                u.user_type = us.user_type;

                //IDENTIFICAÇÃO USUARIO
                if (us.identification != null)
                {
                    ML_Identification ident = new ML_Identification();
                    ident.number = us.identification.number;
                    ident.type = us.identification.type;
                    u.ML_Identification.Add(ident);
                }

                //if (us.billing_info != null)
                //{
                //    ML_Identification ident = new ML_Identification();
                //    ident.type = us.billing_info.doc_type;
                //    ident.number = us.billing_info.doc_number;
                //    u.ML_Identification.Add(ident);
                //}

                if (us.phone != null)
                {
                    //TELEFONES
                    ML_Phone pho = new ML_Phone();
                    pho.area_code = us.phone.area_code;
                    pho.extension = us.phone.extension;
                    pho.number = us.phone.number;
                    pho.varified = us.phone.verified.ToString();
                    u.ML_Phone.Add(pho);

                    if (us.alternative_phone != null)
                    {
                        pho = new ML_Phone();
                        pho.area_code = us.alternative_phone.area_code;
                        pho.extension = us.alternative_phone.extension;
                        pho.number = us.alternative_phone.number;
                        u.ML_Phone.Add(pho);
                    }
                }

                //TRATANDO REPUTAÇÃO DE VENDEDOR
                //if (us.seller_reputation != null)
                //{
                //    ML_SellerReputation sr = new ML_SellerReputation();
                //    sr.power_seller_status = us.seller_reputation.power_seller_status;
                //    sr.level_id = us.seller_reputation.level_id;
                //    u.ML_SellerReputation.Add(sr);

                //    ML_TransactionsSeller ts = new ML_TransactionsSeller();
                //    ts.canceled = us.seller_reputation.transactions.canceled;
                //    ts.completed = us.seller_reputation.transactions.completed;
                //    ts.period = us.seller_reputation.transactions.period;
                //    ts.total = us.seller_reputation.transactions.total;
                //    ts.ML_SellerReputation = sr;
                //    sr.ML_TransactionsSeller.Add(ts);

                //    ML_Ratings rt = new ML_Ratings();
                //    rt.ML_TransactionsSeller = ts;
                //    rt.negative = us.seller_reputation.transactions.ratings.negative;
                //    rt.neutral = us.seller_reputation.transactions.ratings.neutral;
                //    rt.positive = us.seller_reputation.transactions.ratings.positive;
                //    ts.ML_Ratings.Add(rt);
                //}

                //TRATANDO REPUTAÇÃO COMPRADOR
                //if (us.buyer_reputation != null)
                //{
                //    ML_BuyerReputation mb = new ML_BuyerReputation();
                //    mb.canceled_transactions = us.buyer_reputation.canceled_transactions;
                //    u.ML_BuyerReputation.Add(mb);

                //    ML_TransactionsBuyer tb = new ML_TransactionsBuyer();
                //    tb.completed = us.buyer_reputation.transactions.completed;
                //    tb.period = us.buyer_reputation.transactions.period;
                //    tb.total = us.buyer_reputation.transactions.total;
                //    tb.ML_BuyerReputation = mb;

                //    ML_ResumoTransBuyer canceled = new ML_ResumoTransBuyer();
                //    canceled.paid = us.buyer_reputation.transactions.canceled.paid;
                //    canceled.total = us.buyer_reputation.transactions.canceled.total;
                //    canceled.units = us.buyer_reputation.transactions.canceled.units;
                //    tb.ML_ResumoTransBuyer2 = canceled;

                //    ML_ResumoTransBuyer unrated = new ML_ResumoTransBuyer();
                //    unrated.paid = us.buyer_reputation.transactions.unrated.paid;
                //    unrated.total = us.buyer_reputation.transactions.unrated.total;
                //    unrated.units = us.buyer_reputation.transactions.unrated.units;
                //    tb.ML_ResumoTransBuyer1 = unrated;

                //    ML_ResumoTransBuyer not_yet_rated = new ML_ResumoTransBuyer();
                //    not_yet_rated.paid = us.buyer_reputation.transactions.not_yet_rated.paid;
                //    not_yet_rated.total = us.buyer_reputation.transactions.not_yet_rated.total;
                //    not_yet_rated.units = us.buyer_reputation.transactions.not_yet_rated.units;
                //    tb.ML_ResumoTransBuyer = not_yet_rated;
                //}

                return u;
            }
            catch (Exception ex)
            {
                throw new Exception("Erro na rotina ConverteUsuario2.", ex);
            }
        }