/// <summary> /// Get the keywords from an article /// </summary> /// <param name="articleID"></param> /// <param name="creds"></param> /// <returns></returns> public static List<string> GetKeywords(long articleId, ParaCredentials creds) { //Get the article var article = Service.GetDetails<Article>(articleId); return article.Keywords.Split(',').ToList(); }
//Example Setting Keywords public static void AddingKeywordsExample(ParaCredentials creds) { var keywords = new List<string>(); keywords.Add("one"); keywords.Add("two"); AddKeywords(10, keywords, creds); }
/// <summary> /// Retrieve all tickets from a department of Parature minus archived and deleted tickets. /// </summary> /// <param name="creds"></param> /// <returns></returns> public static List<Ticket> GetAllTickets(ParaCredentials creds) { var tq = new TicketQuery(); tq.RetrieveAllRecords = true; var tickets = Service.GetList<Ticket>(tq); if (tickets.ApiCallResponse.HasException) { throw new Exception(tickets.ApiCallResponse.ExceptionDetails); } return tickets.ToList(); }
/// <summary> /// Add keywords to an article that we're assuming does not already have articles /// </summary> /// <param name="articleID"></param> /// <param name="keywords"></param> /// <param name="creds"></param> /// <returns></returns> public static bool AddKeywords(long articleId, List<string> keywords, ParaCredentials creds) { //Get the article var article = Service.GetDetails<Article>(articleId); //Set the keywords article.Keywords = String.Join(",", keywords); //Perform the update var response = Service.Update(article); //Verify response return !response.HasException; }
public static List<ParatureSDK.ParaObjects.DownloadFolder> getAllDownloadFolders(ParaCredentials creds) { var dfQuery = new DownloadFolderQuery(); dfQuery.RetrieveAllRecords = true; var folders = Service.GetList<DownloadFolder>(dfQuery); if (folders.ApiCallResponse.HasException) { throw new Exception(folders.ApiCallResponse.ExceptionDetails); } return folders.ToList(); }
/// <summary> /// Internal method to attach a file for the Parature entity /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="pc"></param> /// <param name="attachment"></param> /// <returns></returns> internal static Attachment UploadFile <TEntity>(ParaCredentials pc, System.Net.Mail.Attachment attachment) where TEntity : ParaEntity { var postUrlR = ApiCallFactory.FileUploadGetUrl <TEntity>(pc); var uploadUrlDoc = postUrlR.XmlReceived; var postUrl = AttachmentGetUrlToPost(uploadUrlDoc); var upresp = ApiCallFactory.FilePerformUpload(postUrl, attachment); var attaDoc = upresp.XmlReceived; var attach = ParaEntityParser.EntityFill <Attachment>(attaDoc); return(attach); }
public static List<ParatureSDK.ParaObjects.Download> getDownloadsByFolder(ParaCredentials creds, long folderID) { var downloadQuery = new DownloadQuery(); downloadQuery.RetrieveAllRecords = true; downloadQuery.AddStaticFieldFilter(DownloadQuery.DownloadStaticFields.Folder, ParaEnums.QueryCriteria.Equal, folderID.ToString()); var downloads = Service.GetList<Download>(downloadQuery); if (downloads.ApiCallResponse.HasException) { throw new Exception(downloads.ApiCallResponse.ExceptionDetails); } return downloads.ToList(); }
public static long getDownloadsCountByFolder(ParaCredentials creds, long folderID) { var downloadQuery = new DownloadQuery(); downloadQuery.TotalOnly = true; downloadQuery.AddStaticFieldFilter(DownloadQuery.DownloadStaticFields.Folder, ParaEnums.QueryCriteria.Equal, folderID.ToString()); var downloads = Service.GetList<Download>(downloadQuery); if (downloads.ApiCallResponse.HasException) { throw new Exception(downloads.ApiCallResponse.ExceptionDetails); } return downloads.TotalItems; }
internal static string ApiObjectCustomUrl <TModule, TEntity>(ParaCredentials paracredentials, ArrayList arguments) where TModule : ParaEntity where TEntity : ParaEntityBaseProperties { var apiCallUrl = ApiBuildBasicUrl(paracredentials) + typeof(TModule).Name + "/" + typeof(TEntity).Name.ToLower() + "?" + ApiToken(paracredentials); if (arguments.Count > 0) { for (int i = 0; i <= arguments.Count - 1; i++) { apiCallUrl = apiCallUrl + "&" + arguments[i]; } } return(apiCallUrl); }
/// <summary> /// Retrieve all tickets that belong to an organization minus archived and deleted tickets /// </summary> /// <param name="creds"></param> /// <param name="accountId">Account ID of the organization. Not to be confused with Instance ID. Use the Account APIs to determine the account ID</param> /// <returns></returns> public static List<ParatureSDK.ParaObjects.Ticket> GetAllTicketsForAccount(ParaCredentials creds, long accountId) { var tq = new TicketQuery(); //Add an account filter: https://support.parature.com/public/doc/api.html#ticket-list tq.AddStaticFieldFilter(TicketQuery.TicketStaticFields.Account, ParaEnums.QueryCriteria.Equal, accountId.ToString()); tq.RetrieveAllRecords = true; var tickets = Service.GetList<Ticket>(tq); if (tickets.ApiCallResponse.HasException) { throw new Exception(tickets.ApiCallResponse.ExceptionDetails); } return tickets.ToList(); }
private static ParaEntityList <T> RetrieveAllEntities <T>(ParaCredentials pc, ParaEntityQuery query) where T : ParaEntity, new() { ApiCallResponse ar; var entityList = new ParaEntityList <T>(); ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; var continueCalling = true; while (continueCalling) { if (entityList.TotalItems > entityList.Data.Count) { // We still need to pull data // Getting next page's data query.PageNumber = query.PageNumber + 1; ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { var objectlist = ParaEntityParser.FillList <T>(ar.XmlReceived); entityList.Data.AddRange(objectlist.Data); entityList.ResultsReturned = entityList.Data.Count; entityList.PageNumber = query.PageNumber; } else { // There is an error processing request entityList.ApiCallResponse = ar; continueCalling = false; } } else { // That is it, pulled all the items. continueCalling = false; entityList.ApiCallResponse = ar; } } return(entityList); }
/// <summary> /// Build the API URL to call, Add a simple customString to be appended at the end of the call. Used for special instances, like requesting an upload URL. /// </summary> internal static string ApiObjectCustomUrl <TEntity>(ParaCredentials paracredentials, string customstring) { if (string.IsNullOrEmpty(customstring)) { customstring = "/"; } else { customstring = "/" + customstring; } string apiCallUrl = ApiBuildBasicUrl(paracredentials) + typeof(TEntity).Name + customstring + "?" + ApiToken(paracredentials); return(apiCallUrl); }
internal static string ApiObjectUrl(ParaCredentials paracredentials, string module, Int64 objectId, ArrayList arguments) { var apiCallUrl = ApiObjectUrl(paracredentials, module, objectId, false); if (arguments != null) { if (arguments.Count > 0) { for (var i = 0; i <= arguments.Count - 1; i++) { apiCallUrl = apiCallUrl + "&" + arguments[i]; } } } return(apiCallUrl); }
/// <summary> /// Retrieve the details for a specific Parature module entity with custom query string arguments /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pc"></param> /// <param name="entityId"></param> /// <returns></returns> internal static T ApiGetEntity <T>(ParaCredentials pc, long entityId, ArrayList arl) where T : ParaEntityBaseProperties, new() { var entity = new T(); var req = ApiCallFactory.ObjectGetDetail <T>(pc, entityId, arl); if (req.HasException == false) { entity = ParaEntityParser.EntityFill <T>(req.XmlReceived); entity.FullyLoaded = true; } else { entity.FullyLoaded = false; entity.Id = 0; } entity.ApiCallResponse = req; entity.IsDirty = false; return(entity); }
internal static ApiCallResponse ObjectDelete(ParaCredentials paracredentials, string entityType, Int64 objectid, bool purge) { string apiCallUrl; if (purge) { var arguments = new ArrayList { "_purge_=true" }; apiCallUrl = ApiUrlBuilder.ApiObjectUrl(paracredentials, entityType, objectid, arguments); } else { apiCallUrl = ApiUrlBuilder.ApiObjectUrl(paracredentials, entityType, objectid, false); } return(ApiMakeTheCall(apiCallUrl, ParaEnums.ApiCallHttpMethod.Delete)); }
/// <summary> /// Retrieve the details for a specific Parature module entity with custom query string arguments /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pc"></param> /// <param name="entityId"></param> /// <returns></returns> internal static ParaObjects.Download ApiGetDownloadEntity(ParaCredentials pc, long entityId, ArrayList arl) { var entity = new ParaObjects.Download(); var req = ApiCallFactory.ObjectGetDetail <ParaObjects.Download>(pc, entityId, arl); if (req.HasException == false) { entity = ParaEntityParser.EntityFillDownload(req.XmlReceived); entity.FullyLoaded = true; } else { entity.FullyLoaded = false; entity.Id = 0; } entity.ApiCallResponse = req; entity.IsDirty = false; return(entity); }
/// <summary> /// Fills a main module's list object. /// </summary> internal static ParaEntityList <T> ApiGetEntityList <T>(ParaCredentials pc, ParaEntityQuery query) where T : ParaEntity, new() { var entityList = new ParaEntityList <T>(); // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { entityList = RetrieveAllEntities <T>(pc, query); } else { var ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; } return(entityList); }
/// <summary> /// Build the API URL to call. Since a simple read (without any further options) is the same as an update, as well as a delete, this method will generate that same link for these operations. Also, indicates whether you are requesting a schema a link, or an actual operation link /// </summary> internal static string ApiObjectUrl(ParaCredentials paracredentials, string module, Int64 objectId, bool isSchema) { string customstring; if (isSchema) { customstring = "/schema"; } else { if (objectId == 0) { customstring = ""; } else { customstring = "/" + objectId; } } var apiCallUrl = ApiBuildBasicUrl(paracredentials) + module + customstring + "?" + ApiToken(paracredentials); return(apiCallUrl); }
/// <summary> /// Internal method to handle the upload of a file to Parature. /// </summary> internal static Attachment UploadFile <TEntity>(ParaCredentials pc, Byte[] attachment, String contentType, String fileName) where TEntity : ParaEntity { Attachment attach; var postUrl = ""; postUrl = AttachmentGetUrlToPost(ApiCallFactory.FileUploadGetUrl <TEntity>(pc).XmlReceived); if (String.IsNullOrEmpty(postUrl) == false) { var uploadResponse = ApiCallFactory.FilePerformUpload(postUrl, attachment, contentType, fileName) .XmlReceived; attach = new Attachment(); var uploadResult = ParaEntityParser.EntityFill <UploadResult>(uploadResponse); if (!string.IsNullOrEmpty(uploadResult.Error)) { //There was an error uploading attach.HasException = true; attach.Error = uploadResult.Error; } else { attach.Name = uploadResult.Result.File.FileName; attach.Guid = uploadResult.Result.File.Guid; } } else { attach = new Attachment(); } return(attach); }
public static ApiCallResponse ObjectDelete <T>(ParaCredentials paracredentials, Int64 objectid, bool purge) { return(ObjectDelete(paracredentials, typeof(T).Name, objectid, purge)); }
internal static ApiCallResponse ObjectCreateUpdate(ParaCredentials paracredentials, string entityType, XmlDocument fileToPost, Int64 objectid) { return(ObjectCreateUpdate(paracredentials, entityType, fileToPost, objectid, null)); }
public static ApiCallResponse ObjectCreateUpdate <T>(ParaCredentials paracredentials, XmlDocument fileToPost, Int64 objectid, ArrayList arguments) { return(ObjectCreateUpdate(paracredentials, typeof(T).Name, fileToPost, objectid, arguments)); }
public static ApiCallResponse FileUploadGetUrl <TEntity>(ParaCredentials paracredentials) where TEntity : ParaEntity { var resp = ApiMakeTheCall(ApiUrlBuilder.ApiObjectCustomUrl <TEntity>(paracredentials, "upload"), ParaEnums.ApiCallHttpMethod.Get); return(resp); }
public static ApiCallResponse ObjectCreateUpdate <T>(ParaCredentials paracredentials, XmlDocument fileToPost, Int64 objectid) { // Calling the next method that manages the call. return(ObjectCreateUpdate <T>(paracredentials, fileToPost, objectid, null)); }
/// <summary> /// Use this method to get the details of an Entity that you plan to fill. /// </summary> /// <param name="paracredentials"> /// The credentials to be used for making the API call. /// Value Type: <see cref="ParaCredentials" /> (ParaConnect.ParaCredentials) /// </param> /// <param name="objectid"> /// The id of the object to create or update. /// Value Type: <see cref="Int64" /> (System.int64) /// </param> public static ApiCallResponse ChatTranscriptGetDetail(ParaCredentials paracredentials, Int64 objectid) { var apiCallUrl = ApiUrlBuilder.ApiChatTranscriptUrl(paracredentials, objectid); return(ApiMakeTheCall(apiCallUrl, ParaEnums.ApiCallHttpMethod.Get)); }
/// <summary> /// Use this method to get the details of an object that you plan to fill. /// </summary> /// <param name="paracredentials"> /// The credentials to be used for making the API call. /// Value Type: <see cref="ParaCredentials" /> (ParaConnect.ParaCredentials) /// </param> /// <param name="objectid"> /// The id of the object to create or update. /// Value Type: <see cref="Int64" /> (System.int64) /// </param> public static ApiCallResponse ObjectGetDetail <T>(ParaCredentials paracredentials, Int64 objectid) where T : ParaEntityBaseProperties { return(ObjectGetDetail <T>(paracredentials, objectid, new ArrayList())); }
/// <summary> /// Simply returns the token query string that needs to be attached to the API URL. Will return something like: _token_=xxxx /// </summary> private static string ApiToken(ParaCredentials paracredentials) { var apiTokenQs = "_token_=" + paracredentials.Token; return(apiTokenQs); }
internal static ParaEntityList <ParaObjects.Download> ApiGetDownloadEntityList(ParaCredentials pc) { var entityList = new ParaEntityList <ParaObjects.Download>(); var ar = ApiCallFactory.ObjectGetList <ParaObjects.Download>(pc, new ArrayList()); if (ar.HasException == false) { entityList = ParaEntityParser.FillListDownload(ar.XmlReceived); } entityList.ApiCallResponse = ar; return(entityList); }
/// <summary> /// Internal Method to run an Action, independently from the module. /// </summary> internal static ApiCallResponse ActionRun <TEntity>(Int64 objectId, ParaObjects.Action action, ParaCredentials pc) where TEntity : ParaEntity { var doc = XmlGenerator.GenerateActionXml <TEntity>(action); var ar = ApiCallFactory.ObjectCreateUpdate <TEntity>(pc, doc, objectId); return(ar); }