Note |
---|
Timetracker version 4.7.5 or higher is required to access this API |
API
Code Block |
---|
package org.everit.jira.reporting.service.costrate;
import java.time.LocalDate;
import java.util.List;
/**
* Semi-Public User Cost Service.
*/
public interface UserCostService {
/**
* Add cost rate. Requires Wage Manager permission.
*
* @param userKey
* the user key
* @param validFromIncl
* the from date (inclusive).
* @param costRate
* the cost rate.
*/
void addCostRate(String userKey, LocalDate validFromIncl, double costRate);
/**
* Delete cost rate. Requires Wage Manager permission.
*
* @param costRateId
* the id of cost rate.
*/
void deleteCostRate(long costRateId);
/**
* List all cost rates for the specific users. Requires Wage Manager permission, else returns an empty list.
*
* @param userKey
* the user key.
* @return list of cost rates.
*/
List<CostRateInfo> listCostRates(String userKey);
/**
* Update cost rate. Requires Wage Manager permission.
*
* @param costRateId
* the id of cost rate.
* @param userKey
* the user key
* @param validFromIncl
* the from date (inclusive).
* @param costRate
* the cost rate.
*/
void updateCostRate(long costRateId, String userKey, LocalDate validFromIncl, double costRate);
} |
Example
Code Block |
---|
import com.onresolve.scriptrunner.runner.customisers.PluginModule;
import java.time.LocalDate;
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
import org.everit.jira.reporting.service.costrate.CostRateInfo;
import org.everit.jira.reporting.service.costrate.UserCostService;
import java.util.Arrays;
@WithPlugin("org.everit.jira.timetracker.plugin")
@PluginModule
UserCostService userCostService;
List<CostRateInfo> costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates);
LocalDate now = LocalDate.now();
userCostService.addCostRate("douglas.arnold@everit.biz", now, (double) 5.0);
costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates);
CostRateInfo costRateInfo = costRates.get(0);
userCostService.updateCostRate(costRateInfo.costRateId, costRateInfo.userKey, costRateInfo.validFromIncl, (double) 2.0);
costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates);
costRateInfo = costRates.get(0);
userCostService.deleteCostRate(costRateInfo.costRateId);
costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates) |