/// <summary> /// Команда запроса для отправки данных в Api /// </summary> public Result5 Set(dynamic paramsRequest, string ObjectRequest, string Metod, ref string[] Headers) { Result5 result = new Result5() { SetResults = new Set.Bids.BidActionResult[] { }, UpdateResults = new UpDate.Campaign.CampaignActionResult[] { }, }; string sdsf = RequestStreamApi (new RequestObjectV5 { Method = Metod, Params = paramsRequest }, ObjectRequest, ref Headers); GetResult s = Newtonsoft.Json.JsonConvert.DeserializeObject <GetResult>(sdsf); if (s.Error != null) { result.Error = s.Error; } else { if (s.Result.SetResults != null) { result.SetResults = result.SetResults.Concat(s.Result.SetResults).ToArray(); } if (s.Result.UpdateResults != null) { result.UpdateResults = result.UpdateResults.Concat(s.Result.UpdateResults).ToArray(); } } return(result); }
/// <summary> /// Команда запроса отчетов /// </summary> public List <string[]> RequestReport(dynamic paramsRequest, string ObjectRequest, string Metod, ref string[] Headers) { Result5 result = new Result5() { SetResults = new Set.Bids.BidActionResult[] { }, UpdateResults = new UpDate.Campaign.CampaignActionResult[] { }, }; List <string[]> sdsf = RequestStreamApiLine(new RequestObjectV5 { Method = Metod, Params = paramsRequest }, ObjectRequest, ref Headers); return(sdsf); }
/// <summary> /// Команда запроса для получения данных с Api /// </summary> public Result5 Get(dynamic paramsRequest, string ObjectRequest, string Metod, ref string[] Headers) { long limitedBy = 0L; Result5 result = new Result5() { AdGroups = new Model.AdGroup[] { }, Bids = new Model.Bids[] { }, Campaigns = new Model.Campaign[] { }, Clients = new Model.Client[] { }, Keywords = new Model.KeywordClass[] { }, KeywordBids = new Model.KeywordBid[] { }, }; do { if (paramsRequest is ParamsRequestAbstract) { paramsRequest.Page = new LimitOffset { Offset = limitedBy, Limit = 10000 } } ; string sdsf = RequestStreamApi (new RequestObjectV5 { Method = Metod, Params = paramsRequest }, ObjectRequest, ref Headers); GetResult s; try { s = Newtonsoft.Json.JsonConvert.DeserializeObject <GetResult>(sdsf); } catch (Exception e) { s = new GetResult { Error = new GetResultError { Error_string = e.Message, Error_code = e.HResult } }; } if (s == null) { goto end; } if (s.Error != null) { result.Error = s.Error; } else { limitedBy = s.Result.LimitedBy; if (s.Result.AdGroups != null) { result.AdGroups = result.AdGroups.Concat(s.Result.AdGroups).ToArray(); } if (s.Result.Bids != null) { result.Bids = result.Bids.Concat(s.Result.Bids).ToArray(); } if (s.Result.Campaigns != null) { result.Campaigns = result.Campaigns.Concat(s.Result.Campaigns).ToArray(); } if (s.Result.Clients != null) { result.Clients = result.Clients.Concat(s.Result.Clients).ToArray(); } if (s.Result.Keywords != null) { result.Keywords = result.Keywords.Concat(s.Result.Keywords).ToArray(); } if (s.Result.KeywordBids != null) { result.KeywordBids = result.KeywordBids.Concat(s.Result.KeywordBids).ToArray(); } } end :; }while (limitedBy > 0); return(result); }