Пример #1
0
        private BulkAPIResponse <ZCRMTrashRecord> GetDeletedRecords(string type)
        {
            try
            {
                requestMethod = APIConstants.RequestMethod.GET;
                urlPath       = module.ApiName + "/deleted";
                requestQueryParams.Add("type", type);

                BulkAPIResponse <ZCRMTrashRecord> response = APIRequest.GetInstance(this).GetBulkAPIResponse <ZCRMTrashRecord>();

                List <ZCRMTrashRecord> trashRecordList = new List <ZCRMTrashRecord>();
                JObject responseJSON = response.ResponseJSON;
                if (responseJSON.ContainsKey(APIConstants.DATA))
                {
                    JArray trashRecordsArray = (JArray)responseJSON[APIConstants.DATA];
                    foreach (JObject trashRecordDetails in trashRecordsArray)
                    {
                        trashRecord = ZCRMTrashRecord.GetInstance((string)trashRecordDetails["type"], Convert.ToInt64(trashRecordDetails["id"]));
                        SetTrashRecordProperties(trashRecordDetails);
                        trashRecordList.Add(trashRecord);
                    }
                }
                response.BulkData = trashRecordList;
                return(response);
            }
            catch (Exception e) when(!(e is ZCRMException))
            {
                ZCRMLogger.LogError(e);
                throw new ZCRMException(APIConstants.SDK_ERROR, e);
            }
        }
Пример #2
0
        //TODO: Handle exceptions;
        public BulkAPIResponse <ZCRMTrashRecord> GetDeletedRecords(string type)
        {
            try
            {
                requestMethod = APIConstants.RequestMethod.GET;
                urlPath       = module.ApiName + "/deleted";
                requestQueryParams.Add("type", type);

                BulkAPIResponse <ZCRMTrashRecord> response = APIRequest.GetInstance(this).GetBulkAPIResponse <ZCRMTrashRecord>();

                List <ZCRMTrashRecord> trashRecordList = new List <ZCRMTrashRecord>();
                JObject responseJSON      = response.ResponseJSON;
                JArray  trashRecordsArray = (JArray)responseJSON.GetValue("data");
                foreach (JObject trashRecordDetails in trashRecordsArray)
                {
                    trashRecord = ZCRMTrashRecord.GetInstance(Convert.ToString(trashRecordDetails.GetValue("type")), Convert.ToInt64(trashRecordDetails.GetValue("id")));
                    SetTrashRecordProperties(trashRecordDetails);
                    trashRecordList.Add(trashRecord);
                }
                response.BulkData = trashRecordList;
                return(response);
            }catch (Exception e) {
                //TODO: Log the exceptions;
                Console.WriteLine(e);
                throw new ZCRMException("ZCRM_INTERNAL_ERROR");
            }
        }