1.0.0 • Published 10 months ago

@redmine/json-api v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

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 a RedmineValue instance with the given id and name.

Methods

  • toJSON(): Returns an object representing the RedmineValue 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 a RedmineCustomField instance with the given id and name.

Methods

  • setValue(value): Sets the value property of the RedmineCustomField instance.
  • toJSON(): Returns an object representing the RedmineCustomField instance in JSON format.

RedmineCheckList Class

The RedmineCheckList class represents a checklist in Redmine.

Constructor

  • RedmineCheckList(): Creates a RedmineCheckList instance.

RedmineCustomFieldMultiple Class

The RedmineCustomFieldMultiple class represents a custom field in Redmine that can hold multiple values.

Constructor

  • RedmineCustomFieldMultiple(id, name): Creates a RedmineCustomFieldMultiple instance with the given id and name.

Methods

  • addValue(value): Adds a value to the value array of the RedmineCustomFieldMultiple instance.
  • setValue(list): Sets the value array of the RedmineCustomFieldMultiple instance with the given list of values.
  • toJSON(): Returns an object representing the RedmineCustomFieldMultiple instance in JSON format.

RedmineIssue Class

The RedmineIssue class represents an issue in Redmine and extends the RedmineBase class.

Constructor

  • RedmineIssue(): Creates a RedmineIssue 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.

1.0.0

10 months ago