loops_sdk 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,11 @@ module LoopsSdk
10
10
  def get(audience_segment_id:)
11
11
  make_request(method: :get, path: "v1/audience-segments/#{audience_segment_id}")
12
12
  end
13
+
14
+ def create(name:, filter:, description: nil)
15
+ body = { name: name, filter: filter, description: description }.compact
16
+ make_request(method: :post, path: "v1/audience-segments", body: body)
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -13,7 +13,7 @@ module LoopsSdk
13
13
  limit = response.headers["x-ratelimit-limit"]
14
14
  remaining = response.headers["x-ratelimit-remaining"]
15
15
  raise RateLimitError.new(limit, remaining)
16
- when 400, 401, 404, 405, 409, 413, 422, 500
16
+ when 400, 401, 404, 405, 409, 413, 422, 500, 501
17
17
  raise APIError.new(response.status, response.body)
18
18
  else
19
19
  raise APIError.new(response.status, "Unexpected error occurred")
@@ -10,6 +10,15 @@ module LoopsSdk
10
10
  def get(component_id:)
11
11
  make_request(method: :get, path: "v1/components/#{component_id}")
12
12
  end
13
+
14
+ def create(name:, lmx:)
15
+ make_request(method: :post, path: "v1/components", body: { name: name, lmx: lmx })
16
+ end
17
+
18
+ def update(component_id:, name: nil, lmx: nil)
19
+ body = { name: name, lmx: lmx }.compact
20
+ make_request(method: :post, path: "v1/components/#{component_id}", body: body)
21
+ end
13
22
  end
14
23
  end
15
24
  end
@@ -52,6 +52,11 @@ module LoopsSdk
52
52
  }.compact
53
53
  make_request(method: :post, path: "v1/email-messages/#{email_message_id}/preview", body: body)
54
54
  end
55
+
56
+ def run_guardian(email_message_id:)
57
+ make_request(method: :get, path: "v1/email-messages/#{email_message_id}/guardian")
58
+ end
55
59
  end
56
60
  end
57
61
  end
62
+
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module LoopsSdk
6
+ class EventPatterns < Base
7
+ class << self
8
+ def list(perPage: 20, cursor: nil)
9
+ make_request(method: :get, path: "v1/event-patterns", params: { perPage: perPage, cursor: cursor })
10
+ end
11
+
12
+ def get(event_pattern_id:)
13
+ make_request(method: :get, path: "v1/event-patterns/#{event_pattern_id}")
14
+ end
15
+
16
+ def get_by_name(event_name:)
17
+ encoded_name = CGI.escapeURIComponent(event_name)
18
+ make_request(method: :get, path: "v1/event-patterns/by-name/#{encoded_name}")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -10,6 +10,16 @@ module LoopsSdk
10
10
  def get(theme_id:)
11
11
  make_request(method: :get, path: "v1/themes/#{theme_id}")
12
12
  end
13
+
14
+ def create(name:, styles: nil)
15
+ body = { name: name, styles: styles }.compact
16
+ make_request(method: :post, path: "v1/themes", body: body)
17
+ end
18
+
19
+ def update(theme_id:, name: nil, styles: nil)
20
+ body = { name: name, styles: styles }.compact
21
+ make_request(method: :post, path: "v1/themes/#{theme_id}", body: body)
22
+ end
13
23
  end
14
24
  end
15
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoopsSdk
4
- VERSION = "2.3.0"
4
+ VERSION = "2.4.0"
5
5
  end
@@ -7,13 +7,100 @@ module LoopsSdk
7
7
  make_request(method: :get, path: "v1/workflows", params: { perPage: perPage, cursor: cursor })
8
8
  end
9
9
 
10
+ def create(name:, description: nil, mailing_list_id: nil)
11
+ body = {
12
+ name: name,
13
+ description: description,
14
+ mailingListId: mailing_list_id
15
+ }.compact
16
+ make_request(method: :post, path: "v1/workflows", body: body)
17
+ end
18
+
10
19
  def get(workflow_id:)
11
20
  make_request(method: :get, path: "v1/workflows/#{workflow_id}")
12
21
  end
13
22
 
