syntax = "proto3";

package userpackagepurchase;

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

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

service UserPackagePurchaseContract
{
    rpc GetAllUserPackagePurchaseByFilter(GetAllUserPackagePurchaseByFilterRequest) returns (GetAllUserPackagePurchaseByFilterResponse){
        option (google.api.http) = {
            get: "/UserPackagePurchase/GetAllByFilter"
        };
    };
    rpc GetUserPackagePurchaseSummary(GetUserPackagePurchaseSummaryRequest) returns (GetUserPackagePurchaseSummaryResponse){
        option (google.api.http) = {
            get: "/UserPackagePurchase/GetSummary"
        };
    };
    rpc GetCustomerPackagePurchaseRollup(GetCustomerPackagePurchaseRollupRequest) returns (GetCustomerPackagePurchaseRollupResponse){
        option (google.api.http) = {
            get: "/UserPackagePurchase/GetCustomerRollup"
        };
    };
}

message GetAllUserPackagePurchaseByFilterRequest
{
    messages.PaginationState pagination_state = 1;
    google.protobuf.StringValue sort_by = 2;
    GetAllUserPackagePurchaseByFilterFilter filter = 3;
}

message GetAllUserPackagePurchaseByFilterFilter
{
    google.protobuf.Int64Value user_id = 1;
    google.protobuf.Int64Value package_id = 2;
    google.protobuf.Int32Value purchase_method = 3;
    google.protobuf.Timestamp purchased_from = 4;
    google.protobuf.Timestamp purchased_to = 5;
    google.protobuf.Int64Value min_amount = 6;
    google.protobuf.Int64Value max_amount = 7;
}

message GetAllUserPackagePurchaseByFilterResponse
{
    messages.MetaData meta_data = 1;
    repeated UserPackagePurchaseModel models = 2;
}

message UserPackagePurchaseModel
{
    int64 id = 1;
    int64 user_id = 2;
    string user_name = 3;
    string user_mobile = 4;
    int64 package_id = 5;
    string package_name = 6;
    int32 purchase_method = 7;
    google.protobuf.Timestamp purchased_at = 8;
    int64 amount = 9;
    google.protobuf.Int64Value order_id = 10;
    google.protobuf.Int64Value transaction_id = 11;
    google.protobuf.Timestamp created_at = 12;
}

message GetUserPackagePurchaseSummaryRequest
{
    GetAllUserPackagePurchaseByFilterFilter filter = 1;
}

message GetUserPackagePurchaseSummaryResponse
{
    int64 total_count = 1;
    int64 total_amount = 2;
}

message GetCustomerPackagePurchaseRollupRequest
{
    messages.PaginationState pagination_state = 1;
    GetCustomerPackagePurchaseRollupFilter filter = 2;
}

message GetCustomerPackagePurchaseRollupFilter
{
    google.protobuf.Int64Value user_id = 1;
    google.protobuf.Int32Value purchase_method = 2;
    google.protobuf.Timestamp purchased_from = 3;
    google.protobuf.Timestamp purchased_to = 4;
}

message GetCustomerPackagePurchaseRollupResponse
{
    messages.MetaData meta_data = 1;
    repeated CustomerPackagePurchaseRollupModel models = 2;
}

message CustomerPackagePurchaseRollupModel
{
    int64 user_id = 1;
    string user_name = 2;
    string user_mobile = 3;

    int64 first_package_id = 4;
    string first_package_name = 5;
    int64 first_amount = 6;
    google.protobuf.Timestamp first_purchased_at = 7;

    int64 last_package_id = 8;
    string last_package_name = 9;
    int64 last_amount = 10;
    google.protobuf.Timestamp last_purchased_at = 11;
    int32 last_purchase_method = 12;

    int32 purchase_count = 13;
    int64 total_amount = 14;

    int32 daya_count = 15;
    int64 daya_amount = 16;
    int32 manual_count = 17;
    int64 manual_amount = 18;
    int32 gateway_count = 19;
    int64 gateway_amount = 20;
}
