Solution: customer.proto

 avatar
unknown
protobuf
4 years ago
1.9 kB
46
Indexable
syntax = "proto3";

package appointy.customers.v1;

import "google/protobuf/empty.proto";

option go_package = "generated/customers";

// Customers service handles creation and management of customers.
service Customers {

    // creates a customer in database with input details
    rpc CreateCustomer (CreateCustomerRequest) returns (Customer);

    // gets details of customer corresponding to it unique id
    rpc GetCustomer (GetCustomerRequest) returns (Customer);

    // gets details of customer corresponding to it unique email
    rpc GetCustomerByEmail (GetCustomerEmailRequest) returns (Customer);

    // updates details of customer corresponding to it unique id
    rpc UpdateCustomer (UpdateCustomerRequest) returns (Customer);

    // deletes a customer using its uniquely identified id
    rpc DeleteCustomer (DeleteCustomerRequest) returns (.google.protobuf.Empty);

    // search for all customers by details
    rpc SearchCustomers (SearchCustomersRequest) returns (SearchCustomersResponse);
}

message Customer {

    // unique identifier of customer
    string id = 1;

    // details of customer
    string first_name = 2;
    string last_name = 3;
    string email = 4;
    string phone_number = 5;

    // ...
}

message CreateCustomerRequest {
    Customer customer = 1;
    // ...
}

message GetCustomerRequest {
    string id = 1;
}

message GetCustomerEmailRequest{
    string email = 1;
}

message UpdateCustomerRequest {
    Customer customer = 1;
    // ...
}

message DeleteCustomerRequest {
    string id = 1;
}

message SearchCustomersRequest {
    // for empty value in fields, condition will be skipped
    string first_name = 1;
    string last_name = 2;
    string email = 3;
    string phone_number = 4;
}

message SearchCustomersResponse {
    repeated Customer customers = 1;
}

// CMD to generate go-code: protoc -I=. --go_out=plugins=grpc:. ./customer.proto
Editor is loading...