23
+ def update(workflow_id:, expected_revision_id:, name: nil, description: nil)
24
+ body = {
25
+ expectedRevisionId: expected_revision_id,
26
+ name: name,
27
+ description: description
28
+ }.compact
29
+ # expectedRevisionId may be null for older workflows; always include it
30
+ body[:expectedRevisionId] = expected_revision_id
31
+ make_request(method: :post, path: "v1/workflows/#{workflow_id}", body: body)
32
+ end
33
+
34
+ def change_mailing_list(workflow_id:, expected_revision_id:, mailing_list_id:, dry_run: nil, queued_contact_policy: nil)
35
+ body = {
36
+ expectedRevisionId: expected_revision_id,
37
+ mailingListId: mailing_list_id,
38
+ dryRun: dry_run,
39
+ queuedContactPolicy: queued_contact_policy
40
+ }.compact
41
+ # expectedRevisionId and mailingListId may be null; always include them
42
+ body[:expectedRevisionId] = expected_revision_id
43
+ body[:mailingListId] = mailing_list_id
44
+ make_request(method: :post, path: "v1/workflows/#{workflow_id}/mailing-list", body: body)
45
+ end
46
+
14
47
  def get_node(workflow_id:, node_id:)
15
48
  make_request(method: :get, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}")
16
49
  end
50
+
51
+ def create_node(
52
+ workflow_id:,
53
+ expected_revision_id:,
54
+ insert_mode:,
55
+ node_type_name:,
56
+ from_node_id: nil,
57
+ to_node_id: nil,
58
+ before_node_id: nil
59
+ )
60
+ body = {
61
+ expectedRevisionId: expected_revision_id,
62
+ insertMode: insert_mode,
63
+ nodeTypeName: node_type_name,
64
+ fromNodeId: from_node_id,
65
+ toNodeId: to_node_id,
66
+ beforeNodeId: before_node_id
67
+ }.compact
68
+ body[:expectedRevisionId] = expected_revision_id
69
+ make_request(method: :post, path: "v1/workflows/#{workflow_id}/nodes", body: body)
70
+ end
71
+
72
+ def update_node(workflow_id:, node_id:, expected_revision_id:, payload:)
73
+ body = {
74
+ expectedRevisionId: expected_revision_id,
75
+ payload: payload
76
+ }
77
+ make_request(method: :post, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}", body: body)
78
+ end
79
+
80
+ def delete_node(workflow_id:, node_id:, expected_revision_id:, dry_run: nil, queued_contact_policy: nil)
81
+ body = {
82
+ expectedRevisionId: expected_revision_id,
83
+ dryRun: dry_run,
84
+ queuedContactPolicy: queued_contact_policy
85
+ }.compact
86
+ body[:expectedRevisionId] = expected_revision_id
87
+ make_request(method: :delete, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}", body: body)
88
+ end
89
+
90
+ def add_branch(workflow_id:, node_id:, expected_revision_id:)
91
+ body = { expectedRevisionId: expected_revision_id }
92
+ make_request(method: :post, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}/add-branch", body: body)
93
+ end
94
+
95
+ def delete_node_recursive(workflow_id:, node_id:, expected_revision_id:, dry_run: nil, queued_contact_policy: nil)
96
+ body = {
97
+ expectedRevisionId: expected_revision_id,
98
+ dryRun: dry_run,
99
+ queuedContactPolicy: queued_contact_policy
100
+ }.compact
101
+ body[:expectedRevisionId] = expected_revision_id
102
+ make_request(method: :delete, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}/recursive", body: body)
103
+ end
17
104
  end
18
105
  end
19
106
  end
data/lib/loops_sdk.rb CHANGED
@@ -20,6 +20,7 @@ require_relative "loops_sdk/email_messages"
20
20
  require_relative "loops_sdk/uploads"
21
21
  require_relative "loops_sdk/audience_segments"
22
22
  require_relative "loops_sdk/workflows"
23
+ require_relative "loops_sdk/event_patterns"
23
24
  require_relative "loops_sdk/transactional_groups"
24
25
 
25
26
  module LoopsSdk
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loops_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Rowden
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-24 00:00:00.000000000 Z
11
+ date: 2026-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -45,6 +45,7 @@ files:
45
45
  - lib/loops_sdk/contacts.rb
46
46
  - lib/loops_sdk/dedicated_sending_ips.rb
47
47
  - lib/loops_sdk/email_messages.rb
48
+ - lib/loops_sdk/event_patterns.rb
48
49
  - lib/loops_sdk/events.rb
49
50
  - lib/loops_sdk/mailing_lists.rb
50
51
  - lib/loops_sdk/themes.rb