-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_email.rb
More file actions
64 lines (58 loc) · 1.69 KB
/
test_email.rb
File metadata and controls
64 lines (58 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path('lib', __dir__))
require 'ccai'
# Load environment variables
begin
require 'dotenv'
Dotenv.load
rescue LoadError
# dotenv not available, use system env vars
end
# Initialize the client
client = CCAI.new(
client_id: ENV['CCAI_CLIENT_ID'],
api_key: ENV['CCAI_API_KEY']
)
# Test single email
puts "Testing single email..."
begin
response = client.email.send_single(
ENV['TEST_FIRST_NAME'] || 'Test',
ENV['TEST_LAST_NAME'] || 'User',
ENV['TEST_EMAIL'],
ENV['TEST_SUBJECT'] || 'Ruby Client Test',
ENV['TEST_MESSAGE'] || '<h1>Hello!</h1><p>This is a test from the Ruby client.</p>',
ENV['SENDER_EMAIL'],
ENV['REPLY_EMAIL'],
ENV['SENDER_NAME'] || 'CCAI Ruby Client',
ENV['CAMPAIGN_TITLE'] || 'Ruby Email Test'
)
puts "✅ Email sent: #{response}"
rescue => e
puts "❌ Email failed: #{e.message}"
end
# Test email campaign
puts "\nTesting email campaign..."
begin
campaign = {
subject: 'Ruby Campaign Test',
title: 'Ruby Test Campaign',
message: '<h1>Hello ${firstName}!</h1><p>This is a campaign test.</p>',
senderEmail: ENV['SENDER_EMAIL'],
replyEmail: ENV['REPLY_EMAIL'],
senderName: ENV['SENDER_NAME'] || 'CCAI Ruby Client',
accounts: [
{ firstName: ENV['TEST_FIRST_NAME'] || 'Test', lastName: ENV['TEST_LAST_NAME'] || 'User', email: ENV['TEST_EMAIL'], phone: '' }
],
campaignType: 'EMAIL',
addToList: 'noList',
contactInput: 'accounts',
fromType: 'single',
senders: []
}
response = client.email.send_campaign(campaign)
puts "✅ Campaign sent: #{response}"
rescue => e
puts "❌ Campaign failed: #{e.message}"
end