تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
نموذج لرمز واجهة برمجة التطبيقات الخاصّة بالتاجر للحصول على حالة التاجر في "برنامج الولاء في المتجر"
Java
// 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.packageshopping.merchant.samples.lfp.v1;importcom.google.api.gax.core.FixedCredentialsProvider;importcom.google.auth.oauth2.GoogleCredentials;importcom.google.shopping.merchant.lfp.v1.GetLfpMerchantStateRequest;importcom.google.shopping.merchant.lfp.v1.LfpMerchantState;importcom.google.shopping.merchant.lfp.v1.LfpMerchantStateName;importcom.google.shopping.merchant.lfp.v1.LfpMerchantStateServiceClient;importcom.google.shopping.merchant.lfp.v1.LfpMerchantStateServiceSettings;importshopping.merchant.samples.utils.Authenticator;importshopping.merchant.samples.utils.Config;/** This class demonstrates how to get the LFP state for a given Merchant Center account */publicclassGetLfpMerchantStateSample{publicstaticvoidgetLfpMerchantState(Configconfig,StringtargetMerchantId)throwsException{// Obtains OAuth token based on the user's configuration.GoogleCredentialscredential=newAuthenticator().authenticate();// Creates service settings using the credentials retrieved above.LfpMerchantStateServiceSettingslfpMerchantStateServiceSettings=LfpMerchantStateServiceSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(credential)).build();// Gets the LFP account ID from the user's configuration.StringlfpAccountId=config.getAccountId().toString();// Calls the API and catches and prints any network failures/errors.try(LfpMerchantStateServiceClientlfpMerchantStateServiceClient=LfpMerchantStateServiceClient.create(lfpMerchantStateServiceSettings)){GetLfpMerchantStateRequestrequest=GetLfpMerchantStateRequest.newBuilder().setName(LfpMerchantStateName.of(lfpAccountId,targetMerchantId).toString()).build();System.out.println("Sending get LFP merchant state request:");LfpMerchantStateresponse=lfpMerchantStateServiceClient.getLfpMerchantState(request);System.out.println("Retrieved LFP merchant state below:");System.out.println(response);}catch(Exceptione){System.out.println(e);}}publicstaticvoidmain(String[]args)throwsException{Configconfig=Config.load();// The Merchant Center account ID.StringtargetMerchantId="{target_merchant}";getLfpMerchantState(config,targetMerchantId);}}
تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Get a LFP merchant state\n\nMerchant API code sample to get a LFP merchant state. \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.lfp.v1;\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.merchant.lfp.v1.GetLfpMerchantStateRequest;\n import com.google.shopping.merchant.lfp.v1.LfpMerchantState;\n import com.google.shopping.merchant.lfp.v1.LfpMerchantStateName;\n import com.google.shopping.merchant.lfp.v1.LfpMerchantStateServiceClient;\n import com.google.shopping.merchant.lfp.v1.LfpMerchantStateServiceSettings;\n import shopping.merchant.samples.utils.Authenticator;\n import shopping.merchant.samples.utils.Config;\n\n /** This class demonstrates how to get the LFP state for a given Merchant Center account */\n public class GetLfpMerchantStateSample {\n\n public static void getLfpMerchantState(Config config, String targetMerchantId) throws Exception {\n\n // Obtains OAuth token based on the user's configuration.\n GoogleCredentials credential = new Authenticator().authenticate();\n\n // Creates service settings using the credentials retrieved above.\n LfpMerchantStateServiceSettings lfpMerchantStateServiceSettings =\n LfpMerchantStateServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n // Gets the LFP account ID from the user's configuration.\n String lfpAccountId = config.getAccountId().toString();\n // Calls the API and catches and prints any network failures/errors.\n try (LfpMerchantStateServiceClient lfpMerchantStateServiceClient =\n LfpMerchantStateServiceClient.create(lfpMerchantStateServiceSettings)) {\n\n GetLfpMerchantStateRequest request =\n GetLfpMerchantStateRequest.newBuilder()\n .setName(LfpMerchantStateName.of(lfpAccountId, targetMerchantId).toString())\n .build();\n\n System.out.println(\"Sending get LFP merchant state request:\");\n LfpMerchantState response = lfpMerchantStateServiceClient.getLfpMerchantState(request);\n\n System.out.println(\"Retrieved LFP merchant state below:\");\n System.out.println(response);\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n Config config = Config.load();\n\n // The Merchant Center account ID.\n String targetMerchantId = \"{target_merchant}\";\n\n getLfpMerchantState(config, targetMerchantId);\n }\n } \n https://github.com/google/merchant-api-samples/blob/c6de994268c785ce22af0065932518a9ac5b3c03/java/src/main/java/shopping/merchant/samples/lfp/v1/GetLfpMerchantStateSample.java"]]