syntax = "proto3";

package com.wixpress.appservice.api.upstream.wix.forms.v4;
option java_package = "com.wixpress.appservice.api.upstream.wix.forms.v4";

import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";

message PaymentType {
    option (.wix.api.decomposite_of) = "wix.forms.v4.PaymentType";
  // Field mapped to products.
  repeated Product products = 1 [(.wix.api.minSize) = 1, (.wix.api.maxSize) = 100];
  // Minimum amount of different products.
  google.protobuf.Int32Value min_items = 2 [(.wix.api.min) = 0, (.wix.api.max) = 100];
  // Maximum amount of different products.
  google.protobuf.Int32Value max_items = 3 [(.wix.api.min) = 0, (.wix.api.max) = 100];

  message Product {
        option (.wix.api.decomposite_of) = "wix.forms.v4.PaymentType.Product";
    // Product ID.
    string id = 1 [(.wix.api.format) = GUID, (.wix.api.readOnly) = true];
    // Product type.
    ProductTypeEnum.ProductType product_type = 2;
    // Price type.
    PriceTypeEnum.PriceType price_type = 3;
    // Quantity limit.
    QuantityLimit quantity_limit = 4;

    oneof price_options {
      option (.wix.api.aligned_with_enum).field = "price_type";
      // Fixed price options.
      FixedPriceOptions fixed_price_options = 5;
      // Dynamic price options.
      DynamicPriceOptions dynamic_price_options = 6;
    }

    message PriceTypeEnum {
        option (.wix.api.decomposite_of) = "wix.forms.v4.PaymentType.PriceTypeEnum";
      enum PriceType {
        UNKNOWN = 0;
        // Fixed price.
        FIXED_PRICE = 1;
        // Dynamic price from price range.
        DYNAMIC_PRICE = 2;
      }
    }

    message ProductTypeEnum {
    option (.wix.api.decomposite_of) = "wix.forms.v4.ProductTypeEnum";
      enum ProductType {
        UNKNOWN = 0;
        // Shippable (physical).
        SHIPPABLE = 1;
        // Digital.
        DIGITAL = 2;
      }
    }

    message FixedPriceOptions {
    option (.wix.api.decomposite_of) = "wix.forms.v4.FixedPriceOptions";
      // Fixed price monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99).
      string price = 1 [(.wix.api.decimalValue) = {gte: "0.00", maxScale: 2}];
    }

    message DynamicPriceOptions {
    option (.wix.api.decomposite_of) = "wix.forms.v4.DynamicPriceOptions";
      // Minimal price monetary amount.
      string min_price = 1 [(.wix.api.decimalValue) = {gte: "0.00", maxScale: 2}];
      // Maximal price monetary amount.
      google.protobuf.StringValue max_price = 2 [(.wix.api.decimalValue) = {gte: "0.00", maxScale: 2}];
    }

    message QuantityLimit {
    option (.wix.api.decomposite_of) = "wix.forms.v4.QuantityLimit";
      // Minimum quantity.
      google.protobuf.Int32Value minimum = 1 [(.wix.api.min) = 1, (.wix.api.max) = 100000];
      // Maximum quantity.
      google.protobuf.Int32Value maximum = 2 [(.wix.api.min) = 1, (.wix.api.max) = 100000];
    }
  }
}
