// 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.accounts.v1beta;

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

option go_package = "cloud.google.com/go/shopping/merchant/accounts/apiv1beta/accountspb;accountspb";
option java_multiple_files = true;
option java_outer_classname = "LfpProvidersProto";
option java_package = "com.google.shopping.merchant.accounts.v1beta";

// The service facilitates the management of a merchant's LFP provider settings.
// This API defines the following resource model:
// - [LfpProvider][google.shopping.merchant.accounts.v1.LfpProvider]
service LfpProvidersService {
  option (google.api.default_host) = "merchantapi.googleapis.com";
  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/content";

  // Find the LFP provider candidates in a given country.
  rpc FindLfpProviders(FindLfpProvidersRequest)
      returns (FindLfpProvidersResponse) {
    option (google.api.http) = {
      get: "/accounts/v1beta/{parent=accounts/*/omnichannelSettings/*}/lfpProviders:find"
    };
    option (google.api.method_signature) = "parent";
  }

  // Link the specified merchant to a LFP provider for the specified country.
  rpc LinkLfpProvider(LinkLfpProviderRequest)
      returns (LinkLfpProviderResponse) {
    option (google.api.http) = {
      post: "/accounts/v1beta/{name=accounts/*/omnichannelSettings/*/lfpProviders/*}:linkLfpProvider"
      body: "*"
    };
    option (google.api.method_signature) = "name";
  }
}

// Collection of information related to a Local Feed Partnership (LFP) provider.
message LfpProvider {
  option (google.api.resource) = {
    type: "merchantapi.googleapis.com/LfpProvider"
    pattern: "accounts/{account}/omnichannelSettings/{omnichannel_setting}/lfpProviders/{lfp_provider}"
    plural: "lfpProviders"
    singular: "lfpProvider"
  };

  // Identifier. The resource name of the LFP provider.
  // Format:
  // `accounts/{account}/omnichannelSettings/{omnichannel_setting}/lfpProviders/{lfp_provider}`
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. Region code defined by [CLDR](https://cldr.unicode.org/).
  string region_code = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The display name of the LFP provider.
  string display_name = 3;
}

// Request message for the FindLfpProviders method.
message FindLfpProvidersRequest {
  // Required. The name of the parent resource under which the LFP providers are
  // found. Format:
  // `accounts/{account}/omnichannelSettings/{omnichannel_setting}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "merchantapi.googleapis.com/OmnichannelSetting"
    }
  ];

  // Optional. The maximum number of `LfpProvider` resources to return. The
  // service returns fewer than this value if the number of lfp providers is
  // less that than the `pageSize`. The default value is 50. The maximum value
  // is 1000; If a value higher than the maximum is specified, then the
  // `pageSize` will default to the maximum.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous `FindLfpProviders` call.
  // Provide the page token to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to `FindLfpProviders` must
  // match the call that provided the page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for the FindLfpProviders method.
message FindLfpProvidersResponse {
  // The LFP providers from the specified merchant in the specified country.
  repeated LfpProvider lfp_providers = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// Request message for the LinkLfpProvider method.
message LinkLfpProviderRequest {
  // Required. The name of the LFP provider resource to link.
  // Format:
  // `accounts/{account}/omnichannelSettings/{omnichannel_setting}/lfpProviders/{lfp_provider}`.
  // The `lfp_provider` is the LFP provider ID.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "merchantapi.googleapis.com/LfpProvider"
    }
  ];

  // Required. The external account ID by which this merchant is known to the
  // LFP provider.
  string external_account_id = 2 [(google.api.field_behavior) = REQUIRED];
}

// Response message for the LinkLfpProvider method.
message LinkLfpProviderResponse {
  // Empty response.
  google.protobuf.Empty response = 1;
}
