package uk.gov.dvsa.domain.service;

import com.jayway.restassured.response.Response;

import uk.gov.dvsa.domain.api.request.CreateEventRequest;
import uk.gov.dvsa.domain.model.User;
import uk.gov.dvsa.domain.model.mot.Event;
import uk.gov.dvsa.framework.config.webdriver.WebDriverConfigurator;

import java.io.IOException;

public class EventService extends Service {

    private static final String CREATE_EVENT_PATH = "/testsupport/event/create";

    public EventService() {
        super(WebDriverConfigurator.testSupportUrl());
    }

    /**
     *
     * @param event
     * @return ID of the created event
     * @throws IOException
     */
    public String createEvent(Event event) throws IOException {
        CreateEventRequest createEventRequest = new CreateEventRequest(event);
        String request = jsonHandler.convertToString(createEventRequest);
        Response response = motClient.postWithoutToken(request, CREATE_EVENT_PATH);
        return ServiceResponse.createResponse(response, String.class);
    }
}
