envoy-hooks 0.9.1 → 0.9.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 967f499b30294744218f09df13dfbfd97d4746421c4bee0dbbe81c1b3ba360ac
4
- data.tar.gz: d383ec4346b1bcde2085835e02769a6ea6f2339e3c9b802fc1dcaaf543d8d2d7
3
+ metadata.gz: 22909d2d61ea631aa5c416510ccb95440a7265f5c793bf0794221c2f2dd50b18
4
+ data.tar.gz: 3706f19b970c11c6d67a679edf2464e804af878f1209746e59e12b78a5930c81
5
5
  SHA512:
6
- metadata.gz: 365724d8370f3f6a1fb832bccb32f51a740632ec9f7fa1ff00964b95dd70a421ba4c69ac7b7079d79ee92fa12655f4b1a37427e476dd7baa625fb9d3012fb858
7
- data.tar.gz: '09ddb4785e2238f552459e86f55c463a487a96d50871612f5b86b206f2bbd3fdf06aa3c8d15eb7633a6b0330d833cc46b8b03f7b86d8637ac44962e4d27b9f4d'
6
+ metadata.gz: 1c665b82b32b50af42d6363aacff26326ed4ae47cde23a044ef5a0dee3f17152153b928a7641d3a0ed564f1a95f8f2e0674bd5fb42a60b6835bbcab4d4e60118
7
+ data.tar.gz: '09ad5daf753fd75807c3cfad4ccf21bd3624cd5e00f66e3a11e34b0f1e3e8c07995a2312184a0f3761d2e690d25094b655b4ada9e8f6154cbe4da6c4ecec791b'
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 2.7.7
7
7
  Exclude:
8
8
  - 'bin/*'
9
9
  - 'db/**/*'
@@ -14,9 +14,6 @@ AllCops:
14
14
  - 'vendor/**/*'
15
15
  CacheRootDirectory: "tmp/cache"
16
16
 
17
- Rails:
18
- Enabled: true
19
-
20
17
  Layout/LineLength:
21
18
  Max: 150
22
19
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.8
1
+ 2.7.7
data/Gemfile CHANGED
@@ -8,3 +8,9 @@ gemspec
8
8
  gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', require: false
13
+
14
+ gem 'rubocop-rspec', require: false
15
+
16
+ gem 'rubocop-performance', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- envoy-hooks (0.9.1)
4
+ envoy-hooks (0.9.3)
5
5
  faraday (~> 0.15.4)
6
6
  faraday-net_http (~> 1.0)
7
7
  faraday_middleware (~> 0.12.2)
@@ -9,14 +9,22 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
+ ast (2.4.2)
12
13
  diff-lcs (1.5.0)
13
14
  faraday (0.15.4)
14
15
  multipart-post (>= 1.2, < 3)
15
16
  faraday-net_http (1.0.1)
16
17
  faraday_middleware (0.12.2)
17
18
  faraday (>= 0.7.4, < 1.0)
19
+ json (2.6.3)
18
20
  multipart-post (2.2.0)
21
+ parallel (1.22.1)
22
+ parser (3.2.1.0)
23
+ ast (~> 2.4.1)
24
+ rainbow (3.1.1)
19
25
  rake (13.0.6)
26
+ regexp_parser (2.7.0)
27
+ rexml (3.2.5)
20
28
  rspec (3.10.0)
21
29
  rspec-core (~> 3.10.0)
22
30
  rspec-expectations (~> 3.10.0)
@@ -30,8 +38,30 @@ GEM
30
38
  diff-lcs (>= 1.2.0, < 2.0)
31
39
  rspec-support (~> 3.10.0)
32
40
  rspec-support (3.10.3)
41
+ rubocop (1.48.0)
42
+ json (~> 2.3)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.2.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml (>= 3.2.5, < 4.0)
48
+ rubocop-ast (>= 1.26.0, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 2.4.0, < 3.0)
51
+ rubocop-ast (1.27.0)
52
+ parser (>= 3.2.1.0)
53
+ rubocop-capybara (2.17.1)
54
+ rubocop (~> 1.41)
55
+ rubocop-performance (1.5.2)
56
+ rubocop (>= 0.71.0)
57
+ rubocop-rspec (2.19.0)
58
+ rubocop (~> 1.33)
59
+ rubocop-capybara (~> 2.17)
60
+ ruby-progressbar (1.13.0)
61
+ unicode-display_width (2.4.2)
33
62
 
34
63
  PLATFORMS
64
+ ruby
35
65
  universal-darwin-21
36
66
  x86_64-darwin-18
37
67
  x86_64-darwin-19
@@ -41,6 +71,9 @@ DEPENDENCIES
41
71
  envoy-hooks!
42
72
  rake (~> 13.0)
43
73
  rspec (~> 3.0)
74
+ rubocop
75
+ rubocop-performance
76
+ rubocop-rspec
44
77
 
45
78
  BUNDLED WITH
46
79
  2.3.19
data/README.md CHANGED
@@ -10,6 +10,7 @@ It has the following three API methods regarding UI Hooks and their subscription
10
10
 
11
11
  * `upsertSubscription`
