Class: MyNewsletterBuilder

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

Overview

$Id: mynewsletterbuilder.rb 67532 2011-09-22 15:50:48Z devin $ Super awesome magic sauce ruby wrapper Follwing any lack of documentation one should reference the main MNB api calls/structure. This is simply a wrapper.

Constant Summary collapse

API_VERSION =
'1.0'
BUILD =
'$Revision: 67532 $'
@@api_host =

Instance variables for wrappers

'api.mynewsletterbuilder.com'
@@timeout =
300

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, validate = false, secure = true) ⇒ MyNewsletterBuilder

Returns a new instance of MyNewsletterBuilder.



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
# File 'lib/mynewsletterbuilder.rb', line 18

def initialize( api_key, validate = false, secure = true )
	if !api_key 
		raise "An api key is required. Contact MyNewsletterBuilder to receive a key"
	end
	
	@api_key    = api_key
	@validation = validate
	@api_secure = { 
					"secure" => secure, 
					"port"   => ( secure ) ? 443 : 80
				  }
	
	# Initilize the XMLRPC client for this instance
	@client     = XMLRPC::Client.new3({
					'host'    => @@api_host,
					'path'    => '/' + API_VERSION + '/',
					'use_ssl' => @api_secure["secure"],
					'port'    => @api_secure["port"],
				  })
				  
	if !@client
		raise "Unable to connect to xmlrpc server with credentials: #{@@api_host}/#{API_VERSION}/ with ssl = #{@api_secure["secure"]}"
	end
	
	@client.http_header_extra = {"MNB_API" => "MNB_API Ruby #{API_VERSION}/$Revision: 67532 $"}
	@client.timeout           = @@timeout 
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



9
10
11
# File 'lib/mynewsletterbuilder.rb', line 9

def api_key
  @api_key
end

#api_secureObject

Returns the value of attribute api_secure.



9
10
11
# File 'lib/mynewsletterbuilder.rb', line 9

def api_secure
  @api_secure
end

#clientObject

Returns the value of attribute client.



9
10
11
# File 'lib/mynewsletterbuilder.rb', line 9

def client
  @client
end

#validationObject

Returns the value of attribute validation.



9
10
11
# File 'lib/mynewsletterbuilder.rb', line 9

def validation
  @validation
end

Instance Method Details

#AccountDetailsObject



429
430
431
# File 'lib/mynewsletterbuilder.rb', line 429

def AccountDetails
	execute( "AccountDetails", '' )
end

#accountKeyCreate(username, password) ⇒ Object



437
438
# File 'lib/mynewsletterbuilder.rb', line 437

def accountKeyCreate ( username, password )
end

#accountKeyDisable(username, password, id_or_key) ⇒ Object



443
444
# File 'lib/mynewsletterbuilder.rb', line 443

def accountKeyDisable ( username, password, id_or_key )
end

#accountKeyEnable(username, password, id_or_key) ⇒ Object



440
441
# File 'lib/mynewsletterbuilder.rb', line 440

def accountKeyEnable ( username, password, id_or_key )
end

#AccountKeys(username, password, disabled = false) ⇒ Object



433
434
435
# File 'lib/mynewsletterbuilder.rb', line 433

def AccountKeys ( username, password, disabled = false )
	
end

#CampaignBounces(id, page = 0, limit = 1000) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/mynewsletterbuilder.rb', line 200

def CampaignBounces ( id, page = 0, limit = 1000 )
	id    = intify( id )
	page  = intify( page )
	limit = intify( limit )
	
	return execute(
		"CampaignBounces",
		id,
		page,
		limit
	)
end

#CampaignClickDetails(id, url_id = 0, page = 0, limit = 1000) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/mynewsletterbuilder.rb', line 235

def CampaignClickDetails ( id, url_id = 0, page = 0, limit = 1000 )
	id     = intify( id )
	url_id = intify( url_id )
	page   = intify( page )
	limit  = intify( limit )
	
	return execute(
		"CampaignClickDetails",
		id,
		url_id,
		page,
		limit
	)
end

#CampaignClicks(id, page = 0, limit = 1000) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/mynewsletterbuilder.rb', line 222

def CampaignClicks ( id, page = 0, limit = 1000 )
	id    = intify( id )
	page  = intify( page )
	limit = intify( limit )
	
	return execute(
		"CampaignClicks",
		id,
		page,
		limit
	)
end

#CampaignCopy(id, name) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/mynewsletterbuilder.rb', line 118

def CampaignCopy ( id, name )
	if !name
		name = ''
	end
	
	return execute(
		"CampaignCopy",
		id,
		name
	)
end

#CampaignCreate(*args) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/mynewsletterbuilder.rb', line 60

def CampaignCreate ( *args )
	name    = args.shift
	subject = args.shift
	from    = args.shift
	reply   = args.shift
	html    = args.shift
	text    = args.shift
	link_tracking = args.shift
	gat     = args.shift
	
	return execute( 
		"CampaignCreate",
		name,
		subject,
		from,
		reply,
		html,
		text,
		link_tracking,
		gat
	)
end

#CampaignDelete(id) ⇒ Object



130
131
132
133
134
135
136
137
# File 'lib/mynewsletterbuilder.rb', line 130

def CampaignDelete ( id )
	id = intify( id )
	
	return execute(
		"CampaignDelete",
		id
	)
end

#CampaignDetails(*args) ⇒ Object



54
55
56
57
58
# File 'lib/mynewsletterbuilder.rb', line 54

def CampaignDetails ( *args )
	id = args.shift
	
	execute( "CampaignDetails", id )
end

#CampaignOpens(id, page = 0, limit = 1000) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/mynewsletterbuilder.rb', line 161

def CampaignOpens ( id, page = 0, limit = 1000 )
	id    = intify( id )
	page  = intify( page )
	limit = intify( limit )
	
	return execute(
		"CampaignOpens",
		id,
		page,
		limit
	)
end

#CampaignRecipients(id, page = 0, limit = 1000) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/mynewsletterbuilder.rb', line 148

def CampaignRecipients ( id, page = 0, limit = 1000 )
	id    = intify( id )
	page  = intify( page )
	limit = intify( limit )
	
	return execute(
		"CampaignRecipients",
		id,
		page,
		limit
	)
end

#Campaigns(filters = []) ⇒ Object



51
52
# File 'lib/mynewsletterbuilder.rb', line 51

def Campaigns ( filters = [] )
end

#CampaignStats(id) ⇒ Object



139
140
141
142
143
144
145
146
# File 'lib/mynewsletterbuilder.rb', line 139

def CampaignStats ( id )
	id = intify( id )
	
	return execute(
		"CampaignStats",
		id
	)
end

#CampaignSubscribes(id, page = 0, limit = 1000) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/mynewsletterbuilder.rb', line 174

def CampaignSubscribes ( id, page = 0, limit = 1000 )
	id    = intify( id )
	page  = intify( page )
	limit = intify( limit )
	
	return execute(
		"CampaignSubscribes",
		id,
		page,
		limit
	)
end

#CampaignUnsubscribes(id, page = 0, limit = 1000) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/mynewsletterbuilder.rb', line 187

def CampaignUnsubscribes ( id, page = 0, limit = 1000 )
	id    = intify( id )
	page  = intify( page )
	limit = intify( limit )
	
	return execute(
		"CampaignUnsubscribes",
		id,
		page,
		limit
	)
end

#CampaignUpdate(*args) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/mynewsletterbuilder.rb', line 83

def CampaignUpdate ( *args )
	id      = args.shift
	details = args.shift
	
	signature = {
		'name'          => { 'value' => 'string' },
		'subject'       => { 'value' => 'string' },
		'html'          => { 'value' => 'string' },
		'text'          => { 'value' => 'string', 'emptyOk' => true },
		'link_tracking' => { 'value' => 'boolean', 'emptyOk' => true },
		'gat'           => { 'value' => 'boolean', 'emptyOk' => true }
	}
	
	signature['from'] = {
		'value' => {
			'name'  => { 'value' => 'string' },
			'email' => { 'value' => 'string' }
		}
	}
	
	signature['reply'] = {
		'value' => {
			'name'  => { 'value' => 'string' },
			'email' => { 'value' => 'string' }
		},
		'emptyOk'   => true
	}
	
	return execute( 
		"CampaignUpdate",
		id,
		details
	)
end

#CampaignUrls(id) ⇒ Object



213
214
215
216
217
218
219
220
# File 'lib/mynewsletterbuilder.rb', line 213

def CampaignUrls ( id ) 
	id = intify( id )
	
	return execute(
		"CampaignUrls",
		id
	)
end

#HelloWorld(val) ⇒ Object



446
447
448
# File 'lib/mynewsletterbuilder.rb', line 446

def HelloWorld ( val )
	execute( "HelloWorld", val )
end

#isSecure?Boolean

public getter for checking if instance will use_ssl xmlrpc communication

Returns:

  • (Boolean)


47
48
49
# File 'lib/mynewsletterbuilder.rb', line 47

def isSecure?
	return @api_secure["secure"]
end

#ListCreate(name, description = '', visible = false, default = false) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/mynewsletterbuilder.rb', line 263

def ListCreate ( name, description = '', visible = false, default = false )
	name    = stringify( name )
	desc    = stringify( description )
	visible = visible
	default = default
	
	return execute(
		"ListCreate",
		name,
		desc,
		visible,
		default
	)
end

#ListDelete(id, delete_subs = false) ⇒ Object



298
299
300
301
302
303
304
305
306
# File 'lib/mynewsletterbuilder.rb', line 298

def ListDelete ( id, delete_subs = false )
	id = intify( id )
	
	return execute(
		"ListDelete",
		id,
		delete_subs
	)
end

#ListDetails(id) ⇒ Object



254
255
256
257
258
259
260
261
# File 'lib/mynewsletterbuilder.rb', line 254

def ListDetails ( id )
	id = intify( id )
	
	return execute(
		"ListDetails",
		id
	)
end

#ListsObject



250
251
252
# File 'lib/mynewsletterbuilder.rb', line 250

def Lists
	return execute("Lists")
end

#ListUpdate(id, name, details) ⇒ Object



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/mynewsletterbuilder.rb', line 278

def ListUpdate ( id, name, details )
	id      = intify( id )
	name    = stringify( name || '' )
	details = details
	
	signature = {
		'name'        => { 'value' => 'string', 'emptyOk' => true },
		'description' => { 'value' => 'string', 'emptyOk' => true },
		'visible'     => { 'value' => 'boolean', 'emptyOk' => true },
		'default'     => { 'value' => 'boolean', 'emptyOk' => true }
	}
	
	return execute(
		"ListUpdate",
		id,
		name,
		details
	)
end

#Subscribe(details, lists, skip_opt_in = false, update_existing = true) ⇒ Object



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/mynewsletterbuilder.rb', line 332

def Subscribe ( details, lists, skip_opt_in = false, update_existing = true )
	details = details
	lists   = lists
	
	signature = {
		'email'        => { 'value' => 'string' },
		'first_name'   => { 'value' => 'string', 'emptyOk' => true },
		'middle_name'  => { 'value' => 'string', 'emptyOk' => true },
		'last_name'    => { 'value' => 'string', 'emptyOk' => true },
		'full_name'    => { 'value' => 'string', 'emptyOk' => true },
		'company_name' => { 'value' => 'string', 'emptyOk' => true },
		'job_title'    => { 'value' => 'string', 'emptyOk' => true },
		'phone_work'   => { 'value' => 'string', 'emptyOk' => true },
		'phone_home'   => { 'value' => 'string', 'emptyOk' => true },
		'address_1'    => { 'value' => 'string', 'emptyOk' => true },
		'address_2'    => { 'value' => 'string', 'emptyOk' => true },
		'address_3'    => { 'value' => 'string', 'emptyOk' => true },
		'city'         => { 'value' => 'string', 'emptyOk' => true },
		'state'        => { 'value' => 'string', 'emptyOk' => true },
		'zip'          => { 'value' => 'string', 'emptyOk' => true },
		'country'      => { 'value' => 'string', 'emptyOk' => true }
	}
	
	return execute(
		"Subscribe",
		details,
		lists,
		skip_opt_in,
		update_existing
	)
end

#SubscribeBatch(subscribers, lists, skip_opt_in = false, update_existing = true) ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/mynewsletterbuilder.rb', line 364

def SubscribeBatch ( subscribers, lists, skip_opt_in = false, update_existing = true )
	signature = {
		'email'        => { 'value' => 'string' },
		'first_name'   => { 'value' => 'string', 'emptyOk' => true },
		'middle_name'  => { 'value' => 'string', 'emptyOk' => true },
		'last_name'    => { 'value' => 'string', 'emptyOk' => true },
		'full_name'    => { 'value' => 'string', 'emptyOk' => true },
		'company_name' => { 'value' => 'string', 'emptyOk' => true },
		'job_title'    => { 'value' => 'string', 'emptyOk' => true },
		'phone_work'   => { 'value' => 'string', 'emptyOk' => true },
		'phone_home'   => { 'value' => 'string', 'emptyOk' => true },
		'address_1'    => { 'value' => 'string', 'emptyOk' => true },
		'address_2'    => { 'value' => 'string', 'emptyOk' => true },
		'address_3'    => { 'value' => 'string', 'emptyOk' => true },
		'city'         => { 'value' => 'string', 'emptyOk' => true },
		'state'        => { 'value' => 'string', 'emptyOk' => true },
		'zip'          => { 'value' => 'string', 'emptyOk' => true },
		'country'      => { 'value' => 'string', 'emptyOk' => true }
	}
	
	return execute(
		"SubscribeBatch",
		subscribers,
		lists,
		skip_opt_in,
		update_existing
	)
end

#SubscribeDeleteBatch(ids_or_emails) ⇒ Object



420
421
422
423
424
425
426
427
# File 'lib/mynewsletterbuilder.rb', line 420

def SubscribeDeleteBatch ( ids_or_emails )
	ids_or_emails = ids_or_emails
	
	return execute(
		"SubscribeDeleteBatch",
		ids_or_emails
	)
end

#SubscriberDelete(id_or_email) ⇒ Object



411
412
413
414
415
416
417
418
# File 'lib/mynewsletterbuilder.rb', line 411

def SubscriberDelete ( id_or_email )
	id_or_email = stringify( id_or_email )
	
	return execute(
		"SubscriberDelete",
		id_or_email
	)
end

#SubscriberDetails(id_or_email) ⇒ Object



323
324
325
326
327
328
329
330
# File 'lib/mynewsletterbuilder.rb', line 323

def SubscriberDetails ( id_or_email )
	id_or_email = stringify( id_or_email )
	
	return execute(
		"SubscriberDetails",
		id_or_email
	)
end

#Subscribers(statuses, lists, page = 0, limit = 1000) ⇒ Object



308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/mynewsletterbuilder.rb', line 308

def Subscribers ( statuses, lists, page = 0, limit = 1000 )
	statuses = statuses
	lists    = lists
	page     = intify( page )
	limit    = intify( limit )
	
	return execute(
		"Subscribers",
		statuses,
		lists,
		page,
		limit
	)
end

#SubscriberUnsubscribe(id_or_email) ⇒ Object



393
394
395
396
397
398
399
400
# File 'lib/mynewsletterbuilder.rb', line 393

def SubscriberUnsubscribe ( id_or_email )
	id_or_email = stringify( id_or_email )
	
	return execute(
		"SubscriberUnsubscribe",
		id_or_email
	)
end

#SubscriberUnsubscribeBatch(ids_or_emails) ⇒ Object



402
403
404
405
406
407
408
409
# File 'lib/mynewsletterbuilder.rb', line 402

def SubscriberUnsubscribeBatch ( ids_or_emails )
	ids_or_emails = ids_or_emails
	
	return execute(
		"SubscribeUnsubscribeBatch",
		ids_or_emails
	)
end