المواقع

عرض قائمة بالمواقع وإنشاؤها وتحديثها وأرشفتها والبحث عنها واسترجاعها عبر client.locations.

جميع أساليب المواقع موجودة ضمن client.locations. ثبّت SDK واضبط مفتاحك قبل استخدامها؛ راجع التثبيت والبدء السريع.

معرّفات المواقع

تقبل الأساليب التي تأخذ location_id إما معرّفًا رقميًا (16808) أو ما يعادله بترميز base64 ("TG9jYXRpb246MTY4MDg="). يرمّز SDK المعرّفات الرقمية تلقائيًا، لذا يمكن استخدام أي من الصيغتين:

Python
# These are equivalentclient.locations.retrieve(16808)client.locations.retrieve("TG9jYXRpb246MTY4MDg=")

locations.add

أنشئ موقعًا باستدعاء واحد مع تمرير كل حقل إلزامي كمعامل مسمّى. هذه هي الطريقة الموصى بها لإنشاء المواقع. يتحقق SDK من متطلبات الإنشاء الخاصة بـ API من جهة العميل ويُطلق الاستثناء ValidationError قبل أي استدعاء للشبكة، لذا تفشل الحمولة غير الصالحة فورًا مع رسالة واضحة.

Python
client.locations.add(    *,    name: str,    description: str,    sub_category_id: int,    country_iso: str,    city: str | None = None,    street: str | None = None,    state_iso: str | None = None,    postal_code: str | None = None,    phone: str | None = None,    website: str | None = None,    store_id: str | None = None,    hide_address: bool | None = None,    business_hours: list[dict] | None = None,    service_area: dict | None = None,    place_action_links: list[dict] | None = None,    enabled_site_ids: list[int] | None = None,    additional_fields: dict | None = None,) -> APIObject
المعاملالنوعالوصف
namestrاسم النشاط التجاري، من 2 إلى 150 حرفًا. مطلوب.
descriptionstrوصف النشاط التجاري، بحد أدنى 200 حرف. تستخدمه منصات النشر كنص أساسي لإدراج النشاط التجاري. مطلوب.
sub_category_idintمعرّف الفئة الفرعية الأساسية. استخدم client.subcategories() للحصول على المعرّفات الصالحة. مطلوب.
country_isostrرمز البلد وفق معيار ISO المكوّن من حرفين. استخدم client.countries() للحصول على البلدان المدعومة. مطلوب.
citystrالمدينة. مطلوبة للبلدان التي تتضمن عناوينها المدينة؛ لا تحذفها إلا للأنشطة التجارية التي تخدم نطاقًا جغرافيًا مع hide_address=True.
streetstrعنوان الشارع.
state_isostrرمز الولاية أو المنطقة وفق معيار ISO.
postal_codestrالرمز البريدي أو رمز ZIP.
phonestrرقم الهاتف الأساسي، مع التحقق من صلاحيته للبلد.
websitestrعنوان URL للموقع الإلكتروني للنشاط التجاري.
store_idstrرمز متجرك الفريد؛ يجب أن يكون فريدًا على مستوى الحساب.
hide_addressboolإخفاء عنوان الشارع (للأنشطة التجارية التي تخدم نطاقًا جغرافيًا).
business_hourslist[dict]ساعات العمل الأسبوعية، e.g. [{"day": "MONDAY", "slots": [...]}].
service_areadictإعدادات نطاق الخدمة الجغرافي: {businessType, regionCode, placeInfos}.
place_action_linkslist[dict]روابط الإجراءات في Google، e.g. [{"placeActionType": "APPOINTMENT", "uri": "https://...", "isPreferred": True}].
enabled_site_idslist[int]معرّفات مواقع النشر التي تريد نشر هذا الموقع عليها، عندما تريد استخدام مجموعة فرعية من مواقع النشر المتاحة في خطتك. استخدم client.plan_sites() للحصول على المعرّفات.
additional_fieldsdictحقول camelCase إضافية تُدمج في الحمولة كما هي.

تشمل عمليات التحقق من جهة العميل: أن يتراوح طول name من 2 إلى 150 حرفًا، وألا يقل طول description عن 200 حرف، وأن يتوفر sub_category_id وcountry_iso، وأن يتوفر city ما لم يتحقق hide_address=True.

القيمة المُعادة هي حمولة الإنشاء: يحتوي .location على الموقع الجديد. لا تحتاج أبدًا إلى فحص مؤشرات النجاح؛ يُطلق SDK الاستثناء ValidationError عندما ترفض API الحمولة.

