@redmine/json-api v1.0.0
Redmine JSON API
RedmineBase Class
The RedmineBase class serves as the base class for various other classes used in a Redmine integration. It provides a static method toCreateFormat(objIns) and an instance method toCreate().
Static Method
toCreateFormat(objIns)
The toCreateFormat(objIns) method is a static method that transforms an object instance or an array of object instances into a specific format suitable for creating or updating objects in the Redmine system. It recursively traverses the object instances and their prototypes to retrieve data to be sent to the Redmine API.
Parameters
objIns: The object instance or an array of object instances to be transformed.
Returns
The method returns an object in a format suitable for creating or updating objects in Redmine.
Instance Method
toCreate()
The toCreate() method is an instance method that should be implemented in the derived classes. It is used to provide data for creating or updating objects in the Redmine system. The method should return an object or a value that represents the data to be sent to Redmine.
Derived Classes
The following classes extend the RedmineBase class and provide specific functionality for creating or updating various Redmine entities.
RedmineValue Class
The RedmineValue class represents a basic Redmine entity with an id and name.
Constructor
RedmineValue(id, name): Creates aRedmineValueinstance with the givenidandname.
Methods
toJSON(): Returns an object representing theRedmineValueinstance in JSON format.
RedmineProject, RedmineTracker, RedmineStatus, RedmineUser, RedmineAuthor, RedmineAssignedTo, RedmineWatcher Classes
These classes represent specific types of Redmine entities and inherit from the RedmineValue class. They have similar functionality to the RedmineValue class.
RedmineCustomField Class
The RedmineCustomField class represents a custom field in Redmine with an additional value property.
Constructor
RedmineCustomField(id, name): Creates aRedmineCustomFieldinstance with the givenidandname.
Methods
setValue(value): Sets thevalueproperty of theRedmineCustomFieldinstance.toJSON(): Returns an object representing theRedmineCustomFieldinstance in JSON format.
RedmineCheckList Class
The RedmineCheckList class represents a checklist in Redmine.
Constructor
RedmineCheckList(): Creates aRedmineCheckListinstance.
RedmineCustomFieldMultiple Class
The RedmineCustomFieldMultiple class represents a custom field in Redmine that can hold multiple values.
Constructor
RedmineCustomFieldMultiple(id, name): Creates aRedmineCustomFieldMultipleinstance with the givenidandname.
Methods
addValue(value): Adds a value to thevaluearray of theRedmineCustomFieldMultipleinstance.setValue(list): Sets thevaluearray of theRedmineCustomFieldMultipleinstance with the given list of values.toJSON(): Returns an object representing theRedmineCustomFieldMultipleinstance in JSON format.
RedmineIssue Class
The RedmineIssue class represents an issue in Redmine and extends the RedmineBase class.
Constructor
RedmineIssue(): Creates aRedmineIssueinstance.
Methods
setProject(project): Sets the project of the issue.setTracker(tracker): Sets the tracker of the issue.setStatus(status): Sets the status of the issue.setAuthor(author): Sets the author of the issue.setAssignedTo(assigned_to): Sets the assigned-to user of the issue.setSubject(subject): Sets the subject of the issue.setDescription(description): Sets the description of the issue.addCustomFields(custom_field): Adds a custom field to the issue.addWatchers(watcher): Adds a watcher to the issue.setWatchers(...watchers): Sets the watchers of the issue with multiple watcher objects.setDueDate(due_date): Sets the due date of the issue.setEstimatedHours(estimated_hours): Sets the estimated hours of the issue.addCheckList(subject, is_done): Adds a checklist item to the issue.setCheckList(...list): Sets the checklist of the issue with multiple checklist items.
Note: The RedmineIssue class does not have a toCreate() method. It relies on the toCreate() method defined in its parent classes (RedmineBase and RedmineValue) to generate the necessary data for creating or updating the issue in Redmine.
2 years ago