syntax = "proto3";
// flynt-disable package-matches-structure

package com.wixpress.appservice.api.upstream.wix.billing.spi.v1;
option java_package = "com.wixpress.appservice.api.upstream.wix.billing.spi.v1";

import "google/api/annotations.proto";
import "wix/api/entity.proto";
import "wix/api/validations.proto";
import "wix/spi/definitions.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";
import "wix/common/spi.proto";

message TaxExemptGroupsProviderConfig {
    option (.wix.api.decomposite_of) = "wix.billing.spi.v1.TaxExemptGroupsProviderConfig";
  // Base URI of the service plugin implementation. Since no endpoint is calling this path, it may be left blank.
  .wix.common.spi.SpiBaseUri deployment_uri = 1;
  reserved 2,3;
  repeated TaxExemptGroup tax_exempt_groups = 4 [(.wix.api.minSize) = 0, (.wix.api.maxSize) = 100];
}


message TaxExemptGroup {
    option (.wix.api.decomposite_of) = "wix.billing.spi.v1.TaxExemptGroup";
  // Name of the exempt tax group.
  string exempt_tax_group_name = 1 [(.wix.api.translatable) = {
    type: SHORT_TEXT
    name: "Exempt tax group name"
    grouping: "Exempt tax group name"
  }, (.wix.api.maxLength) = 100];

  // Unique tax exempt group ID.
  string id = 2 [(.wix.api.format) = GUID];

  // Supported exempt regions
  // Contacts that are buying in those regions will be exempt from paying taxes.
  ExemptRegions exempt_regions = 3;
}

// The exempt regions could apply automatically to all regions or to specific regions.
message ExemptRegions {
    option (.wix.api.decomposite_of) = "wix.billing.spi.v1.ExemptRegions";
  // Scope of regions, when worldwide is selected, the regions list will be empty.
  RegionScopeScope region_scope = 1;

  // The list of exempt regions, if specific regions scope is used.
  repeated Region regions = 2 [(.wix.api.minSize) = 0, (.wix.api.maxSize) = 200];
}

message Region {
    option (.wix.api.decomposite_of) = "wix.billing.spi.v1.Region";
  // 2-letters code.
  string country_code = 1 [(.wix.api.format) = COUNTRY];

  // subdivisions - Usually a state, region, prefecture, or province code, according to [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2).
  // If empty, the rule applies to the entire region.
  repeated string subdivisions = 2 [(.wix.api.minSize) = 0, (.wix.api.maxSize) = 100, (.wix.api.minLength) = 1, (.wix.api.maxLength) = 50];
}

enum RegionScopeScope {
  // Specific regions where tax exempt is applicable.
  SPECIFIC_REGIONS = 0;
  // Tax exempt is applicable to all regions, no need to specify them.
  WORLDWIDE = 1;
}

