الأتمتة
`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`.
كل الدوالّ
automation = client.automations.create( name: "Welcome series", starter: "welcome-series", settings: {timezone: "Europe/London"}) trigger = {kind: "event", eventName: "trial.started", filters: []}saved = client.automations.update( automation[:id], definition: automation[:definition].to_h.merge(trigger: trigger), expectedUpdatedAt: automation[:updatedAt]) blocking = saved[:problems].to_a.find { |problem| problem[:blocking] }raise blocking[:message] if blocking client.automations.send_test(saved[:id], stepKey: saved.dig(:definition, :entry))live = client.automations.publish(saved[:id]) sent = client.events.send( name: "trial.started", email: "[email protected]", properties: {plan: "starter"}, createContact: true, idempotency_key: "trial:[email protected]") client.automations.iterate_enrollments(live[:id], status: "active") do |enrollment| puts "#{enrollment.dig(:contact, :email)} #{enrollment[:heldFor]}" if enrollment[:heldFor]end stats = client.automations.stats(live[:id])history = client.contacts.list_events("[email protected]", name: "trial.started") client.automations.pause(live[:id])client.automations.resume(live[:id]) puts sent[:enrolled], stats.dig(:totals, :entered), history.items.sizeتحتفظ الأتمتة بمسودة 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>.