Exemple #1
0
        public DealResponse Update(DealModelProperty model, long uid)
        {
            DealResponse Deal    = new DealResponse();
            string       url     = string.Format(GetUrl(UrlType.Deal, UrlSubType.DealById), uid);
            var          request = new
            {
                properties = model.ToDealProperty()
            };

            Synergy.Common.Request.WebClient client = new Synergy.Common.Request.WebClient();
            HttpWebResponse response = client.Put(JsonConvert.SerializeObject(request), url, AuthorizationHeader.GetAuthorizationToken(_AccessToken.Accesstoken), EnumUtilities.GetDescriptionFromEnumValue(ContentTypes.JSON));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var          responseStream = response.GetResponseStream();
                StreamReader streamReader   = new StreamReader(responseStream);
                string       rawResponse    = streamReader.ReadToEnd();
                Deal = JsonConvert.DeserializeObject <DealResponse>(rawResponse);
            }
            return(Deal);
        }
Exemple #2
0
        private DealResponse Add(DealModel model)
        {
            DealResponse Deal = new DealResponse();
            string       url  = GetUrl(UrlType.Deal, UrlSubType.DealAdd);

            Synergy.Common.Request.WebClient client = new Synergy.Common.Request.WebClient();
            HttpWebResponse response = client.Post(JsonConvert.SerializeObject(model.ToDealRequest()), url, AuthorizationHeader.GetAuthorizationToken(_AccessToken.Accesstoken), EnumUtilities.GetDescriptionFromEnumValue(ContentTypes.JSON));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var          responseStream = response.GetResponseStream();
                StreamReader streamReader   = new StreamReader(responseStream);
                string       rawResponse    = streamReader.ReadToEnd();
                Deal = JsonConvert.DeserializeObject <DealResponse>(rawResponse);
            }
            return(Deal);
        }
Exemple #3
0
 private void Delete(string url)
 {
     Synergy.Common.Request.WebClient client = new Synergy.Common.Request.WebClient();
     HttpWebResponse response = client.Delete(url, EnumUtilities.GetDescriptionFromEnumValue(ContentTypes.JSON), AuthorizationHeader.GetAuthorizationToken(_AccessToken.Accesstoken));
 }
Exemple #4
0
        private DealsResponse GetDeals(string url)
        {
            DealsResponse Deals = new DealsResponse();

            Synergy.Common.Request.WebClient client = new Synergy.Common.Request.WebClient();
            HttpWebResponse response = client.Get(url, EnumUtilities.GetDescriptionFromEnumValue(ContentTypes.JSON), AuthorizationHeader.GetAuthorizationToken(_AccessToken.Accesstoken));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var          responseStream = response.GetResponseStream();
                StreamReader streamReader   = new StreamReader(responseStream);
                string       rawResponse    = streamReader.ReadToEnd();
                Deals = JsonConvert.DeserializeObject <DealsResponse>(rawResponse);
            }
            return(Deals);
        }
Exemple #5
0
        private ContactResponse Update(string uid, ContactModel model)
        {
            ContactResponse Contact = new ContactResponse();
            string          url     = string.Format(GetUrl(UrlType.Contact, UrlSubType.ContactById), uid);
            ContactRequest  request = new ContactRequest()
            {
                Properties = model.ToProperties()
            };

            Synergy.Common.Request.WebClient client = new Synergy.Common.Request.WebClient();
            HttpWebResponse response = client.Post(JsonConvert.SerializeObject(request), url, AuthorizationHeader.GetAuthorizationToken(_AccessToken.Accesstoken), EnumUtilities.GetDescriptionFromEnumValue(ContentTypes.JSON));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var          responseStream = response.GetResponseStream();
                StreamReader streamReader   = new StreamReader(responseStream);
                string       rawResponse    = streamReader.ReadToEnd();
                Contact = JsonConvert.DeserializeObject <ContactResponse>(rawResponse);
            }
            return(Contact);
        }