// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.shopping.merchant.lfp.v1beta;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";

option go_package = "cloud.google.com/go/shopping/merchant/lfp/apiv1beta/lfppb;lfppb";
option java_multiple_files = true;
option java_outer_classname = "LfpMerchantStateProto";
option java_package = "com.google.shopping.merchant.lfp.v1beta";

// Service for a [LFP
// partner](https://support.google.com/merchants/answer/7676652) to get the
// state of a merchant.
service LfpMerchantStateService {
  option (google.api.default_host) = "merchantapi.googleapis.com";
  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/content";

  // Gets the LFP state of a merchant
  rpc GetLfpMerchantState(GetLfpMerchantStateRequest)
      returns (LfpMerchantState) {
    option (google.api.http) = {
      get: "/lfp/v1beta/{name=accounts/*/lfpMerchantStates/*}"
    };
    option (google.api.method_signature) = "name";
  }
}

// The LFP state of a merchant.
message LfpMerchantState {
  option (google.api.resource) = {
    type: "merchantapi.googleapis.com/LfpMerchantState"
    pattern: "accounts/{account}/lfpMerchantStates/{lfp_merchant_state}"
    plural: "lfpMerchantStates"
    singular: "lfpMerchantState"
  };

  // The state of a specific merchant's store.
  message LfpStoreState {
    // The state of matching `LfpStore` to a Google Business Profile listing.
    enum StoreMatchingState {
      // Store matching state unspecified.
      STORE_MATCHING_STATE_UNSPECIFIED = 0;

      // The `LfpStore` is successfully matched with a Google Business Profile
      // store.
      STORE_MATCHING_STATE_MATCHED = 1;

      // The `LfpStore` is not matched with a Google Business Profile store.
      STORE_MATCHING_STATE_FAILED = 2;
    }

    // Required. Immutable. The identifier of this store.
    string store_code = 1 [
      (google.api.field_behavior) = REQUIRED,
      (google.api.field_behavior) = IMMUTABLE
    ];

    // Output only. The store matching state.
    StoreMatchingState matching_state = 2
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // The hint of why the matching has failed (only set if matching_state is
    // FAILED).
    string matching_state_hint = 3;
  }

  // The inventory statistics for a merchant.
  message InventoryStats {
    // Number of entries (understanding entry as a pair of product and store)
    // that were built based on provided inventories/sales and submitted to
    // Google.
    int64 submitted_entries = 1;

    // Number of submitted in stock entries.
    int64 submitted_in_stock_entries = 2;

    // Number of entries that were built based on provided
    // inventories/sales and couldn't be submitted to Google due to errors like
    // missing product.
    int64 unsubmitted_entries = 3;

    // Number of products from provided inventories/sales that were created from
    // matches to existing online products provided by the merchant or to the
    // Google catalog.
    int64 submitted_products = 4;
  }

  // Country-specific settings for the merchant.
  message CountrySettings {
    // The possible verification states for different merchant programs.
    enum VerificationState {
      // Verification state unspecified.
      VERIFICATION_STATE_UNSPECIFIED = 0;

      // Verification state not approved.
      VERIFICATION_STATE_NOT_APPROVED = 1;

      // Verification state in progress.
      VERIFICATION_STATE_IN_PROGRESS = 2;

      // Verification state approved.
      VERIFICATION_STATE_APPROVED = 3;
    }

    // The possible [product page
    // types](https://support.google.com/merchants/topic/15148370) for a
    // merchant.
    enum ProductPageType {
      // Product page type unspecified.
      PRODUCT_PAGE_TYPE_UNSPECIFIED = 0;

      // Google hosted product page.
      GOOGLE_HOSTED = 1;

      // Merchant hosted product page.
      MERCHANT_HOSTED = 2;

      // Merchant hosted store specific product page.
      MERCHANT_HOSTED_STORE_SPECIFIC = 3;
    }

    // Required. The [CLDR territory
    // code](https://github.com/unicode-org/cldr/blob/latest/common/main/en.xml)
    // for the country for which these settings are defined.
    string region_code = 1 [(google.api.field_behavior) = REQUIRED];

    // True if this merchant has enabled free local listings in MC.
    bool free_local_listings_enabled = 2;

    // True if this merchant has enabled local inventory ads in MC.
    bool local_inventory_ads_enabled = 3;

    // Output only. The verification state of this merchant's inventory check.
    VerificationState inventory_verification_state = 4
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The product page type selected by this merchant.
    ProductPageType product_page_type = 5
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The verification state of this merchant's instock serving
    // feature.
    VerificationState instock_serving_verification_state = 6
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The verification state of this merchant's pickup serving
    // feature.
    VerificationState pickup_serving_verification_state = 7
        [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Identifier. The name of the `LfpMerchantState` resource. Format:
  // `accounts/{account}/lfpMerchantStates/{target_merchant}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Number of [GBPs](https://www.google.com/business/) this merchant has access
  // to.
  int64 linked_gbps = 2;

  // Output only. The state per store from the specified merchant. The field
  // will be absent if the merchant has no stores submitted through LFP.
  repeated LfpStoreState store_states = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // The inventory statistics for the merchant. The field will be absent if the
  // merchant has no inventory submitted through LFP.
  InventoryStats inventory_stats = 4;

  // Country-specific settings for the merchant.
  repeated CountrySettings country_settings = 5;
}

// Request message for the GetLfpMerchantState method.
message GetLfpMerchantStateRequest {
  // Required. The name of the state to retrieve.
  // Format: `accounts/{account}/lfpMerchantStates/{target_merchant}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "merchantapi.googleapis.com/LfpMerchantState"
    }
  ];
}
