Search in sources :

Example 1 with Harvest

use of ch.aaap.harvestclient.core.Harvest in project harvest-client by 3AP-AG.

the class ExceptionsTest method startServer.

private void startServer() throws IOException {
    server.start();
    HttpUrl baseUrl = server.url("");
    Config config = ConfigFactory.defaultReference();
    config = config.withValue("harvest.baseUrl", ConfigValueFactory.fromAnyRef(baseUrl.toString()));
    new Harvest(config);
}
Also used : Config(com.typesafe.config.Config) Harvest(ch.aaap.harvestclient.core.Harvest) HttpUrl(okhttp3.HttpUrl)

Example 2 with Harvest

use of ch.aaap.harvestclient.core.Harvest in project harvest-client by 3AP-AG.

the class DeleteAllData method main.

/**
 * Delete all available data in an Harvest account apart from the currently
 * authenticated User
 */
public static void main(String[] args) {
    Harvest harvest = TestSetupUtil.getAnotherAdminAccess();
    log.debug("Deleting all data in account {}", harvest.getAccountId());
    harvest.projects().list(new ProjectFilter()).forEach(harvest.projects()::delete);
    List<ClientContact> clientContacts = harvest.clientContacts().list(new ClientContactFilter());
    deleteAll(clientContacts, harvest.clientContacts());
    harvest.estimates().list(new EstimateFilter()).forEach(harvest.estimates()::delete);
    harvest.estimateItemCategories().list(null).forEach(harvest.estimateItemCategories()::delete);
    List<Client> clients = harvest.clients().list(new ClientFilter());
    deleteAll(clients, harvest.clients());
    harvest.timesheets().list(new TimeEntryFilter()).forEach(harvest.timesheets()::delete);
    harvest.tasks().list(new TaskFilter()).forEach(harvest.tasks()::delete);
    harvest.roles().list().forEach(harvest.roles()::delete);
    User self = harvest.users().getSelf();
    harvest.users().list().stream().filter(user -> !user.getId().equals(self.getId())).forEach(harvest.users()::delete);
}
Also used : Api(ch.aaap.harvestclient.api.Api) Harvest(ch.aaap.harvestclient.core.Harvest) List(java.util.List) Logger(org.slf4j.Logger) Client(ch.aaap.harvestclient.domain.Client) Reference(ch.aaap.harvestclient.domain.reference.Reference) LoggerFactory(org.slf4j.LoggerFactory) ClientContact(ch.aaap.harvestclient.domain.ClientContact) User(ch.aaap.harvestclient.domain.User) ch.aaap.harvestclient.api.filter(ch.aaap.harvestclient.api.filter) User(ch.aaap.harvestclient.domain.User) Harvest(ch.aaap.harvestclient.core.Harvest) ClientContact(ch.aaap.harvestclient.domain.ClientContact) Client(ch.aaap.harvestclient.domain.Client)

Aggregations

Harvest (ch.aaap.harvestclient.core.Harvest)2 Api (ch.aaap.harvestclient.api.Api)1 ch.aaap.harvestclient.api.filter (ch.aaap.harvestclient.api.filter)1 Client (ch.aaap.harvestclient.domain.Client)1 ClientContact (ch.aaap.harvestclient.domain.ClientContact)1 User (ch.aaap.harvestclient.domain.User)1 Reference (ch.aaap.harvestclient.domain.reference.Reference)1 Config (com.typesafe.config.Config)1 List (java.util.List)1 HttpUrl (okhttp3.HttpUrl)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1