syntax = "proto3";

package clubmembershipcycle;

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.ClubMembershipCycle";

service ClubMembershipCycleContract
{
    rpc GetAllClubMembershipCycleByFilter(GetAllClubMembershipCycleByFilterRequest) returns (GetAllClubMembershipCycleByFilterResponse){
        option (google.api.http) = {
            get: "/ClubMembershipCycle/GetAllByFilter"
        };
    };
    rpc GetClubMembershipCycleSummary(GetClubMembershipCycleSummaryRequest) returns (GetClubMembershipCycleSummaryResponse){
        option (google.api.http) = {
            get: "/ClubMembershipCycle/GetSummary"
        };
    };
}

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

message GetAllClubMembershipCycleByFilterFilter
{
    google.protobuf.Int64Value user_id = 1;
    google.protobuf.BoolValue is_current_cycle = 2;
    google.protobuf.Int64Value package_id = 3;
    google.protobuf.Int32Value cycle_number = 4;
    google.protobuf.Int32Value purchase_method = 5;
    google.protobuf.Int32Value magic_state = 6; // 0=none, 1=active, 2=completed
    google.protobuf.Timestamp package_purchased_from = 7;
    google.protobuf.Timestamp package_purchased_to = 8;
}

message GetAllClubMembershipCycleByFilterResponse
{
    messages.MetaData meta_data = 1;
    repeated ClubMembershipCycleModel models = 2;
}

message ClubMembershipCycleModel
{
    int64 id = 1;
    int64 user_id = 2;
    string user_name = 3;
    int64 club_membership_id = 4;
    int32 cycle_number = 5;
    int64 package_id = 6;
    string package_name = 7;
    int64 package_amount = 8;
    int32 purchase_method = 9;
    google.protobuf.Timestamp package_purchased_at = 10;
    google.protobuf.Timestamp magic_started_at = 11;
    google.protobuf.Timestamp magic_completed_at = 12;
    bool is_current_cycle = 13;
    google.protobuf.Timestamp created_at = 14;
}

message GetClubMembershipCycleSummaryRequest
{
    GetAllClubMembershipCycleByFilterFilter filter = 1;
}

message GetClubMembershipCycleSummaryResponse
{
    int64 total_count = 1;
    int64 current_cycle_count = 2;
    int64 magic_active_count = 3;
}
