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)


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

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)


85
86
87
88
89
90
91
92
93
# File 'lib/sendly/enterprise.rb', line 85

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)


114
115
116
117
118
119
120
121
122
123
124
# File 'lib/sendly/enterprise.rb', line 114

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)


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

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)


164
165
166
167
168
169
170
171
# File 'lib/sendly/enterprise.rb', line 164

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)


79
80
81
82
83
# File 'lib/sendly/enterprise.rb', line 79

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)


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

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)


62
63
64
65
66
# File 'lib/sendly/enterprise.rb', line 62

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)


53
54
55
56
57
58
59
60
# File 'lib/sendly/enterprise.rb', line 53

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)


220
221
222
223
224
# File 'lib/sendly/enterprise.rb', line 220

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)


95
96
97
98
99
# File 'lib/sendly/enterprise.rb', line 95

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)


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

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)


158
159
160
161
162
# File 'lib/sendly/enterprise.rb', line 158

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)


194
195
196
197
198
199
# File 'lib/sendly/enterprise.rb', line 194

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

#resume(workspace_id) ⇒ Object

Raises:

  • (ArgumentError)


188
189
190
191
192
# File 'lib/sendly/enterprise.rb', line 188

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)


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

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)


209
210
211
212
213
214
215
216
217
218
# File 'lib/sendly/enterprise.rb', line 209

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)


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

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)


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

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)


147
148
149
150
151
152
153
154
155
156
# File 'lib/sendly/enterprise.rb', line 147

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:, business_type:, ein:, address:, city:, state:, zip:, use_case:, sample_messages:, monthly_volume: nil) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/sendly/enterprise.rb', line 34

def submit_verification(workspace_id, business_name:, business_type:, ein:, address:, city:, state:, zip:, use_case:, sample_messages:, monthly_volume: nil)
  raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty?

  body = {
    business_name: business_name,
    business_type: business_type,
    ein: ein,
    address: address,
    city: city,
    state: state,
    zip: zip,
    use_case: use_case,
    sample_messages: sample_messages
  }
  body[:monthly_volume] = monthly_volume if monthly_volume

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

#suspend(workspace_id, reason: nil) ⇒ Object

Raises:

  • (ArgumentError)


179
180
181
182
183
184
185
186
# File 'lib/sendly/enterprise.rb', line 179

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)


173
174
175
176
177
# File 'lib/sendly/enterprise.rb', line 173

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)


68
69
70
71
72
73
74
75
76
77
# File 'lib/sendly/enterprise.rb', line 68

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)


126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/sendly/enterprise.rb', line 126

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