public BulkAPIResponse <ZCRMRecord> GetRecords(long?cvId, string sortByField, CommonUtil.SortOrder?sortOrder, int page, int perPage, string modifiedSince, string isConverted, string isApproved, List <string> fields) { requestMethod = APIConstants.RequestMethod.GET; urlPath = module.ApiName; if (cvId != null) { requestQueryParams.Add("cvid", cvId.ToString()); } if (sortByField != null) { requestQueryParams.Add("sort_by", sortByField); } if (sortOrder != null) { requestQueryParams.Add("sort_order", sortOrder.ToString()); } requestQueryParams.Add(APIConstants.PAGE, page.ToString()); requestQueryParams.Add(APIConstants.PER_PAGE, perPage.ToString()); if (isApproved != null && isApproved != "") { requestQueryParams.Add("approved", isApproved); } if (isConverted != null && isConverted != "") { requestQueryParams.Add("converted", isConverted); } if (fields != null) { requestQueryParams.Add("fields", CommonUtil.CollectionToCommaDelimitedString(fields)); } if (modifiedSince != null && modifiedSince != "") { requestHeaders.Add("If-Modified-Since", modifiedSince); } BulkAPIResponse <ZCRMRecord> response = APIRequest.GetInstance(this).GetBulkAPIResponse <ZCRMRecord>(); List <ZCRMRecord> records = new List <ZCRMRecord>(); JObject responseJSON = response.ResponseJSON; if (responseJSON.ContainsKey(APIConstants.DATA)) { JArray recordsArray = (JArray)responseJSON[APIConstants.DATA]; foreach (JObject recordDetails in recordsArray) { ZCRMRecord record = ZCRMRecord.GetInstance(module.ApiName, Convert.ToInt64(recordDetails["id"])); EntityAPIHandler.GetInstance(record).SetRecordProperties(recordDetails); records.Add(record); } } response.BulkData = records; return(response); }
public BulkAPIResponse <ZCRMOrgTax> DeleteTaxes(List <long> taxIds) { if (taxIds.Count > 100) { throw new ZCRMException(APIConstants.API_MAX_RECORDS_MSG); } try { requestMethod = APIConstants.RequestMethod.DELETE; urlPath = "org/taxes"; requestQueryParams.Add("ids", CommonUtil.CollectionToCommaDelimitedString(taxIds)); return(APIRequest.GetInstance(this).GetBulkAPIResponse <ZCRMOrgTax>()); } catch (Exception e) when(!(e is ZCRMException)) { ZCRMLogger.LogError(e); throw new ZCRMException(APIConstants.SDK_ERROR, e); } }
public BulkAPIResponse <ZCRMEntity> DeleteRecords(List <long> entityIds) { if (entityIds.Count > 100) { throw new ZCRMException(APIConstants.API_MAX_RECORDS_MSG); } requestMethod = APIConstants.RequestMethod.DELETE; urlPath = module.ApiName; requestQueryParams.Add("ids", CommonUtil.CollectionToCommaDelimitedString(entityIds)); BulkAPIResponse <ZCRMEntity> response = APIRequest.GetInstance(this).GetBulkAPIResponse <ZCRMEntity>(); List <EntityResponse> responses = response.BulkEntitiesResponse; foreach (EntityResponse entityResponse in responses) { JObject entityResponseJSON = entityResponse.ResponseJSON; JObject recordJSON = (JObject)entityResponseJSON[APIConstants.DETAILS]; ZCRMRecord record = ZCRMRecord.GetInstance(module.ApiName, Convert.ToInt64(recordJSON["id"])); entityResponse.Data = record; } return(response); }