syntax = "proto3";

package usercarts;

import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/duration.proto";  
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";

option csharp_namespace = "CMSMicroservice.Protobuf.Protos.UserCarts";

service UserCartsContract
{
    rpc CreateNewUserCarts(CreateNewUserCartsRequest) returns (CreateNewUserCartsResponse){
        option (google.api.http) = {
            post: "/CreateNewUserCarts"
            body: "*"
        };
    };
    rpc UpdateUserCarts(UpdateUserCartsRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            put: "/UpdateUserCarts"
            body: "*"
        };
    };
    rpc DeleteUserCarts(DeleteUserCartsRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            delete: "/DeleteUserCarts"
            body: "*"
        };
    };
    rpc GetUserCarts(GetUserCartsRequest) returns (GetUserCartsResponse){
        option (google.api.http) = {
            get: "/GetUserCarts"
            
        };
    };
    rpc GetAllUserCartsByFilter(GetAllUserCartsByFilterRequest) returns (GetAllUserCartsByFilterResponse){
        option (google.api.http) = {
            get: "/GetAllUserCartsByFilter"
            
        };
    };
    rpc ClearCart(ClearCartRequest) returns (ClearCartResponse){
        option (google.api.http) = {
            post: "/ClearCart"
            body: "*"
        };
    };
}
message CreateNewUserCartsRequest
{
    int64 product_id = 1;
    int64 user_id = 2;
    int32 count = 3;
}
message CreateNewUserCartsResponse
{
    int64 id = 1;
}
message UpdateUserCartsRequest
{
    int64 id = 1;
    int32 count = 2;
}
message DeleteUserCartsRequest
{
    int64 id = 1;
}
message GetUserCartsRequest
{
    int64 id = 1;
}
message GetUserCartsResponse
{
    int64 id = 1;
    int64 product_id = 2;
    int64 user_id = 3;
    int32 count = 4;
}
message GetAllUserCartsByFilterRequest
{
    messages.PaginationState pagination_state = 1;
    google.protobuf.StringValue sort_by = 2;
    GetAllUserCartsByFilterFilter filter = 3;
}
message GetAllUserCartsByFilterFilter
{
    google.protobuf.Int64Value id = 1;
    google.protobuf.Int64Value product_id = 2;
    google.protobuf.Int64Value user_id = 3;
    google.protobuf.Int32Value count = 4;
}
message GetAllUserCartsByFilterResponse
{
    messages.MetaData meta_data = 1;
    repeated GetAllUserCartsByFilterResponseModel models = 2;
}
message GetAllUserCartsByFilterResponseModel
{
    int64 id = 1;
    int64 product_id = 2;
    int64 user_id = 3;
    int32 count = 4;
    string product_title = 5;
    string product_short_infomation = 6;
    int64 product_price = 7;
    int32 product_discount = 8;
    string product_thumbnail_path = 9;
    google.protobuf.Timestamp created = 10;
}

// ClearCart Messages
message ClearCartRequest
{
    int64 user_id = 1;
}

message ClearCartResponse
{
    int64 user_id = 1;
    int32 removed_items_count = 2;
    string message = 3;
}
