/*
 * (c) 2023 Pluto Inc.
 */
package tv.pluto.grpc.timelines_past;

import io.grpc.Channel;
import java.util.List;
import java.util.logging.Logger;
import tv.pluto.grpc.GenericGrpcClient;
import tv.pluto.ip.dal.timelinespast.TimelinesPast;
import tv.pluto.ip.dal.timelinespast.TimelinesPastManagerGrpc;

/** Class represents gRPC client for <b>timelines-past.proto</b> file */
public class TimelinesPastClient extends GenericGrpcClient {
  private static final Logger logger = Logger.getLogger(TimelinesPastClient.class.getName());

  private TimelinesPastManagerGrpc.TimelinesPastManagerBlockingStub blockingStub;

  public TimelinesPastClient(Channel channel) {
    blockingStub = TimelinesPastManagerGrpc.newBlockingStub(channel);
    blockingStub = blockingStub.withInterceptors(CLIENT_INTERCEPTOR);
  }

  public TimelinesPast.FindByIdAndUpsertResponse getFindByIdAndUpsert(
      String id, TimelinesPast.TimelinePast timelinepast, List<String> values) {
    TimelinesPast.FindByIdAndUpsertRequest request =
        TimelinesPast.FindByIdAndUpsertRequest.newBuilder()
            .setId(id)
            .setDocument(timelinepast)
            .addAllUpdateFields(values)
            .build();
    return blockingStub.findByIdAndUpsert(request);
  }
}
