syntax = "proto3";
package customer;
import "google/protobuf/empty.proto";

service Customer {
  // Create new customer
  rpc CreateNew(NewCustomerObj) returns (CustomerObj);
  // Get all customers (as stream)
  rpc GetAll(google.protobuf.Empty) returns (CustomerIds);
  // Get customer by id
  rpc GetById(GetByIdRequest) returns (CustomerObj);
  // Get customers in bulk
  rpc GetBulk(GetBulkRequest) returns (stream CustomerObj);
  // Update customer by id
  rpc UpdateById(UpdateByIdRequest) returns (CustomerObj);
  // Find customer by query
  rpc FindCustomer(FindCustomerRequest) returns (CustomerIds);
}

message e {}

message GetBulkRequest { repeated uint32 customer_ids = 1; }

message FindCustomerRequest { string query = 1; }

message CustomerId { uint32 customer_id = 1; }

message CustomerIds { repeated uint32 customer_ids = 1; }

message CustomerObj {
  uint32 id = 1;
  string name = 2;
  string email = 3;
  string phone = 4;
  string tax_number = 5;
  string address_zip = 6;
  string address_location = 7;
  string address_street = 8;
  string date_created = 9;
  uint32 created_by = 10;
}

message CustomerUpdateObj {
  uint32 id = 1;
  string name = 2;
  string email = 3;
  string phone = 4;
  string address_zip = 5;
  string address_location = 6;
  string address_street = 7;
  string tax_number = 8;
}

message NewCustomerObj {
  string name = 1;
  string email = 2;
  string phone = 3;
  string tax_number = 4;
  string address_zip = 5;
  string address_location = 6;
  string address_street = 7;
  uint32 created_by = 8;
}

message GetByIdRequest { uint32 customer_id = 1; }

message UpdateByIdRequest {
  uint32 customer_id = 1;
  CustomerUpdateObj customer = 2;
}

message AddUserRequest {
  uint32 customer_id = 1;
  uint32 user_id = 2;
}

message RemoveUserRequest {
  uint32 customer_id = 1;
  uint32 user_id = 2;
}