판매자 리뷰 데이터 소스 만들기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
판매자 리뷰 데이터 소스를 만들기 위한 판매자 API 코드 샘플
자바
// 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
//
// https://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.
package shopping.merchant.samples.datasources.v1;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1.CreateDataSourceRequest;
import com.google.shopping.merchant.datasources.v1.DataSource;
import com.google.shopping.merchant.datasources.v1.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1.MerchantReviewDataSource;
import java.io.IOException;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to create a merchant reviews data source. */
public class CreateMerchantReviewsDataSourceSample {
private static void createMerchantReviewsDataSource(String accountId) throws IOException {
GoogleCredentials credential = new Authenticator().authenticate();
DataSourcesServiceSettings dataSourcesServiceSettings =
DataSourcesServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (DataSourcesServiceClient dataSourcesServiceClient =
DataSourcesServiceClient.create(dataSourcesServiceSettings)) {
CreateDataSourceRequest request =
CreateDataSourceRequest.newBuilder()
.setParent(String.format("accounts/%s", accountId))
.setDataSource(
DataSource.newBuilder()
.setDisplayName("Merchant Reviews Data Source")
.setMerchantReviewDataSource(MerchantReviewDataSource.newBuilder().build())
.build())
.build();
System.out.println("Creating merchant reviews data source...");
DataSource dataSource = dataSourcesServiceClient.createDataSource(request);
System.out.println(
String.format("Datasource created successfully: %s", dataSource.getName()));
} catch (Exception e) {
System.out.println(e);
System.exit(1);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
createMerchantReviewsDataSource(config.getAccountId().toString());
}
}
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-21(UTC)
[null,null,["최종 업데이트: 2025-08-21(UTC)"],[],[],null,["# Create a merchant review data source\n\nMerchant API code sample to create a merchant review data source. \n\n### Java\n\n // Copyright 2025 Google LLC\n //\n // Licensed under the Apache License, Version 2.0 (the \"License\");\n // you may not use this file except in compliance with the License.\n // You may obtain a copy of the License at\n //\n // https://www.apache.org/licenses/LICENSE-2.0\n //\n // Unless required by applicable law or agreed to in writing, software\n // distributed under the License is distributed on an \"AS IS\" BASIS,\n // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n // See the License for the specific language governing permissions and\n // limitations under the License.\n\n package shopping.merchant.samples.datasources.v1;\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.merchant.datasources.v1.CreateDataSourceRequest;\n import com.google.shopping.merchant.datasources.v1.DataSource;\n import com.google.shopping.merchant.datasources.v1.DataSourcesServiceClient;\n import com.google.shopping.merchant.datasources.v1.DataSourcesServiceSettings;\n import com.google.shopping.merchant.datasources.v1.MerchantReviewDataSource;\n import java.io.IOException;\n import shopping.merchant.samples.utils.Authenticator;\n import shopping.merchant.samples.utils.Config;\n\n /** This class demonstrates how to create a merchant reviews data source. */\n public class CreateMerchantReviewsDataSourceSample {\n\n private static void createMerchantReviewsDataSource(String accountId) throws IOException {\n\n GoogleCredentials credential = new Authenticator().authenticate();\n\n DataSourcesServiceSettings dataSourcesServiceSettings =\n DataSourcesServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n try (DataSourcesServiceClient dataSourcesServiceClient =\n DataSourcesServiceClient.create(dataSourcesServiceSettings)) {\n CreateDataSourceRequest request =\n CreateDataSourceRequest.newBuilder()\n .setParent(String.format(\"accounts/%s\", accountId))\n .setDataSource(\n DataSource.newBuilder()\n .setDisplayName(\"Merchant Reviews Data Source\")\n .setMerchantReviewDataSource(MerchantReviewDataSource.newBuilder().build())\n .build())\n .build();\n\n System.out.println(\"Creating merchant reviews data source...\");\n DataSource dataSource = dataSourcesServiceClient.createDataSource(request);\n System.out.println(\n String.format(\"Datasource created successfully: %s\", dataSource.getName()));\n } catch (Exception e) {\n System.out.println(e);\n System.exit(1);\n }\n }\n\n public static void main(String[] args) throws Exception {\n Config config = Config.load();\n createMerchantReviewsDataSource(config.getAccountId().toString());\n }\n } \n https://github.com/google/merchant-api-samples/blob/c6de994268c785ce22af0065932518a9ac5b3c03/java/src/main/java/shopping/merchant/samples/datasources/v1/CreateMerchantReviewsDataSourceSample.java"]]