UpdateCssProductInput পদ্ধতি ব্যবহার করে একটি বিদ্যমান একক CSS পণ্য আপডেট করুন পণ্য cssProductInput.name
এবং একটি JSON বডি যেখানে আপনি পণ্যটির জন্য আপডেট করতে চান এমন ডেটা উল্লেখ করে।
দ্রষ্টব্য : এই পদ্ধতিটি শুধুমাত্র আপডেট অনুরোধে প্রদত্ত বৈশিষ্ট্যগুলিকে আপডেট করে। প্রতিক্রিয়াটিতে অনুরোধের মতো একই বৈশিষ্ট্য রয়েছে এবং আপডেট প্রয়োগ করার পরে সম্পূর্ণ CssProductInput
অবস্থা প্রতিফলিত করে না। CssProductInput
এর চূড়ান্ত অবস্থা নির্ধারণ করতে আপনার প্রতিক্রিয়ার উপর নির্ভর করা উচিত নয়।
PATCH https://css.googleapis.com/v1/accounts/{ACCOUNT_ID}/cssProductInputs/{CSS_PRODUCT_ID}
একটি পণ্যে একটি বৈশিষ্ট্য যোগ বা পরিবর্তন করতে, JSON বডিতে নতুন মান সহ ক্ষেত্রটি নির্দিষ্ট করুন। দেখানো উদাহরণটি 123/cssProductInputs/de~DE~B019G4
নামের একটি বিদ্যমান পণ্যের শিরোনাম এবং শিরোনাম অফার লিঙ্ক আপডেট করবে অনুরোধের অংশে প্রদত্ত অ্যাট্রিবিউট মান সহ, অন্য সমস্ত ক্ষেত্রগুলিকে স্পর্শ না করে৷
HTTP
PATCH https://css.googleapis.com/v1/accounts/{ACCOUNT_ID}/cssProductInputs/{CSS_PRODUCT_ID}
{
"attributes": {
"title": "new item title",
"headlineOfferLink": "headline-offer.com"
}
}
cURL
curl --location --request PATCH 'https://css.googleapis.com/v1/accounts/{ACCOUNT_ID}/cssProductInputs/{CSS_PRODUCT_ID}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_TOKEN>' \
--data '{"attributes":{"numberOfOffers":"99","headlineOfferPrice":{"currency_code":"EUR","amount_micros":"1200000"}}}'
জাভা
// Copyright 2023 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.css.samples.v1.cssproducts;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.protobuf.FieldMask;
import com.google.shopping.css.v1.CssProductInput;
import com.google.shopping.css.v1.CssProductInputsServiceClient;
import com.google.shopping.css.v1.CssProductInputsServiceSettings;
import com.google.shopping.css.v1.UpdateCssProductInputRequest;
import shopping.css.samples.utils.Authenticator;
import shopping.css.samples.utils.Config;
/** This class demonstrates how to update a CSS Product for a given Account */
public class UpdateCssProductInput {
private static String getName(String domainId, String productId) {
return String.format("accounts/%s/cssProductInputs/%s", domainId, productId);
}
public static void updateCssProductInput(Config config, String productId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
String name = getName(config.getDomainId().toString(), productId);
CssProductInputsServiceSettings cssProductInputsServiceSettings =
CssProductInputsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
try (CssProductInputsServiceClient cssProductInputsServiceClient =
CssProductInputsServiceClient.create(cssProductInputsServiceSettings)) {
// Updates the title of the CSS Product leaving the rest of the fields unchanged
UpdateCssProductInputRequest request =
UpdateCssProductInputRequest.newBuilder()
.setCssProductInput(
CssProductInput.newBuilder()
.setName(name)
.setAttributes(
com.google.shopping.css.v1.Attributes.newBuilder()
.setTitle("Attribute Title")
.setHeadlineOfferLink("abc.com")
.setHeadlineOfferCondition("New")
.setDescription("CSS Product description 0")
.build())
.build())
.setUpdateMask(FieldMask.newBuilder().addPaths("title").build())
.build();
System.out.println("Updating CSS Product");
CssProductInput response = cssProductInputsServiceClient.updateCssProductInput(request);
System.out.print("CSS product updated:");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
final Config config = Config.load();
// The ID uniquely identifying each product. In
// the format languageCode~countryCode~rawProvidedId
final String productId = "de~DE~rawProvidedId17";
updateCssProductInput(config, productId);
}
}
শুধুমাত্র শীর্ষ-স্তরের ক্ষেত্রগুলি cssProductInputs.update
অনুরোধের সাথে আপডেট করা যেতে পারে। আপনি যদি নেস্টেড ক্ষেত্রগুলি আপডেট করতে চান তবে আপনাকে অবশ্যই সম্পূর্ণ শীর্ষ-স্তরের বস্তু প্রদান করতে হবে।
দেখানো উদাহরণটি একটি বিদ্যমান পণ্যের নেস্টেড ক্ষেত্র সহ শীর্ষ-স্তরের headlineOfferPrice
অবজেক্টকে আপডেট করবে, অনুরোধের অংশে প্রদত্ত পণ্য ডেটা সহ, অন্যান্য সমস্ত ক্ষেত্রগুলিকে স্পর্শ না করে রেখে৷
PATCH https://css.googleapis.com/v1/accounts/{ACCOUNT_ID}/cssProductInputs/{CSS_PRODUCT_ID}
{
"attributes": {
"headlineOfferPrice": {
"amountMicros": "17.99",
"currencyCode": "USD"
}
}
}
অনুরোধের মূল অংশে অন্তর্ভুক্ত অন্যগুলিতে পরিবর্তন না করে আপডেট করার জন্য নির্দিষ্ট ক্ষেত্রগুলি নির্বাচন করতে, আপনি একটি updateMask
নির্দিষ্ট করতে পারেন। এই ক্যোয়ারী স্ট্রিং প্যারামিটারটি আপনার সংশোধন করতে হবে এমন ক্ষেত্রগুলির একটি কমা দ্বারা পৃথক করা তালিকা হওয়া উচিত। একটি updateMask
দরকারী যখন আপনি দাবি করতে চান যে শুধুমাত্র নামযুক্ত ক্ষেত্রগুলি আপডেট করা হবে। একটি updateMask
নির্দিষ্ট না করা আপডেট করার অনুরোধের সমস্ত ক্ষেত্র চিহ্নিত করার সমতুল্য, যেমন উদাহরণে দেখানো হয়েছে। যাইহোক, যদি একটি updateMask
স্পষ্টভাবে প্রদান করা না হয়, তাহলে বিদ্যমান বৈশিষ্ট্যগুলি মুছে ফেলা সম্ভব নয়।
দেখানো উদাহরণটি অনুরোধের মূল অংশে প্রদত্ত সংশ্লিষ্ট পণ্য ডেটা সহ বিদ্যমান আইটেমের শিরোনামটি আপডেট করবে, headline offer link
সহ অন্যান্য সমস্ত ক্ষেত্রগুলিকে স্পর্শ করা যাবে না title
PATCH https://css.googleapis.com/v1/accounts/{ACCOUNT_ID}/cssProductInputs/{CSS_PRODUCT_ID}?updateMask=title
{
"attributes": {
"title":"item-title",
"headlineOfferLink":"headline-offer-newer.com"
}
}
যদি আপডেটমাস্ক তালিকায় একটি ক্ষেত্র সরবরাহ করা হয় তবে অনুরোধের মূল অংশে না থাকে তবে সেই ক্ষেত্রটি পণ্য সংস্থান থেকে মুছে ফেলা হবে, যদি এটি বিদ্যমান থাকে।
দেখানো উদাহরণটি ক্ষেত্রের title
মানটি সরাতে updateMask ব্যবহার করবে।
PATCH https://css.googleapis.com/v1/accounts/{ACCOUNT_ID}/cssProductInputs/{CSS_PRODUCT_ID}?updateMask=title
ACCOUNT_ID : অ্যাকাউন্টের জন্য অনন্য শনাক্তকারী, উদাহরণস্বরূপ, 123
।
CSS_PRODUCT_ID : CSS পণ্য আইডি, উদাহরণস্বরূপ, de~DE~B019G4
।
title
ক্ষেত্রটি মুছে ফেলতে, অনুরোধের মূল অংশ থেকে এটি ছেড়ে দিন। আপনি কোনও বডি বা খালি বডি ছাড়াই অনুরোধ পাঠাতে পারেন। আপডেটমাস্কে না থাকা ক্ষেত্রগুলি অপরিবর্তিত থাকবে।