@redmine/json-api
v1.0.0
Published
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()`.
Downloads
1
Readme
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 aRedmineValue
instance with the givenid
andname
.
Methods
toJSON()
: Returns an object representing theRedmineValue
instance 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 aRedmineCustomField
instance with the givenid
andname
.
Methods
setValue(value)
: Sets thevalue
property of theRedmineCustomField
instance.toJSON()
: Returns an object representing theRedmineCustomField
instance in JSON format.
RedmineCheckList Class
The RedmineCheckList
class represents a checklist in Redmine.
Constructor
RedmineCheckList()
: Creates aRedmineCheckList
instance.
RedmineCustomFieldMultiple Class
The RedmineCustomFieldMultiple
class represents a custom field in Redmine that can hold multiple values.
Constructor
RedmineCustomFieldMultiple(id, name)
: Creates aRedmineCustomFieldMultiple
instance with the givenid
andname
.
Methods
addValue(value)
: Adds a value to thevalue
array of theRedmineCustomFieldMultiple
instance.setValue(list)
: Sets thevalue
array of theRedmineCustomFieldMultiple
instance with the given list of values.toJSON()
: Returns an object representing theRedmineCustomFieldMultiple
instance in JSON format.
RedmineIssue Class
The RedmineIssue
class represents an issue in Redmine and extends the RedmineBase
class.
Constructor
RedmineIssue()
: Creates aRedmineIssue
instance.
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.