المواقع
عرض قائمة بالمواقع وإنشاؤها وتحديثها وأرشفتها والبحث عنها واسترجاعها عبر client.locations.
جميع أساليب المواقع موجودة ضمن client.locations. ثبّت SDK واضبط مفتاحك قبل استخدامها؛ راجع التثبيت والبدء السريع.
معرّفات المواقع
تقبل الأساليب التي تأخذ location_id إما معرّفًا رقميًا (16808) أو ما يعادله بترميز base64 ("TG9jYXRpb246MTY4MDg="). يرمّز SDK المعرّفات الرقمية تلقائيًا، لذا يمكن استخدام أي من الصيغتين:
# These are equivalentclient.locations.retrieve(16808)client.locations.retrieve("TG9jYXRpb246MTY4MDg=")locations.add
أنشئ موقعًا باستدعاء واحد مع تمرير كل حقل إلزامي كمعامل مسمّى. هذه هي الطريقة الموصى بها لإنشاء المواقع. يتحقق SDK من متطلبات الإنشاء الخاصة بـ API من جهة العميل ويُطلق الاستثناء ValidationError قبل أي استدعاء للشبكة، لذا تفشل الحمولة غير الصالحة فورًا مع رسالة واضحة.
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تشمل عمليات التحقق من جهة العميل: أن يتراوح طول name من 2 إلى 150 حرفًا، وألا يقل طول description عن 200 حرف، وأن يتوفر sub_category_id وcountry_iso، وأن يتوفر city ما لم يتحقق hide_address=True.
القيمة المُعادة هي حمولة الإنشاء: يحتوي .location على الموقع الجديد. لا تحتاج أبدًا إلى فحص مؤشرات النجاح؛ يُطلق SDK الاستثناء ValidationError عندما ترفض API الحمولة.
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.
client.locations.list( *, first: int | None = None, after: str | None = None, before: str | None = None, last: int | None = None,) -> SyncPage# 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 إذا لم يكن المعرّف موجودًا.
client.locations.retrieve(location_id: str | int) -> APIObjectloc = client.locations.retrieve(16808)print(loc.name, loc.street, loc.city)locations.list_by_ids
اجلب عدة مواقع باستخدام قائمة معرّفات (رقمية أو بترميز base64) في استدعاء واحد.
client.locations.list_by_ids(location_ids: list[str | int]) -> list[APIObject]locs = client.locations.list_by_ids([16808, 16809, "TG9jYXRpb246MTQwMjQ="])for loc in locs: print(loc.id, loc.name)locations.list_by_store_codes
اجلب المواقع المطابقة لرموز المتاجر المحددة.
client.locations.list_by_store_codes(store_codes: list[str]) -> list[APIObject]locs = client.locations.list_by_store_codes(["SF-001", "NYC-042"])for loc in locs: print(loc.storeId, loc.name)locations.search
ابحث عن المواقع باستخدام كلمة مفتاحية في الاسم أو العنوان أو معرّف المتجر. يُعيد SyncPage.
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# 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 بالفعل.
client.locations.create(input: dict) -> APIObjectالحقول التي تتطلبها API: name، وdescription (بحد أدنى 200 حرف)، وsubCategoryId، وcountryIso، وcity (للبلدان التي تتضمن عناوينها المدينة).
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 تلقائيًا.
client.locations.update(input: dict) -> APIObjectresult = client.locations.update({ "id": 16808, "phone": "6443859399", "street": "125 Jump Street",})print("Updated:", result.location.id)locations.archive
أرشف موقعًا واحدًا أو أكثر.
client.locations.archive(location_ids: list[str | int]) -> APIObjectresult = client.locations.archive([16808, 16809])print(result.to_dict())locations.cancel_archive
ألغِ عملية أرشفة مجدولة.
client.locations.cancel_archive( location_ids: list[str | int], selection_type: str, changed_by: str,) -> APIObjectclient.locations.cancel_archive( [16808], selection_type="manual", changed_by="admin@example.com",)راجع أيضًا
- المنشورات: نشر الإعلانات والفعاليات والعروض
- إدراجات الأنشطة التجارية: التحقق من حالة المزامنة لكل موقع
- التقييمات: عرض التقييمات والرد عليها
- التحليلات: تحليلات الملفات التعريفية على Google وBing وFacebook