99 lines
3.3 KiB
Java
99 lines
3.3 KiB
Java
/**
|
|
* Auto-generated from apibuilder.io service spec.
|
|
* apidoc-version : 0.15.4
|
|
* organisation : nclazz
|
|
* service-version : 0.0.0-dev-30-gbd50cdf-bd9390b2-staging
|
|
*
|
|
* Documentation at:
|
|
* <a href="https://app.apibuilder.io/nclazz/users/0.0.0-dev-30-gbd50cdf-bd9390b2-staging">https://app.apibuilder.io/nclazz/users/0.0.0-dev-30-gbd50cdf-bd9390b2-staging</a>
|
|
*
|
|
**/
|
|
package de.nclazz.users.v0.client;
|
|
|
|
import de.nclazz.users.v0.client.UsersApiClientConfig;
|
|
import de.nclazz.users.v0.models.*;
|
|
|
|
import de.nclazz.users.v0.models.UserLoginForm;
|
|
import de.nclazz.users.v0.models.UserLogin;
|
|
|
|
import lombok.*;
|
|
|
|
import javax.ws.rs.client.Entity;
|
|
import javax.ws.rs.client.WebTarget;
|
|
import javax.ws.rs.core.*;
|
|
import java.net.URI;
|
|
|
|
|
|
/**
|
|
* Client for API resource de.nclazz.users.v0.UserLoginsResource
|
|
* version 0.0.0-dev-30-gbd50cdf-bd9390b2-staging
|
|
*
|
|
* Resource for authenticating users.
|
|
**/
|
|
@RequiredArgsConstructor
|
|
public class UserLoginsResource {
|
|
|
|
private final UsersApiClientConfig config;
|
|
|
|
/** Login user with username + password. **/
|
|
public PostUserLoginForm postUserLoginForm () {
|
|
return new PostUserLoginForm(this.config);
|
|
}
|
|
|
|
/**
|
|
* Login user with username + password.
|
|
**/
|
|
public static class PostUserLoginForm {
|
|
|
|
private final UsersApiClientConfig config;
|
|
|
|
public PostUserLoginForm(@NonNull final UsersApiClientConfig config) {
|
|
this.config = config;
|
|
}
|
|
|
|
public PostUserLoginFormResponse request(@NonNull UserLoginForm userLoginForm) {
|
|
// /login/
|
|
final URI uri = UriBuilder.fromUri(this.config.getBaseUrl())
|
|
.path("login")
|
|
.build();
|
|
|
|
WebTarget target = config.getClient().target(uri);
|
|
Response response = target.request(MediaType.APPLICATION_JSON)
|
|
.method("POST", Entity.json(userLoginForm));
|
|
int status = response.getStatus();
|
|
switch(status) {
|
|
case 200:
|
|
|
|
UserLogin userLogin200Resp = response.readEntity(UserLogin.class);
|
|
return PostUserLoginFormResponse.builder()
|
|
.status(status)
|
|
.headers(response.getHeaders())
|
|
.userLogin200(userLogin200Resp)
|
|
.build();
|
|
case 401:
|
|
return PostUserLoginFormResponse.builder()
|
|
.status(status)
|
|
.headers(response.getHeaders())
|
|
.build();
|
|
default:
|
|
return PostUserLoginFormResponse.builder()
|
|
.status(status)
|
|
.unexpected(response.readEntity(String.class))
|
|
.build();
|
|
}
|
|
}
|
|
|
|
|
|
@Builder
|
|
@Data
|
|
public static class PostUserLoginFormResponse {
|
|
private UserLogin userLogin200;
|
|
|
|
private final int status;
|
|
private final MultivaluedMap<String, Object> headers;
|
|
private final String unexpected;
|
|
}
|
|
}
|
|
|
|
|
|
} |