syntax = "proto3";

package com.wix.ecommerce.catalog_spi.api.v1;

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";
import "wix/payment/api/pay/v2/resources/subscription.proto";
import "google/protobuf/timestamp.proto";

message SubscriptionOptionInfo {

    // Subscription option settings.
    SubscriptionSettings subscription_settings = 1;

    // Subscription option title.
    Title title = 2;

    // Subscription option description.
    Description description = 3;
}

message SubscriptionSettings {

    // Frequency of recurring payment.
    .wix.payment.api.pay.v2.SubscriptionFrequency frequency = 1;

    // Interval of recurring payment.
    //
    // Default: `1`.
    // If SubscriptionFrequency is Day the minimum interval is 7
    google.protobuf.Int32Value interval = 2 [(.wix.api.min) = 1, (.wix.api.max) = 3650];

    // Whether subscription is renewed automatically at the end of each period.
    bool auto_renewal = 3;

    // Number of billing cycles before subscription ends. Ignored if `autoRenewal` is `true`.
    google.protobuf.Int32Value billing_cycles = 4 [(.wix.api.min) = 1];

    // Whether to allow the customer to cancel the subscription..
    bool enable_customer_cancellation = 5 [(.wix.api.field_maturity) = BETA];

    //Period until first cycle starts. If applied payNow will be 0
    // If None => no free trial
    FreeTrialPeriod free_trial_period = 6 [(.wix.api.field_maturity) = BETA];

    //The date the subscription will start. The subscription will be charged either now or according to freeTrialDays.
    google.protobuf.Timestamp start_date = 7 [(.wix.api.field_maturity) = ALPHA];
    
    reserved 8;
}

message FreeTrialPeriod {
    // Frequency of period. Values: DAY, WEEK, MONTH, YEAR
    .wix.payment.api.pay.v2.SubscriptionFrequency frequency = 1;
    // interval of period 
    int32 interval = 2 [(.wix.api.min) = 1, (.wix.api.max) = 999];
}

message Title {

    // Subscription option name in the site's default language as defined in the [request envelope](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions#request-envelope).
    string original = 1 [(.wix.api.minLength) = 1, (.wix.api.maxLength) = 150];

    // Subscription option name translated into the buyer's language.
    // 
    // Default: Same as `original`.
    google.protobuf.StringValue translated = 2 [(.wix.api.minLength) = 1, (.wix.api.maxLength) = 150];
}

message Description {

    // Subscription option description.
    string original = 1 [(.wix.api.maxLength) = 500];
    
    // Translated subscription option description.
    google.protobuf.StringValue translated = 2 [(.wix.api.maxLength) = 500];
}