Python
result = client.locations.add(  name="Acme Dental",  description=(      "Acme Dental is a family-owned dental practice offering general, "      "cosmetic, and pediatric dentistry in the heart of New York. Our "      "team provides cleanings, fillings, crowns, whitening, and same-day "      "emergency care in a modern, comfortable office with weekend hours "      "and easy online booking for new and returning patients."  ),  sub_category_id=1432,  country_iso="US",  city="New York",  street="123 Jump Street",  state_iso="NY",  postal_code="10013",  phone="6443859313",  website="https://acmedental.example.com",  store_id="NYC-001",  place_action_links=[      {"placeActionType": "APPOINTMENT", "uri": "https://acmedental.example.com/book", "isPreferred": True},  ],  enabled_site_ids=[1, 24, 87],)print("Created:", result.location.id, result.location.name)

locations.list

اعرض قائمة المواقع مع تقسيم النتائج إلى صفحات باستخدام مؤشر. يُعيد SyncPage.

Python
client.locations.list(    *,    first: int | None = None,    after: str | None = None,    before: str | None = None,    last: int | None = None,) -> SyncPage
Python
# First page of 25page = client.locations.list(first=25)for loc in page:  print(loc.name, loc.city) # Next page manuallyif page.has_more:  page2 = page.next_page() # Auto-paginate all locationsfor loc in client.locations.list(first=100).auto_paging_iter():  print(loc.name)

locations.retrieve

احصل على موقع واحد باستخدام معرّفه. يُطلق الاستثناء NotFoundError إذا لم يكن المعرّف موجودًا.

Python
client.locations.retrieve(location_id: str | int) -> APIObject
Python
loc = client.locations.retrieve(16808)print(loc.name, loc.street, loc.city)

locations.list_by_ids

اجلب عدة مواقع باستخدام قائمة معرّفات (رقمية أو بترميز base64) في استدعاء واحد.

Python
client.locations.list_by_ids(location_ids: list[str | int]) -> list[APIObject]
Python
locs = client.locations.list_by_ids([16808, 16809, "TG9jYXRpb246MTQwMjQ="])for loc in locs:  print(loc.id, loc.name)

locations.list_by_store_codes

اجلب المواقع المطابقة لرموز المتاجر المحددة.

Python
client.locations.list_by_store_codes(store_codes: list[str]) -> list[APIObject]
Python
locs = client.locations.list_by_store_codes(["SF-001", "NYC-042"])for loc in locs:  print(loc.storeId, loc.name)

locations.search

ابحث عن المواقع باستخدام كلمة مفتاحية في الاسم أو العنوان أو معرّف المتجر. يُعيد SyncPage.

Python
client.locations.search(    query: str,    *,    fields: list[str] | None = None,    first: int | None = None,    after: str | None = None,    before: str | None = None,    last: int | None = None,) -> SyncPage
Python
# Search all fieldspage = client.locations.search("downtown dental", first=10) # Restrict to name onlypage = client.locations.search("Acme Dental", fields=["name"], first=10) for loc in page:  print(loc.name, loc.city)

locations.create

أنشئ موقعًا من قاموس إدخال خام بأسماء حقول camelCase. يُفضّل استخدام locations.add للمعاملات المسماة والتحقق من جهة العميل؛ استخدم create عندما تكون لديك حمولة camelCase بالفعل.

Python
client.locations.create(input: dict) -> APIObject

الحقول التي تتطلبها API: name، وdescription (بحد أدنى 200 حرف)، وsubCategoryId، وcountryIso، وcity (للبلدان التي تتضمن عناوينها المدينة).

Python
result = client.locations.create({  "name": "Acme Dental Brooklyn",  "description": (      "Acme Dental Brooklyn is a family-owned dental practice offering "      "general, cosmetic, and pediatric dentistry. Our team provides "      "cleanings, fillings, crowns, whitening, and same-day emergency "      "care in a modern, comfortable office with weekend hours and easy "      "online booking for new and returning patients across Brooklyn."  ),  "subCategoryId": 1432,  "countryIso": "US",  "city": "Brooklyn",  "street": "88 Court St",  "stateIso": "NY",  "postalCode": "11201",  "phone": "6443859314",  "storeId": "NYC-002",})print("Created:", result.location.id)

locations.update

حدّث موقعًا. مرّر id مع أي حقول تريد تغييرها (camelCase). يمكن أن يكون id رقميًا أو بترميز base64؛ يرمّزه SDK تلقائيًا.

Python
client.locations.update(input: dict) -> APIObject
Python
result = client.locations.update({  "id": 16808,  "phone": "6443859399",  "street": "125 Jump Street",})print("Updated:", result.location.id)

locations.archive

أرشف موقعًا واحدًا أو أكثر.

Python
client.locations.archive(location_ids: list[str | int]) -> APIObject
Python
result = client.locations.archive([16808, 16809])print(result.to_dict())

locations.cancel_archive

ألغِ عملية أرشفة مجدولة.

Python
client.locations.cancel_archive(    location_ids: list[str | int],    selection_type: str,    changed_by: str,) -> APIObject
Python
client.locations.cancel_archive(  [16808],  selection_type="manual",  changed_by="admin@example.com",)

راجع أيضًا