syntax = "proto3";

package addresses;

service AddressesService {
  rpc ListAddresses (ListAddressesRequest) returns (ListAddressesResponse);
  rpc UpsertAddress (UpsertAddressRequest) returns (UserAddress);
  rpc DeleteAddress (AddressIdRequest) returns (MutationResponse);
}

message ListAddressesRequest {
  string userId = 1;
}

message AddressIdRequest {
  string addressId = 1;
  string userId = 2;
}

message UpsertAddressRequest {
  string userId = 1;
  optional string addressId = 2;
  string label = 3;
  string city = 4;
  string street = 5;
  string house = 6;
  optional string apartment = 7;
  optional string comment = 8;
  optional double latitude = 9;
  optional double longitude = 10;
  optional string fullAddress = 11;
}

message UserAddress {
  string id = 1;
  string userId = 2;
  string label = 3;
  string city = 4;
  string street = 5;
  string house = 6;
  optional string apartment = 7;
  optional string comment = 8;
  optional double latitude = 9;
  optional double longitude = 10;
  optional string fullAddress = 11;
  string createdAt = 12;
  string updatedAt = 13;
}

message ListAddressesResponse {
  repeated UserAddress addresses = 1;
}

message MutationResponse {
  int32 count = 1;
}
