Class: Sendly::EnterpriseWorkspacesSubResource

Inherits:
Object
  • Object
show all
Defined in:
lib/sendly/enterprise.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ EnterpriseWorkspacesSubResource

Returns a new instance of EnterpriseWorkspacesSubResource.



5
6
7
# File 'lib/sendly/enterprise.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#cancel_invitation(workspace_id, invite_id) ⇒ Object

Raises:

  • (ArgumentError)


278
279
280
281
282
283
# File 'lib/sendly/enterprise.rb', line 278

def cancel_invitation(workspace_id, invite_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Invite ID is required" if invite_id.nil? || invite_id.empty?

  @client.delete("/enterprise/workspaces/#{workspace_id}/invitations/#{invite_id}")
end

#create(name:, description: nil) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# File 'lib/sendly/enterprise.rb', line 9

def create(name:, description: nil)
  raise ArgumentError, "Workspace name is required" if name.nil? || name.strip.empty?

  body = { name: name }
  body[:description] = description if description

  @client.post("/enterprise/workspaces", body)
end

#create_key(workspace_id, name: nil, type: nil) ⇒ Object

Raises:

  • (ArgumentError)


137
138
139
140
141
142
143
144
145
# File 'lib/sendly/enterprise.rb', line 137

def create_key(workspace_id, name: nil, type: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  body = {}
  body[:name] = name if name
  body[:type] = type if type

  @client.post("/enterprise/workspaces/#{workspace_id}/keys", body)
end

#create_opt_in_page(workspace_id, business_name:, use_case: nil, use_case_summary: nil, sample_messages: nil) ⇒ Object

Raises:

  • (ArgumentError)


166
167
168
169
170
171
172
173
174
175
176
# File 'lib/sendly/enterprise.rb', line 166

def create_opt_in_page(workspace_id, business_name:, use_case: nil, use_case_summary: nil, sample_messages: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Business name is required" if business_name.nil? || business_name.strip.empty?

  body = { businessName: business_name }
  body[:useCase] = use_case if use_case
  body[:useCaseSummary] = use_case_summary if use_case_summary
  body[:sampleMessages] = sample_messages if sample_messages

  @client.post("/enterprise/workspaces/#{workspace_id}/opt-in-pages", body)
end

#delete(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
# File 'lib/sendly/enterprise.rb', line 28

def delete(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.delete("/enterprise/workspaces/#{workspace_id}")
end

#delete_opt_in_page(workspace_id, page_id) ⇒ Object

Raises:

  • (ArgumentError)


192
193
194
195
196
197
# File 'lib/sendly/enterprise.rb', line 192

def delete_opt_in_page(workspace_id, page_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Page ID is required" if page_id.nil? || page_id.empty?

  @client.delete("/enterprise/workspaces/#{workspace_id}/opt-in-pages/#{page_id}")
end

#delete_webhooks(workspace_id, webhook_id: nil) ⇒ Object

Raises:

  • (ArgumentError)


216
217
218
219
220
221
222
223
# File 'lib/sendly/enterprise.rb', line 216

def delete_webhooks(workspace_id, webhook_id: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  path = "/enterprise/workspaces/#{workspace_id}/webhooks"
  path += "?webhookId=#{webhook_id}" if webhook_id

  @client.delete(path)
end

#get(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'lib/sendly/enterprise.rb', line 22

def get(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}")
end

#get_credits(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


131
132
133
134
135
# File 'lib/sendly/enterprise.rb', line 131

def get_credits(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/credits")
end

#get_quota(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


285
286
287
288
289
# File 'lib/sendly/enterprise.rb', line 285

def get_quota(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/quota")
end

#get_verification(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


114
115
116
117
118
# File 'lib/sendly/enterprise.rb', line 114

def get_verification(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/verification")
end

#inherit_verification(workspace_id, source_workspace_id:) ⇒ Object

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
112
# File 'lib/sendly/enterprise.rb', line 105

def inherit_verification(workspace_id, source_workspace_id:)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Source workspace ID is required" if source_workspace_id.nil? || source_workspace_id.empty?

  @client.post("/enterprise/workspaces/#{workspace_id}/verification/inherit", {
    source_workspace_id: source_workspace_id
  })
end

#listObject



18
19
20
# File 'lib/sendly/enterprise.rb', line 18

def list
  @client.get("/enterprise/workspaces")
end

#list_invitations(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


272
273
274
275
276
# File 'lib/sendly/enterprise.rb', line 272

def list_invitations(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/invitations")
end

#list_keys(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


147
148
149
150
151
# File 'lib/sendly/enterprise.rb', line 147

def list_keys(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/keys")
end

#list_opt_in_pages(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


160
161
162
163
164
# File 'lib/sendly/enterprise.rb', line 160

def list_opt_in_pages(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/opt-in-pages")
end

#list_webhooks(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


210
211
212
213
214
# File 'lib/sendly/enterprise.rb', line 210

def list_webhooks(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.get("/enterprise/workspaces/#{workspace_id}/webhooks")
end

#provision_bulk(workspaces) ⇒ Object

Raises:

  • (ArgumentError)


246
247
248
249
250
251
# File 'lib/sendly/enterprise.rb', line 246

def provision_bulk(workspaces)
  raise ArgumentError, "Workspaces array is required" if workspaces.nil? || !workspaces.is_a?(Array) || workspaces.empty?
  raise ArgumentError, "Maximum 50 workspaces per bulk provision" if workspaces.length > 50

  @client.post("/enterprise/workspaces/provision/bulk", { workspaces: workspaces })
end

#resubmit_verification(workspace_id, **partial_updates) ⇒ Object

Convenience alias for resubmits. Identical to submit_verification but reads more naturally when you only want to update a few fields after a rejection.

client.enterprise.workspaces.resubmit_verification(workspace_id,
  contact: { email: "new@email.com" })


101
102
103
# File 'lib/sendly/enterprise.rb', line 101

def resubmit_verification(workspace_id, **partial_updates)
  submit_verification(workspace_id, **partial_updates)
end

#resume(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


240
241
242
243
244
# File 'lib/sendly/enterprise.rb', line 240

def resume(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.post("/enterprise/workspaces/#{workspace_id}/resume")
end

#revoke_key(workspace_id, key_id) ⇒ Object

Raises:

  • (ArgumentError)


153
154
155
156
157
158
# File 'lib/sendly/enterprise.rb', line 153

def revoke_key(workspace_id, key_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Key ID is required" if key_id.nil? || key_id.empty?

  @client.delete("/enterprise/workspaces/#{workspace_id}/keys/#{key_id}")
end

#send_invitation(workspace_id, email:, role:) ⇒ Object

Raises:

  • (ArgumentError)


261
262
263
264
265
266
267
268
269
270
# File 'lib/sendly/enterprise.rb', line 261

def send_invitation(workspace_id, email:, role:)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Email is required" if email.nil? || email.empty?
  raise ArgumentError, "Role is required" if role.nil? || role.empty?

  @client.post("/enterprise/workspaces/#{workspace_id}/invitations", {
    email: email,
    role: role
  })
end

#set_custom_domain(workspace_id, page_id, domain:) ⇒ Object

Raises:

  • (ArgumentError)


253
254
255
256
257
258
259
# File 'lib/sendly/enterprise.rb', line 253

def set_custom_domain(workspace_id, page_id, domain:)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Page ID is required" if page_id.nil? || page_id.empty?
  raise ArgumentError, "Domain is required" if domain.nil? || domain.empty?

  @client.put("/enterprise/workspaces/#{workspace_id}/pages/#{page_id}/domain", { domain: domain })
end

#set_quota(workspace_id, monthly_message_quota:) ⇒ Object

Raises:

  • (ArgumentError)


291
292
293
294
295
296
297
# File 'lib/sendly/enterprise.rb', line 291

def set_quota(workspace_id, monthly_message_quota:)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.put("/enterprise/workspaces/#{workspace_id}/quota", {
    monthlyMessageQuota: monthly_message_quota
  })
end

#set_webhook(workspace_id, url:, events: nil, description: nil) ⇒ Object

Raises:

  • (ArgumentError)


199
200
201
202
203
204
205
206
207
208
# File 'lib/sendly/enterprise.rb', line 199

def set_webhook(workspace_id, url:, events: nil, description: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Webhook URL is required" if url.nil? || url.empty?

  body = { url: url }
  body[:events] = events if events
  body[:description] = description if description

  @client.put("/enterprise/workspaces/#{workspace_id}/webhooks", body)
end

#submit_verification(workspace_id, business_name: nil, doing_business_as: nil, website: nil, entity_type: nil, address: nil, contact: nil, brn: nil, brn_type: nil, brn_country: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, opt_in_image_urls: nil, monthly_volume: nil, additional_information: nil, age_gated_content: nil, isv_reseller: nil, privacy_url: nil, terms_url: nil) ⇒ Object

Submit (or resubmit) a verification for an enterprise workspace.

Partial-update friendly (May 2026): for resubmit on an existing workspace, you only need to send the fields you want to change —everything else is preserved from the existing record. Hosted page URLs (/biz/, /opt-in/, /legal/) generated during provision are auto-preserved.

For sole proprietors, leave brn/brn_type/brn_country nil — the server strips them before forwarding to the carrier.

Accepts snake_case keyword arguments which are transformed to the camelCase keys the API expects. Nested address and contact hashes should already use camelCase keys (e.g. firstName, lastName) since they are passed through verbatim.

Example (full submit):

client.enterprise.workspaces.submit_verification(workspace_id,
  business_name: "Acme LLC",
  website: "https://acme.com",
  address: { street: "...", city: "...", state: "California", zip: "90001", country: "US" },
  contact: { firstName: "...", lastName: "...", email: "...", phone: "+15551234567" },
  use_case: "Insurance Services",
  use_case_summary: "...",
  sample_messages: "...",
  opt_in_workflow: "...",
  entity_type: "SOLE_PROPRIETOR")

Example (partial-update resubmit, only changing email):

client.enterprise.workspaces.submit_verification(workspace_id,
  contact: { email: "new@email.com" })

Raises:

  • (ArgumentError)


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/sendly/enterprise.rb', line 67

def submit_verification(workspace_id, business_name: nil, doing_business_as: nil, website: nil, entity_type: nil, address: nil, contact: nil, brn: nil, brn_type: nil, brn_country: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, opt_in_image_urls: nil, monthly_volume: nil, additional_information: nil, age_gated_content: nil, isv_reseller: nil, privacy_url: nil, terms_url: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  body = {}
  body[:businessName] = business_name unless business_name.nil?
  body[:doingBusinessAs] = doing_business_as unless doing_business_as.nil?
  body[:website] = website unless website.nil?
  body[:entityType] = entity_type unless entity_type.nil?
  body[:address] = address unless address.nil?
  body[:contact] = contact unless contact.nil?
  body[:brn] = brn unless brn.nil?
  body[:brnType] = brn_type unless brn_type.nil?
  body[:brnCountry] = brn_country unless brn_country.nil?
  body[:useCase] = use_case unless use_case.nil?
  body[:useCaseSummary] = use_case_summary unless use_case_summary.nil?
  body[:sampleMessages] = sample_messages unless sample_messages.nil?
  body[:optInWorkflow] = opt_in_workflow unless opt_in_workflow.nil?
  body[:optInImageUrls] = opt_in_image_urls unless opt_in_image_urls.nil?
  body[:monthlyVolume] = monthly_volume unless monthly_volume.nil?
  body[:additionalInformation] = additional_information unless additional_information.nil?
  body[:ageGatedContent] = age_gated_content unless age_gated_content.nil?
  body[:isvReseller] = isv_reseller unless isv_reseller.nil?
  body[:privacyUrl] = privacy_url unless privacy_url.nil?
  body[:termsUrl] = terms_url unless terms_url.nil?

  @client.post("/enterprise/workspaces/#{workspace_id}/verification/submit", body)
end

#suspend(workspace_id, reason: nil) ⇒ Object

Raises:

  • (ArgumentError)


231
232
233
234
235
236
237
238
# File 'lib/sendly/enterprise.rb', line 231

def suspend(workspace_id, reason: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  body = {}
  body[:reason] = reason if reason

  @client.post("/enterprise/workspaces/#{workspace_id}/suspend", body)
end

#test_webhook(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


225
226
227
228
229
# File 'lib/sendly/enterprise.rb', line 225

def test_webhook(workspace_id)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  @client.post("/enterprise/workspaces/#{workspace_id}/webhooks/test")
end

#transfer_credits(workspace_id, source_workspace_id:, amount:) ⇒ Object

Raises:

  • (ArgumentError)


120
121
122
123
124
125
126
127
128
129
# File 'lib/sendly/enterprise.rb', line 120

def transfer_credits(workspace_id, source_workspace_id:, amount:)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Source workspace ID is required" if source_workspace_id.nil? || source_workspace_id.empty?
  raise ArgumentError, "Amount must be a positive number" if !amount.is_a?(Integer) || amount <= 0

  @client.post("/enterprise/workspaces/#{workspace_id}/transfer-credits", {
    source_workspace_id: source_workspace_id,
    amount: amount
  })
end

#update_opt_in_page(workspace_id, page_id, logo_url: nil, header_color: nil, button_color: nil, custom_headline: nil, custom_benefits: nil) ⇒ Object

Raises:

  • (ArgumentError)


178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/sendly/enterprise.rb', line 178

def update_opt_in_page(workspace_id, page_id, logo_url: nil, header_color: nil, button_color: nil, custom_headline: nil, custom_benefits: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?
  raise ArgumentError, "Page ID is required" if page_id.nil? || page_id.empty?

  body = {}
  body[:logoUrl] = logo_url unless logo_url.nil?
  body[:headerColor] = header_color unless header_color.nil?
  body[:buttonColor] = button_color unless button_color.nil?
  body[:customHeadline] = custom_headline unless custom_headline.nil?
  body[:customBenefits] = custom_benefits unless custom_benefits.nil?

  @client.patch("/enterprise/workspaces/#{workspace_id}/opt-in-pages/#{page_id}", body)
end