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

com.geotab.http.request.AuthenticatedRequest Maven / Gradle / Ivy

/*
 *
 * 2020 Copyright (C) Geotab Inc. All rights reserved.
 */

package com.geotab.http.request;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.geotab.http.request.param.AuthenticatedParameters;
import com.geotab.model.login.Credentials;
import java.util.Optional;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class AuthenticatedRequest extends BaseRequest {

  protected AuthenticatedRequest() {
    // for serialization purpose
  }

  @Builder(builderMethodName = "authRequestBuilder")
  public AuthenticatedRequest(Integer id, String method, T params) {
    super(id, method, params);
  }

  @JsonIgnore
  public Optional getCredentials() {
    if (params == null) {
      Optional.empty();
    }
    return Optional.ofNullable(params.getCredentials());
  }

  @JsonIgnore
  public void setCredentials(Credentials credentials) {
    if (params != null) {
      params.setCredentials(credentials);
    }
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy