-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_immediate_email.rb
More file actions
58 lines (50 loc) · 2.09 KB
/
send_immediate_email.rb
File metadata and controls
58 lines (50 loc) · 2.09 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
#!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path('lib', __dir__))
require 'ccai'
# Initialize the client
client = CCAI.new(
client_id: '1231',
api_key: 'eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhbmRyZWFzQGFsbGNvZGUuY29tIiwiaXNzIjoiY2xvdWRjb250YWN0IiwibmJmIjoxNzUyMDg5MDk2LCJpYXQiOjE3NTIwODkwOTYsInJvbGUiOiJVU0VSIiwiY2xpZW50SWQiOjEyMzEsImlkIjoxMjIzLCJ0eXBlIjoiQVBJX0tFWSIsImtleV9yYW5kb21faWQiOiIzNTAxZjVmNC0zOWYyLTRjYzctYTk2Yi04ZDkyZjVlMjM5ZGUifQ.XjtDPpyYUJNJjLrpM1pdQ4Sqk90eaagqzPX2v1gwHDP1wOV4fTbB44UGDRXtWyGvN-Fz7o84_Ab-VlAjNCyEmXcDzmzscnwFSbqiZrWLAM_W3Mutd36vArl9QSG_osuYdf9T2wmAduUZu2bcnvKHdBbEaBUalJSSUoHwHsMBX3w'
)
puts "Sending email with immediate send parameters..."
# Try different parameter combinations that might trigger immediate sending
campaign_data = {
subject: 'CCAI Ruby - Immediate Send Test v2',
title: 'Ruby Immediate Send Test v2',
message: '<h1>Hello Andreas!</h1><p>This email tests immediate sending with different parameters.</p><p>Time: ' + Time.now.to_s + '</p>',
senderEmail: 'noreply@allcode.com',
replyEmail: 'support@allcode.com',
senderName: 'CCAI Ruby Client',
accounts: [
{ firstName: 'Andreas', lastName: 'AllCode', email: 'andreas@allcode.com', phone: '' }
],
campaignType: 'EMAIL',
addToList: 'noList',
contactInput: 'accounts',
fromType: 'single',
senders: [],
# Parameters that might trigger immediate sending
scheduled: false,
scheduledTimestamp: nil,
scheduledTimezone: nil,
sendNow: true,
immediate: true,
autoSend: true,
status: 'ACTIVE'
}
begin
response = client.email.send_campaign(campaign_data)
puts "✅ Campaign created: #{response['id']}"
puts "Status: #{response['status']}"
puts "Total Pending: #{response['totalPending']}"
puts "Total Sent: #{response['totalSent']}"
puts "Created: #{response['createdAt']}"
if response['status'] == 'PENDING'
puts "\n⚠️ Campaign is still PENDING"
puts "This might be normal - the system may process it shortly"
puts "Check the CCAI dashboard for campaign ID: #{response['id']}"
end
rescue => e
puts "❌ Failed: #{e.message}"
end