12
12
  * `triggerUIHooks`
13
+ * `triggerZoneUIHooks`
13
14
  * `subscribedUIHooks`
14
15
 
15
16
  These are the methods listed in [the Jira ticket](https://envoycom.atlassian.net/jira/software/c/projects/DEVP/boards/131?modal=detail&selectedIssue=DEVP-829) describing what's required for the email customization screen and the dynamic email sender.
@@ -171,6 +172,32 @@ hooksService.triggerUIHooks(
171
172
  )
172
173
  ```
173
174
 
175
+ The return value will be an array of objects. Each object will contain a lot of information, but the most important part is `response` - that will contain the HTML or JSON from the UI Hooks, which will then be used to create the UI.
176
+ ### **`triggerZoneUIHooks`**
177
+
178
+ This is how we fetch custom UI at a Connect zone. The name "trigger Zone UI Hooks" comes from the fact that we are getting the custom UI from potentially multiple UI Hooks, and we "trigger" them in order to fetch the data.
179
+
180
+ This will act to fetch the custom UI, which we will receive in the response.
181
+
182
+ ```rb
183
+ hooksService.triggerZoneUIHooks(
184
+ # REQUIRED
185
+ zoneIds: [3],
186
+ triggerName: "welcome_email", # The UI Hook name to invoke (deprecated)
187
+ triggerNames: ["welcome_email"], # The list of UI Hook extension names to invoke (triggerName or triggerNames required)
188
+ responseType: "JSON", # only other option is HTML. Determines whether you get Component JSON or prerendered HTML.
189
+
190
+ # XOR REQUIRED
191
+ resourceId: 341153, # the ID of the invite we are working with
192
+ resourceIds: [341153, 341153] # array of IDs of the invites we are working with
193
+
194
+ # OPTIONAL
195
+ previewMode: false, # Whether or not to run in preview mode. Preview mode makes it so you do not need to send in a resourceId
196
+ accentColor: "#123DEF", # Override the default Envoy accent color on applicable UI components. Currently only in emails, but that could change.
197
+ uiHookIds: [2954, 8271], # The specific UI hooks to invoke. If you don't include it, _all_ UI Hook subscriptions that match the locationId and triggerName will trigger.
198
+ )
199
+ ```
200
+
174
201
  The return value will be an array of objects. Each object will contain a lot of information, but the most important part is `response` - that will contain the HTML or JSON from the UI Hooks, which will then be used to create the UI.
175
202
  ## Client Config
176
203
 
data/envoy-hooks.gemspec CHANGED
@@ -5,13 +5,13 @@ require_relative 'lib/envoy/hooks/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'envoy-hooks'
7
7
  spec.version = Envoy::Hooks::VERSION
8
- spec.authors = ['Jeffrey-Biles-Envoy']
9
- spec.email = ['jeffrey@envoy.com']
8
+ spec.authors = ['Jeffrey-Biles-Envoy', 'Anthony-Floccari-Envoy']
9
+ spec.email = ['afloccari@envoy.com']
10
10
 
11
11
  spec.summary = 'Ruby wrapper for envoy/hooks'
12
12
  # spec.description = "TODO: Write a longer description or delete this line."
13
13
  spec.homepage = 'https://github.com/envoy/envoy-hooks-ruby'
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.7')
15
15
 
16
16
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
17
17
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Envoy
4
4
  class Hooks
5
- VERSION = '0.9.1'
5
+ VERSION = '0.9.3'
6
6
  end
7
7
  end
data/lib/envoy/hooks.rb CHANGED
@@ -9,6 +9,7 @@ module Envoy
9
9
  class Error < StandardError; end
10
10
 
11
11
  attr_reader :jwtToken, :baseUrl, :adapter
12
+
12
13
  def initialize(jwtToken:, baseUrl:, adapter: Faraday.default_adapter, stubs: nil, timeout: 25)
13
14
  @jwtToken = jwtToken
14
15
  @baseUrl = baseUrl
@@ -30,8 +31,9 @@ module Envoy
30
31
  end
31
32
 
32
33
  # Should we require all these, or can we get some from the environment?
33
- def upsertSubscription(subscriptionScope:, clientId:, status:, config: {}, externalId: nil, creatorUserId: nil, authorizedScopes: [])
34
- # NOTE - should we be doing these checks in here, or let the API handle it?
34
+ def upsertSubscription(subscriptionScope:, clientId:, status:, config: {}, externalId: nil, creatorUserId: nil,
35
+ authorizedScopes: [])
36
+ # NOTE: - should we be doing these checks in here, or let the API handle it?
35
37
  if !subscriptionScope || !subscriptionScope[:type] || !subscriptionScope[:id]
36
38
  raise(Error, 'Must fully define a subscriptionScope for `upsertSubscription`')
37
39
  end
@@ -55,9 +57,7 @@ module Envoy
55
57
 
56
58
  validateEnum('responseType', responseType, %w[HTML JSON])
57
59
 
58
- unless resourceType.nil?
59
- validateEnum('resourceType', resourceType, %w[INVITE ENTRY])
60
- end
60
+ validateEnum('resourceType', resourceType, %w[INVITE ENTRY]) unless resourceType.nil?
61
61
 
62
62
  faraday.post("/rest/v1/locations/#{locationId}/hooks/ui/trigger", {
63
63
  locationId: locationId,
@@ -72,6 +72,26 @@ module Envoy
72
72
  })
73
73
  end
74
74
 
75
+ def triggerZoneUIHooks(responseType:, zoneIds:, triggerNames: [], resourceId: nil, resourceIds: [],
76
+ resourceType: nil, accentColor: nil, previewMode: false, uiHookIds: [])
77
+
78
+ validateEnum('responseType', responseType, %w[HTML JSON])
79
+
80
+ validateEnum('resourceType', resourceType, %w[INVITE ENTRY]) unless resourceType.nil?
81
+
82
+ resource_ids = Array(resourceId || resourceIds)
83
+ faraday.post('/rest/v1/zones/hooks/ui/trigger', {
84
+ zoneIds: zoneIds,
85
+ triggerNames: triggerNames,
86
+ responseType: responseType,
87
+ resourceIds: resource_ids,
88
+ resourceType: resourceType,
89
+ accentColor: accentColor,
90
+ previewMode: previewMode,
91
+ uiHookIds: uiHookIds
92
+ })
93
+ end
94
+
75
95
  def subscribedUIHooks(locationId: nil, locationIds: [], triggerName: nil, triggerNames: [], includeHidden: false)
76
96
  faraday.get('/rest/v1/locations/hooks/ui', {
77
97
  locationId: locationId,
@@ -82,6 +102,14 @@ module Envoy
82
102
  })
83
103
  end
84
104
 
105
+ def subscribedZoneUIHooks(zoneIds: [], triggerNames: [], includeHidden: false)
106
+ faraday.get('/rest/v1/zones/hooks/ui', {
107
+ zoneIds: zoneIds,
108
+ triggerNames: triggerNames,
109
+ includeHidden: includeHidden
110
+ })
111
+ end
112
+
85
113
  def triggerEventHooks(locationId:, userEmail: nil, userEmails: [], triggerName: nil,
86
114
  triggerNames: [], resourceId: nil, eventHookIds: [])
87
115
  faraday.post("/rest/v1/locations/#{locationId}/hooks/event/trigger", {
@@ -112,12 +140,8 @@ module Envoy
112
140
  )
113
141
  validateEnum('clientType', clientType, %w[APP PRODUCT])
114
142
  uiHooks.each do |uiHook|
115
- if uiHook[:invocationType] != 'STATIC_CONTENT'
116
- uiHook[:staticContent] = nil
117
- end
118
- if uiHook[:invocationType] != 'DYNAMIC_CONTENT'
119
- uiHook[:invocationURL] = nil
120
- end
143
+ uiHook[:staticContent] = nil if uiHook[:invocationType] != 'STATIC_CONTENT'
144
+ uiHook[:invocationURL] = nil if uiHook[:invocationType] != 'DYNAMIC_CONTENT'
121
145
  end
122
146
  faraday.post("/rest/v1/clients/#{clientId}/config", {
123
147
  clientId: clientId,
@@ -137,7 +161,10 @@ module Envoy
137
161
  end
138
162
 
139
163
  def validateEnum(optionName, testOption, validOptions)
140
- raise(Error, "#{optionName} must be one of the allowed options: #{validOptions.join(', ')}") unless validOptions.include?(testOption)
164
+ return if validOptions.include?(testOption)
165
+
166
+ raise(Error,
167
+ "#{optionName} must be one of the allowed options: #{validOptions.join(', ')}")
141
168
  end
142
169
  end
143
170
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envoy-hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey-Biles-Envoy
8
- autorequire:
8
+ - Anthony-Floccari-Envoy
9
+ autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2022-10-04 00:00:00.000000000 Z
12
+ date: 2023-03-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: faraday
@@ -52,9 +53,9 @@ dependencies:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
55
  version: '1.0'
55
- description:
56
+ description:
56
57
  email:
57
- - jeffrey@envoy.com
58
+ - afloccari@envoy.com
58
59
  executables: []
59
60
  extensions: []
60
61
  extra_rdoc_files: []
@@ -78,7 +79,7 @@ licenses: []
78
79
  metadata:
79
80
  homepage_uri: https://github.com/envoy/envoy-hooks-ruby
80
81
  source_code_uri: https://github.com/envoy/envoy-hooks-ruby
81
- post_install_message:
82
+ post_install_message:
82
83
  rdoc_options: []
83
84
  require_paths:
84
85
  - lib
@@ -86,15 +87,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - ">="
88
89
  - !ruby/object:Gem::Version
89
- version: 2.3.0
90
+ version: 2.7.7
90
91
  required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  requirements:
92
93
  - - ">="
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
96
  requirements: []
96
- rubygems_version: 3.0.3.1
97
- signing_key:
97
+ rubygems_version: 3.1.6
98
+ signing_key:
98
99
  specification_version: 4
99
100
  summary: Ruby wrapper for envoy/hooks
100
101
  test_files: []