Class: Courier::Resources::Journeys
- Inherits:
-
Object
- Object
- Courier::Resources::Journeys
- Defined in:
- lib/courier/resources/journeys.rb,
lib/courier/resources/journeys/templates.rb
Defined Under Namespace
Classes: Templates
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#archive(template_id, request_options: {}) ⇒ nil
Archive a journey.
-
#create(name:, nodes:, enabled: nil, state: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Create a journey.
-
#initialize(client:) ⇒ Journeys
constructor
private
A new instance of Journeys.
-
#invoke(template_id, data: nil, profile: nil, user_id: nil, request_options: {}) ⇒ Courier::Models::JourneysInvokeResponse
Some parameter documentations has been truncated, see Models::JourneyInvokeParams for more details.
-
#list(cursor: nil, version: nil, request_options: {}) ⇒ Courier::Models::JourneysListResponse
Some parameter documentations has been truncated, see Models::JourneyListParams for more details.
-
#list_versions(template_id, request_options: {}) ⇒ Courier::Models::JourneyVersionsListResponse
List published versions of a journey, ordered most recent first.
-
#publish(template_id, version: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Publish the current draft as a new version.
-
#replace(template_id, name:, nodes:, enabled: nil, state: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Replace the journey draft.
-
#retrieve(template_id, version: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Fetch a journey by id.
Constructor Details
#initialize(client:) ⇒ Journeys
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Journeys.
232 233 234 235 |
# File 'lib/courier/resources/journeys.rb', line 232 def initialize(client:) @client = client @templates = Courier::Resources::Journeys::Templates.new(client: client) end |
Instance Attribute Details
#templates ⇒ Courier::Resources::Journeys::Templates (readonly)
7 8 9 |
# File 'lib/courier/resources/journeys.rb', line 7 def templates @templates end |
Instance Method Details
#archive(template_id, request_options: {}) ⇒ nil
Archive a journey. Archived journeys cannot be invoked. Existing journey runs continue to completion.
108 109 110 111 112 113 114 115 |
# File 'lib/courier/resources/journeys.rb', line 108 def archive(template_id, params = {}) @client.request( method: :delete, path: ["journeys/%1$s", template_id], model: NilClass, options: params[:request_options] ) end |
#create(name:, nodes:, enabled: nil, state: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Create a journey. Defaults to ‘DRAFT` state; pass `state: “PUBLISHED”` to publish on create. Send nodes are not allowed on `POST`. The standard flow is: create the journey shell here, add notification templates with `POST /journeys/templateId/templates`, then wire them into the journey with `PUT /journeys/templateId`. Call `POST /journeys/templateId/publish` to publish a draft after the fact.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/courier/resources/journeys.rb', line 31 def create(params) parsed, = Courier::JourneyCreateParams.dump_request(params) @client.request( method: :post, path: "journeys", body: parsed, model: Courier::JourneyResponse, options: ) end |
#invoke(template_id, data: nil, profile: nil, user_id: nil, request_options: {}) ⇒ Courier::Models::JourneysInvokeResponse
Some parameter documentations has been truncated, see Models::JourneyInvokeParams for more details.
Invoke a journey by id or alias to start a new run. The response includes a ‘runId` identifying the run.
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/courier/resources/journeys.rb', line 138 def invoke(template_id, params = {}) parsed, = Courier::JourneyInvokeParams.dump_request(params) @client.request( method: :post, path: ["journeys/%1$s/invoke", template_id], body: parsed, model: Courier::JourneysInvokeResponse, options: ) end |
#list(cursor: nil, version: nil, request_options: {}) ⇒ Courier::Models::JourneysListResponse
Some parameter documentations has been truncated, see Models::JourneyListParams for more details.
Get the list of journeys.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/courier/resources/journeys.rb', line 84 def list(params = {}) parsed, = Courier::JourneyListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "journeys", query: query, model: Courier::JourneysListResponse, options: ) end |
#list_versions(template_id, request_options: {}) ⇒ Courier::Models::JourneyVersionsListResponse
List published versions of a journey, ordered most recent first.
160 161 162 163 164 165 166 167 |
# File 'lib/courier/resources/journeys.rb', line 160 def list_versions(template_id, params = {}) @client.request( method: :get, path: ["journeys/%1$s/versions", template_id], model: Courier::JourneyVersionsListResponse, options: params[:request_options] ) end |
#publish(template_id, version: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Publish the current draft as a new version. Body is optional; pass ‘{ “version”: “vN” }` to roll back to a prior version instead. Returns 404 if the journey has no draft to publish.
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/courier/resources/journeys.rb', line 184 def publish(template_id, params = {}) parsed, = Courier::JourneyPublishParams.dump_request(params) @client.request( method: :post, path: ["journeys/%1$s/publish", template_id], body: parsed, model: Courier::JourneyResponse, options: ) end |
#replace(template_id, name:, nodes:, enabled: nil, state: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Replace the journey draft. Updates the working draft only; call ‘POST /journeys/templateId/publish` to make it live, or pass `state: “PUBLISHED”` in this request to publish immediately. Send-node `template` ids must already exist and be scoped to this journey, and node ids must not be claimed by another journey.
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/courier/resources/journeys.rb', line 218 def replace(template_id, params) parsed, = Courier::JourneyReplaceParams.dump_request(params) @client.request( method: :put, path: ["journeys/%1$s", template_id], body: parsed, model: Courier::JourneyResponse, options: ) end |
#retrieve(template_id, version: nil, request_options: {}) ⇒ Courier::Models::JourneyResponse
Fetch a journey by id. Pass ‘?version=draft` (default `published`) to retrieve the working draft, or `?version=vN` to retrieve a historical version.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/courier/resources/journeys.rb', line 56 def retrieve(template_id, params = {}) parsed, = Courier::JourneyRetrieveParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["journeys/%1$s", template_id], query: query, model: Courier::JourneyResponse, options: ) end |