com.teststeps.thekla4j.http.spp.abilities.UseTheRestApi Maven / Gradle / Ivy
package com.teststeps.thekla4j.http.spp.abilities;
import com.teststeps.thekla4j.core.base.abilities.Ability;
import com.teststeps.thekla4j.core.base.persona.UsesAbilities;
import com.teststeps.thekla4j.http.core.HttpClient;
import com.teststeps.thekla4j.http.core.HttpRequest;
import com.teststeps.thekla4j.http.spp.Request;
import com.teststeps.thekla4j.http.spp.HttpOptions;
import io.vavr.control.Either;
import io.vavr.control.Try;
public class UseTheRestApi implements Ability {
private HttpClient httpClient;
public static Try as(UsesAbilities actor) {
return Try.of(() -> (UseTheRestApi)actor.withAbilityTo(UseTheRestApi.class));
}
public static UseTheRestApi with(HttpClient httpClient) {
return new UseTheRestApi(httpClient);
}
public Either send(Request spe, HttpOptions activityOptions) {
return this.httpClient.request(spe, activityOptions);
}
private UseTheRestApi(HttpClient httpClient) {
this.httpClient = httpClient;
}
@Override
public void destroy() {
httpClient.destroy();
}
}