Search in sources :

Example 11 with ClientContact

use of ch.aaap.harvestclient.domain.ClientContact in project harvest-client by 3AP-AG.

the class ClientContactsApiImpl method get.

@Override
public ClientContact get(Reference<ClientContact> clientContactReference) {
    Call<ClientContact> call = service.get(clientContactReference.getId());
    ClientContact clientContact = ExceptionHandler.callOrThrow(call);
    log.debug("Got ClientContact {}", clientContact);
    return clientContact;
}
Also used : ClientContact(ch.aaap.harvestclient.domain.ClientContact)

Example 12 with ClientContact

use of ch.aaap.harvestclient.domain.ClientContact 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

ClientContact (ch.aaap.harvestclient.domain.ClientContact)12 HarvestTest (ch.aaap.harvestclient.HarvestTest)9 ImmutableClientContact (ch.aaap.harvestclient.domain.ImmutableClientContact)9 Test (org.junit.jupiter.api.Test)9 ClientContactFilter (ch.aaap.harvestclient.api.filter.ClientContactFilter)4 Client (ch.aaap.harvestclient.domain.Client)3 ClientContactUpdateInfo (ch.aaap.harvestclient.domain.param.ClientContactUpdateInfo)2 ImmutableClientContactUpdateInfo (ch.aaap.harvestclient.domain.param.ImmutableClientContactUpdateInfo)2 Reference (ch.aaap.harvestclient.domain.reference.Reference)2 Api (ch.aaap.harvestclient.api.Api)1 ClientContactsApi (ch.aaap.harvestclient.api.ClientContactsApi)1 ch.aaap.harvestclient.api.filter (ch.aaap.harvestclient.api.filter)1 Harvest (ch.aaap.harvestclient.core.Harvest)1 User (ch.aaap.harvestclient.domain.User)1 RequestProcessingException (ch.aaap.harvestclient.exception.RequestProcessingException)1 Instant (java.time.Instant)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 AfterEach (org.junit.jupiter.api.AfterEach)1