// Copyright 2021 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.ads.googleads.v8.services;

import "google/ads/googleads/v8/common/criteria.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/api/client.proto";

option csharp_namespace = "Google.Ads.GoogleAds.V8.Services";
option go_package = "google.golang.org/genproto/googleapis/ads/googleads/v8/services;services";
option java_multiple_files = true;
option java_outer_classname = "SmartCampaignSuggestServiceProto";
option java_package = "com.google.ads.googleads.v8.services";
option objc_class_prefix = "GAA";
option php_namespace = "Google\\Ads\\GoogleAds\\V8\\Services";
option ruby_package = "Google::Ads::GoogleAds::V8::Services";

// Service to get suggestions for Smart Campaigns.
service SmartCampaignSuggestService {
  option (google.api.default_host) = "googleads.googleapis.com";
  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/adwords";

  // Returns BudgetOption suggestions.
  rpc SuggestSmartCampaignBudgetOptions(SuggestSmartCampaignBudgetOptionsRequest) returns (SuggestSmartCampaignBudgetOptionsResponse) {
    option (google.api.http) = {
      post: "/v8/customers/{customer_id=*}:suggestSmartCampaignBudgetOptions"
      body: "*"
    };
  }
}

// Request message for
// [SmartCampaignBudgetSuggestService.SuggestSmartCampaignBudgets][].
message SuggestSmartCampaignBudgetOptionsRequest {
  // Required. The ID of the customer whose budget options are to be suggested.
  string customer_id = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. For first time campaign creation use SuggestionInfo, for
  // subsequent updates on BudgetOptions based on an already created campaign
  // use that campaign.
  oneof suggestion_data {
    // Required. The resource name of the campaign to get suggestion for.
    string campaign = 2 [
      (google.api.field_behavior) = REQUIRED,
      (google.api.resource_reference) = {
        type: "googleads.googleapis.com/Campaign"
      }
    ];

    // Required. Information needed to get budget options
    SmartCampaignSuggestionInfo suggestion_info = 3 [(google.api.field_behavior) = REQUIRED];
  }
}

// Information needed to get suggestion for Smart Campaign. More information
// provided will help the system to derive better suggestions.
message SmartCampaignSuggestionInfo {
  // A list of locations.
  message LocationList {
    // Required. Locations.
    repeated google.ads.googleads.v8.common.LocationInfo locations = 1 [(google.api.field_behavior) = REQUIRED];
  }

  // Optional. Landing page URL of the campaign.
  string final_url = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The ID of the Google My Business (GMB) Location.
  // The location ID can be fetched by GMB API with its form:
  // accounts/{accountId}/locations/{locationId}. The last {locationId}
  // component from the GMB API represents the business_location_id.
  // See the [Google My Business API]
  // (https://developers.google.com/my-business/reference/rest/v4/accounts.locations)
  int64 business_location_id = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The two letter advertising language for the Smart campaign to be
  // constructed, default to 'en' if not set.
  string language_code = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The business ad schedule.
  repeated google.ads.googleads.v8.common.AdScheduleInfo ad_schedules = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Smart campaign keyword themes. This field may greatly improve suggestion
  // accuracy and we recommend always setting it if possible.
  repeated google.ads.googleads.v8.common.KeywordThemeInfo keyword_themes = 7 [(google.api.field_behavior) = OPTIONAL];

  // The geo target of the campaign, either a list of locations or
  // a single proximity shall be specified.
  oneof geo_target {
    // Optional. The targeting geo location by locations.
    LocationList location_list = 4 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The targeting geo location by proximity.
    google.ads.googleads.v8.common.ProximityInfo proximity = 5 [(google.api.field_behavior) = OPTIONAL];
  }
}

// Response message for
// [SmartCampaignBudgetSuggestService.SuggestSmartCampaignBudgets][]. Depending
// on whether the system could suggest the options, either all of the options or
// none of them might be returned.
message SuggestSmartCampaignBudgetOptionsResponse {
  // Performance metrics for a given budget option.
  message Metrics {
    // The estimated min daily clicks.
    int64 min_daily_clicks = 1;

    // The estimated max daily clicks.
    int64 max_daily_clicks = 2;
  }

  // Smart Campaign budget option.
  message BudgetOption {
    // The amount of the budget, in the local currency for the account.
    // Amount is specified in micros, where one million is equivalent to one
    // currency unit.
    int64 daily_amount_micros = 1;

    // Metrics pertaining to the suggested budget, could be empty if there is
    // not enough information to derive the estimates.
    Metrics metrics = 2;
  }

  // Optional. The lowest budget option.
  optional BudgetOption low = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The recommended budget option.
  optional BudgetOption recommended = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The highest budget option.
  optional BudgetOption high = 3 [(google.api.field_behavior) = OPTIONAL];
}
