All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.tools.horreum.mapper.UserApiKeyMapper Maven / Gradle / Ivy

The newest version!
package io.hyperfoil.tools.horreum.mapper;

import java.time.Instant;

import io.hyperfoil.tools.horreum.api.services.UserService;
import io.hyperfoil.tools.horreum.entity.user.UserApiKey;

public class UserApiKeyMapper {

    public static UserApiKey from(UserService.ApiKeyRequest request, Instant creation, long valid) {
        return new UserApiKey(request.name == null ? "" : request.name, request.type, creation, valid);
    }

    public static UserService.ApiKeyResponse to(UserApiKey key) {
        UserService.ApiKeyResponse response = new UserService.ApiKeyResponse();
        response.id = key.id;
        response.name = key.name;
        response.type = key.type;
        response.creation = key.creation;
        response.access = key.access;
        response.isRevoked = key.revoked;
        response.toExpiration = key.toExpiration(Instant.now());
        return response;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy