syntax = "proto3";

package profile_v1;

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";

option go_package = "gitlab.golang-school.ru/potok-2/lessons/lesson-24/gen/grpc/profile_v1";

service ProfileV1 {
  rpc CreateProfile(CreateProfileInput) returns (CreateProfileOutput);
  rpc GetProfile(GetProfileInput) returns (GetProfileOutput);
  rpc UpdateProfile(UpdateProfileInput) returns (google.protobuf.Empty);
  rpc DeleteProfile(DeleteProfileInput) returns (google.protobuf.Empty);
  rpc GetProfiles(GetProfilesInput) returns (GetProfilesOutput);
}

message GetProfilesInput {
  string sort = 1;
  optional string order = 2;
  optional int32 offset = 3;
  optional int32 limit = 4;
}

message GetProfilesOutput {
  repeated Profile profiles = 1;

  message Profile {
    string id = 1;
    google.protobuf.Timestamp created_at = 2;
    google.protobuf.Timestamp updated_at = 3;
    string name = 4;
    int32 age = 5;
    bool verified = 6;
    int32 status = 7;
    Contacts contacts = 8;

    message Contacts {
      string email = 1;
      string phone = 2;
    }
  }
}

message CreateProfileInput {
  string name = 1;
  int32 age = 2;
  string email = 3;
  string phone = 4;
}

message CreateProfileOutput {
  string id = 1;
}

message GetProfileInput {
  string id = 1;
}

message GetProfileOutput {
  string id = 1;
  google.protobuf.Timestamp created_at = 2;
  google.protobuf.Timestamp updated_at = 3;
  string name = 4;
  int32 age = 5;
  bool verified = 6;
  int32 status = 7;
  Contacts contacts = 8;

  message Contacts {
    string email = 1;
    string phone = 2;
  }
}

message UpdateProfileInput {
  string id = 1;
  optional string name = 2;
  optional int32 age = 3;
  optional string email = 4;
  optional string phone = 5;
  string idempotency_key = 6;
}

message DeleteProfileInput {
  string id = 1;
}