syntax = "proto3";
package journey.v1;

import "google/protobuf/timestamp.proto";

//==================================
//========== primitives ============
//==================================
message ID {
  string id = 1;
}

message Title {
  string content = 1;
}

message Body {
  string content = 1;
}

message Entry {
  ID id = 1;
  google.protobuf.Timestamp time_created = 2;
  Title title = 3;
  Body body = 4;
}
message TimeRange {
  bool has_start = 1;
  google.protobuf.Timestamp start = 2;
  bool has_end = 3;
  google.protobuf.Timestamp end = 4;
}

message EntryFilter {
  repeated TimeRange by_time_created = 1;
  repeated TimeRange by_time_updated = 2;
}
enum EntrySortInfo {
  UNSPECIFIED = 0;
  CREATED = 1;
  UPDATED = 2;
}
message EntrySort {
  bool assending = 1;
  EntrySortInfo by = 2;
}

//==================================
//======= request / responses ======
//==================================

//
// CreateEntry
//

message CreateEntryRequest {
  Title entry_title = 1;
  Body body = 4;
}

message CreateEntryResponse {}

message GetEntriesRequest {
  uint32 number = 1;
  EntrySort sorted_by = 2;
  repeated EntryFilter filtered_by = 3;
}

message GetEntriesResponse {
  repeated Entry entries = 1;
}

//==================================
//========== services ==============
//==================================

service JourneyService {
  rpc CreateEntry(CreateEntryRequest) returns (CreateEntryResponse) {}
  rpc GetEntries(GetEntriesRequest) returns (GetEntriesResponse) {}
}
