الأتمتة
`automations.list` و`get` و`create` و`update` و`publish` و`pause` و`resume` و`archive` و`duplicate` و`delete` و`send_test` و`stats` و`list_versions` و`restore_version` و`list_starters` و`list_enrollments` و`get_enrollment` و`enroll` و`exit_enrollment`، مع `events.send` و`send_batch` و`list_names`.
كل الدوالّ
from openemail import openemail automation = openemail.automations.create({ 'name': 'Welcome series', 'starter': 'welcome-series', 'settings': {'timezone': 'Europe/London'},}) saved = openemail.automations.update(automation['id'], { 'definition': { **automation['definition'], 'trigger': {'kind': 'event', 'eventName': 'trial.started', 'filters': []}, }, 'expectedUpdatedAt': automation['updatedAt'],}) blocking = [problem for problem in saved['problems'] if problem['blocking']]if blocking: raise RuntimeError(blocking[0]['message']) openemail.automations.send_test(saved['id'], {'stepKey': saved['definition']['entry'] or ''})live = openemail.automations.publish(saved['id']) sent = openemail.events.send( { 'name': 'trial.started', 'email': '[email protected]', 'properties': {'plan': 'starter'}, 'createContact': True, }, idempotency_key='trial:[email protected]',) for enrollment in openemail.automations.iterate_enrollments(live['id'], status='active'): if enrollment['heldFor']: print(enrollment['contact']['email'], enrollment['heldFor']) stats = openemail.automations.stats(live['id'])history = openemail.contacts.list_events('[email protected]', name='trial.started') openemail.automations.pause(live['id'])openemail.automations.resume(live['id']) print(sent['enrolled'], stats['totals']['entered'], len(history['items']))تحتفظ الأتمتة بمسودة definition وبنسخة published التي تعمل. ويغيّر update المسودة والإعدادات، ويثبّت publish المسودة بوصفها النسخة التالية ويشغّل الأتمتة. ويذكر problems ما يمنع نشر المسودة حتى الآن، ويرفض expectedUpdatedAt بـ 409 version_conflict أي حفظ قد يكتب فوق حفظ شخص آخر.
القراءة تتطلب automations:read والتغيير يتطلب automations:write. وتتطلب publish وresume وsend_test أيضًا emails:send. وتتطلب events.send وevents.send_batch النطاق contacts:write، وتتطلب contacts.list_events النطاق contacts:read. ويطلب delete من رمز وصول OAuth رمز تحقق، ولا يطلبه من مفتاح API أبدًا.
يقبل events.send_batch حتى 100 حدث ولا يرفع استثناءً أبدًا بسبب حدث واحد غير صالح: تسرد الاستجابة accepted وfailed، ولكل منها index الحدث في القائمة التي أرسلتها.
يحمل attributes في جهة الاتصال حقولها المخصصة، وتقرأ الأتمتة أحدها بالصيغة attributes.<key>.
المرجع
automations.list()المرجع الكاملautomations.list_all()المرجع الكاملautomations.iterate()المرجع الكاملautomations.get()المرجع الكاملautomations.create()المرجع الكاملautomations.update()المرجع الكاملautomations.delete()المرجع الكاملautomations.publish()المرجع الكاملautomations.pause()المرجع الكاملautomations.resume()المرجع الكاملautomations.archive()المرجع الكاملautomations.duplicate()المرجع الكاملautomations.send_test()المرجع الكاملautomations.stats()المرجع الكاملautomations.list_versions()المرجع الكاملautomations.restore_version()المرجع الكاملautomations.list_starters()المرجع الكاملautomations.list_enrollments()المرجع الكاملautomations.list_all_enrollments()المرجع الكاملautomations.iterate_enrollments()المرجع الكاملautomations.get_enrollment()المرجع الكاملautomations.enroll()المرجع الكاملautomations.exit_enrollment()المرجع الكاملevents.send()المرجع الكاملevents.send_batch()المرجع الكاملevents.list_names()المرجع الكاملcontacts.list_events()المرجع الكاملcontacts.list_all_events()المرجع الكاملcontacts.iterate_events()المرجع الكامل