Source

mandrill-api-node / mandrill.coffee

Full commit
   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
  65
  66
  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
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 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
 363
 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
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588

https = require 'https'

OPTS = {
    host:   'mandrillapp.com',
    port:   443,
    prefix: '/api/1.0/',
    method: 'POST',
    headers: {'Content-Type': 'application/json', 'User-Agent': 'Mandrill-Node/1.0.34'}
}

class exports.Mandrill
    constructor: (@apikey=null, @debug=false) ->
        @templates = new Templates(this)
        @exports = new Exports(this)
        @users = new Users(this)
        @rejects = new Rejects(this)
        @inbound = new Inbound(this)
        @tags = new Tags(this)
        @messages = new Messages(this)
        @whitelists = new Whitelists(this)
        @ips = new Ips(this)
        @internal = new Internal(this)
        @subaccounts = new Subaccounts(this)
        @urls = new Urls(this)
        @webhooks = new Webhooks(this)
        @senders = new Senders(this)

        if @apikey == null then @apikey = process.env['MANDRILL_APIKEY']

    call: (uri, params={}, onresult, onerror) ->
        params.key = @apikey
        params = new Buffer(JSON.stringify(params), 'utf8')

        if @debug then console.log("Mandrill: Opening request to https://#{OPTS.host}#{OPTS.prefix}#{uri}.json")
        OPTS.path = "#{OPTS.prefix}#{uri}.json"
        OPTS.headers['Content-Length'] = params.length
        req = https.request(OPTS, (res) =>
            res.setEncoding('utf8')
            json = ''
            res.on('data', (d) =>
                json += d
            )

            res.on('end', =>
                try
                    json = JSON.parse(json)
                catch e
                    json = {status: 'error', name: 'GeneralError', message: e}
                
                json ?= {status: 'error', name: 'GeneralError', message: 'An unexpected error occurred'}
                if res.statusCode != 200
                    if onerror then onerror(json) else @onerror(json)
                else
                    if onresult then onresult(json)
            )
        )
        req.write(params)
        req.end()
        req.on('error', (e) =>
            if onerror then onerror(e) else @onerror({status: 'error', name: 'GeneralError', message: e})
        )

        return null

    onerror: (err) ->
        throw {name: err.name, message: err.message, toString: -> "#{err.name}: #{err.message}"}

class Templates
    constructor: (@master) ->


    ###
    Add a new template
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} name the name for the new template - must be unique
    @option params {String} from_email a default sending address for emails sent using this template
    @option params {String} from_name a default from name to be used
    @option params {String} subject a default subject line to be used
    @option params {String} code the HTML code for the template with mc:edit attributes for the editable elements
    @option params {String} text a default text part to be used when sending with this template
    @option params {Boolean} publish set to false to add a draft template without publishing
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    add: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["from_email"] ?= null
        params["from_name"] ?= null
        params["subject"] ?= null
        params["code"] ?= null
        params["text"] ?= null
        params["publish"] ?= true

        @master.call('templates/add', params, onsuccess, onerror)

    ###
    Get the information for an existing template
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} name the immutable name of an existing template
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('templates/info', params, onsuccess, onerror)

    ###
    Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} name the immutable name of an existing template
    @option params {String} from_email the new default sending address
    @option params {String} from_name the new default from name
    @option params {String} subject the new default subject line
    @option params {String} code the new code for the template
    @option params {String} text the new default text part to be used
    @option params {Boolean} publish set to false to update the draft version of the template without publishing
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    update: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["from_email"] ?= null
        params["from_name"] ?= null
        params["subject"] ?= null
        params["code"] ?= null
        params["text"] ?= null
        params["publish"] ?= true

        @master.call('templates/update', params, onsuccess, onerror)

    ###
    Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} name the immutable name of an existing template
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    publish: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('templates/publish', params, onsuccess, onerror)

    ###
    Delete a template
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} name the immutable name of an existing template
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('templates/delete', params, onsuccess, onerror)

    ###
    Return a list of all the templates available to this user
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('templates/list', params, onsuccess, onerror)

    ###
    Return the recent history (hourly stats for the last 30 days) for a template
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} name the name of an existing template
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    timeSeries: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('templates/time-series', params, onsuccess, onerror)

    ###
    Inject content and optionally merge fields into a template, returning the HTML that results
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} template_name the immutable name of a template that exists in the user's account
    @option params {Array} template_content an array of template content to render.  Each item in the array should be a struct with two keys - name: the name of the content block to set the content for, and content: the actual content to put into the block
         - template_content[] {Object} the injection of a single piece of content into a single editable region
             - name {String} the name of the mc:edit editable region to inject into
             - content {String} the content to inject
    @option params {Array} merge_vars optional merge variables to use for injecting merge field content.  If this is not provided, no merge fields will be replaced.
         - merge_vars[] {Object} a single merge variable
             - name {String} the merge variable's name. Merge variable names are case-insensitive and may not start with _
             - content {String} the merge variable's content
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    render: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["merge_vars"] ?= null

        @master.call('templates/render', params, onsuccess, onerror)
class Exports
    constructor: (@master) ->


    ###
    Returns information about an export job. If the export job's state is 'complete',
the returned data will include a URL you can use to fetch the results. Every export
job produces a zip archive, but the format of the archive is distinct for each job
type. The api calls that initiate exports include more details about the output format
for that job type.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id an export job identifier
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('exports/info', params, onsuccess, onerror)

    ###
    Returns a list of your exports.
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('exports/list', params, onsuccess, onerror)

    ###
    Begins an export of your rejection blacklist. The blacklist will be exported to a zip archive
containing a single file named rejects.csv that includes the following fields: email,
reason, detail, created_at, expires_at, last_event_at, expires_at.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} notify_email an optional email address to notify when the export job has finished.
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    rejects: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["notify_email"] ?= null

        @master.call('exports/rejects', params, onsuccess, onerror)

    ###
    Begins an export of your rejection whitelist. The whitelist will be exported to a zip archive
containing a single file named whitelist.csv that includes the following fields:
email, detail, created_at.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} notify_email an optional email address to notify when the export job has finished.
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    whitelist: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["notify_email"] ?= null

        @master.call('exports/whitelist', params, onsuccess, onerror)

    ###
    Begins an export of your activity history. The activity will be exported to a zip archive
containing a single file named activity.csv in the same format as you would be able to export
from your account's activity view. It includes the following fields: Date, Email Address,
Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom
metadata fields, they will be included in the exported data.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} notify_email an optional email address to notify when the export job has finished
    @option params {String} date_from start date as a UTC string in YYYY-MM-DD HH:MM:SS format
    @option params {String} date_to end date as a UTC string in YYYY-MM-DD HH:MM:SS format
    @option params {Array} tags an array of tag names to narrow the export to; will match messages that contain ANY of the tags
         - tags[] {String} a tag name
    @option params {Array} senders an array of senders to narrow the export to
         - senders[] {String} a sender address
    @option params {Array} states an array of states to narrow the export to; messages with ANY of the states will be included
         - states[] {String} a message state
    @option params {Array} api_keys an array of api keys to narrow the export to; messsagse sent with ANY of the keys will be included
         - api_keys[] {String} an API key associated with your account
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    activity: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["notify_email"] ?= null
        params["date_from"] ?= null
        params["date_to"] ?= null
        params["tags"] ?= null
        params["senders"] ?= null
        params["states"] ?= null
        params["api_keys"] ?= null

        @master.call('exports/activity', params, onsuccess, onerror)
class Users
    constructor: (@master) ->


    ###
    Return the information about the API-connected user
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('users/info', params, onsuccess, onerror)

    ###
    Validate an API key and respond to a ping
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    ping: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('users/ping', params, onsuccess, onerror)

    ###
    Validate an API key and respond to a ping (anal JSON parser version)
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    ping2: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('users/ping2', params, onsuccess, onerror)

    ###
    Return the senders that have tried to use this account, both verified and unverified
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    senders: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('users/senders', params, onsuccess, onerror)
class Rejects
    constructor: (@master) ->


    ###
    Adds an email to your email rejection blacklist. Addresses that you
add manually will never expire and there is no reputation penalty
for removing them from your blacklist. Attempting to blacklist an
address that has been whitelisted will have no effect.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} email an email address to block
    @option params {String} comment an optional comment describing the rejection
    @option params {String} subaccount an optional unique identifier for the subaccount to limit the blacklist entry
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    add: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["comment"] ?= null
        params["subaccount"] ?= null

        @master.call('rejects/add', params, onsuccess, onerror)

    ###
    Retrieves your email rejection blacklist. You can provide an email
address to limit the results. Returns up to 1000 results. By default,
entries that have expired are excluded from the results; set
include_expired to true to include them.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} email an optional email address to search by
    @option params {Boolean} include_expired whether to include rejections that have already expired.
    @option params {String} subaccount an optional unique identifier for the subaccount to limit the blacklist
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["email"] ?= null
        params["include_expired"] ?= false
        params["subaccount"] ?= null

        @master.call('rejects/list', params, onsuccess, onerror)

    ###
    Deletes an email rejection. There is no limit to how many rejections
you can remove from your blacklist, but keep in mind that each deletion
has an affect on your reputation.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} email an email address
    @option params {String} subaccount an optional unique identifier for the subaccount to limit the blacklist deletion
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["subaccount"] ?= null

        @master.call('rejects/delete', params, onsuccess, onerror)
class Inbound
    constructor: (@master) ->


    ###
    List the domains that have been configured for inbound delivery
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    domains: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('inbound/domains', params, onsuccess, onerror)

    ###
    List the mailbox routes defined for an inbound domain
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} domain the domain to check
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    routes: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('inbound/routes', params, onsuccess, onerror)

    ###
    Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} raw_message the full MIME document of an email message
    @option params {Array|null} to optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document
         - to[] {String} the email address of the recipient
    @option params {String} mail_from the address specified in the MAIL FROM stage of the SMTP conversation. Required for the SPF check.
    @option params {String} helo the identification provided by the client mta in the MTA state of the SMTP conversation. Required for the SPF check.
    @option params {String} client_address the remote MTA's ip address. Optional; required for the SPF check.
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    sendRaw: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["to"] ?= null
        params["mail_from"] ?= null
        params["helo"] ?= null
        params["client_address"] ?= null

        @master.call('inbound/send-raw', params, onsuccess, onerror)
class Tags
    constructor: (@master) ->


    ###
    Return all of the user-defined tag information
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('tags/list', params, onsuccess, onerror)

    ###
    Deletes a tag permanently. Deleting a tag removes the tag from any messages
that have been sent, and also deletes the tag's stats. There is no way to
undo this operation, so use it carefully.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} tag a tag name
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('tags/delete', params, onsuccess, onerror)

    ###
    Return more detailed information about a single tag, including aggregates of recent stats
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} tag an existing tag name
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('tags/info', params, onsuccess, onerror)

    ###
    Return the recent history (hourly stats for the last 30 days) for a tag
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} tag an existing tag name
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    timeSeries: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('tags/time-series', params, onsuccess, onerror)

    ###
    Return the recent history (hourly stats for the last 30 days) for all tags
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    allTimeSeries: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('tags/all-time-series', params, onsuccess, onerror)
class Messages
    constructor: (@master) ->


    ###
    Send a new transactional message through Mandrill
    @param {Object} params the hash of the parameters to pass to the request
    @option params {Struct} message the information on the message to send
         - html {String} the full HTML content to be sent
         - text {String} optional full text content to be sent
         - subject {String} the message subject
         - from_email {String} the sender email address.
         - from_name {String} optional from name to be used
         - to {Array} an array of recipient information.
             - to[] {Object} a single recipient's information.
                 - email {String} the email address of the recipient
                 - name {String} the optional display name to use for the recipient
         - headers {Object} optional extra headers to add to the message (most headers are allowed)
         - important {Boolean} whether or not this message is important, and should be delivered ahead of non-important messages
         - track_opens {Boolean} whether or not to turn on open tracking for the message
         - track_clicks {Boolean} whether or not to turn on click tracking for the message
         - auto_text {Boolean} whether or not to automatically generate a text part for messages that are not given text
         - auto_html {Boolean} whether or not to automatically generate an HTML part for messages that are not given HTML
         - inline_css {Boolean} whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size
         - url_strip_qs {Boolean} whether or not to strip the query string from URLs when aggregating tracked URL data
         - preserve_recipients {Boolean} whether or not to expose all recipients in to "To" header for each email
         - view_content_link {Boolean} set to false to remove content logging for sensitive emails
         - bcc_address {String} an optional address to receive an exact copy of each recipient's email
         - tracking_domain {String} a custom domain to use for tracking opens and clicks instead of mandrillapp.com
         - signing_domain {String} a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)
         - return_path_domain {String} a custom domain to use for the messages's return-path
         - merge {Boolean} whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided.
         - global_merge_vars {Array} global merge variables to use for all recipients. You can override these per recipient.
             - global_merge_vars[] {Object} a single global merge variable
                 - name {String} the global merge variable's name. Merge variable names are case-insensitive and may not start with _
                 - content {String} the global merge variable's content
         - merge_vars {Array} per-recipient merge variables, which override global merge variables with the same name.
             - merge_vars[] {Object} per-recipient merge variables
                 - rcpt {String} the email address of the recipient that the merge variables should apply to
                 - vars {Array} the recipient's merge variables
                     - vars[] {Object} a single merge variable
                         - name {String} the merge variable's name. Merge variable names are case-insensitive and may not start with _
                         - content {String} the merge variable's content
         - tags {Array} an array of string to tag the message with.  Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently.  Tags should be 50 characters or less.  Any tags starting with an underscore are reserved for internal use and will cause errors.
             - tags[] {String} a single tag - must not start with an underscore
         - subaccount {String} the unique id of a subaccount for this message - must already exist or will fail with an error
         - google_analytics_domains {Array} an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.
         - google_analytics_campaign {Array|string} optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.
         - metadata {Array} metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.
         - recipient_metadata {Array} Per-recipient metadata that will override the global values specified in the metadata parameter.
             - recipient_metadata[] {Object} metadata for a single recipient
                 - rcpt {String} the email address of the recipient that the metadata is associated with
                 - values {Array} an associated array containing the recipient's unique metadata. If a key exists in both the per-recipient metadata and the global metadata, the per-recipient metadata will be used.
         - attachments {Array} an array of supported attachments to add to the message
             - attachments[] {Object} a single supported attachment
                 - type {String} the MIME type of the attachment
                 - name {String} the file name of the attachment
                 - content {String} the content of the attachment as a base64-encoded string
         - images {Array} an array of embedded images to add to the message
             - images[] {Object} a single embedded image
                 - type {String} the MIME type of the image - must start with "image/"
                 - name {String} the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
                 - content {String} the content of the image as a base64-encoded string
    @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
    @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
    @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    send: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["async"] ?= false
        params["ip_pool"] ?= null
        params["send_at"] ?= null

        @master.call('messages/send', params, onsuccess, onerror)

    ###
    Send a new transactional message through Mandrill using a template
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} template_name the immutable name or slug of a template that exists in the user's account. For backwards-compatibility, the template name may also be used but the immutable slug is preferred.
    @option params {Array} template_content an array of template content to send.  Each item in the array should be a struct with two keys - name: the name of the content block to set the content for, and content: the actual content to put into the block
         - template_content[] {Object} the injection of a single piece of content into a single editable region
             - name {String} the name of the mc:edit editable region to inject into
             - content {String} the content to inject
    @option params {Struct} message the other information on the message to send - same as /messages/send, but without the html content
         - html {String} optional full HTML content to be sent if not in template
         - text {String} optional full text content to be sent
         - subject {String} the message subject
         - from_email {String} the sender email address.
         - from_name {String} optional from name to be used
         - to {Array} an array of recipient information.
             - to[] {Object} a single recipient's information.
                 - email {String} the email address of the recipient
                 - name {String} the optional display name to use for the recipient
         - headers {Object} optional extra headers to add to the message (most headers are allowed)
         - important {Boolean} whether or not this message is important, and should be delivered ahead of non-important messages
         - track_opens {Boolean} whether or not to turn on open tracking for the message
         - track_clicks {Boolean} whether or not to turn on click tracking for the message
         - auto_text {Boolean} whether or not to automatically generate a text part for messages that are not given text
         - auto_html {Boolean} whether or not to automatically generate an HTML part for messages that are not given HTML
         - inline_css {Boolean} whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size
         - url_strip_qs {Boolean} whether or not to strip the query string from URLs when aggregating tracked URL data
         - preserve_recipients {Boolean} whether or not to expose all recipients in to "To" header for each email
         - view_content_link {Boolean} set to false to remove content logging for sensitive emails
         - bcc_address {String} an optional address to receive an exact copy of each recipient's email
         - tracking_domain {String} a custom domain to use for tracking opens and clicks instead of mandrillapp.com
         - signing_domain {String} a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)
         - return_path_domain {String} a custom domain to use for the messages's return-path
         - merge {Boolean} whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided.
         - global_merge_vars {Array} global merge variables to use for all recipients. You can override these per recipient.
             - global_merge_vars[] {Object} a single global merge variable
                 - name {String} the global merge variable's name. Merge variable names are case-insensitive and may not start with _
                 - content {String} the global merge variable's content
         - merge_vars {Array} per-recipient merge variables, which override global merge variables with the same name.
             - merge_vars[] {Object} per-recipient merge variables
                 - rcpt {String} the email address of the recipient that the merge variables should apply to
                 - vars {Array} the recipient's merge variables
                     - vars[] {Object} a single merge variable
                         - name {String} the merge variable's name. Merge variable names are case-insensitive and may not start with _
                         - content {String} the merge variable's content
         - tags {Array} an array of string to tag the message with.  Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently.  Tags should be 50 characters or less.  Any tags starting with an underscore are reserved for internal use and will cause errors.
             - tags[] {String} a single tag - must not start with an underscore
         - subaccount {String} the unique id of a subaccount for this message - must already exist or will fail with an error
         - google_analytics_domains {Array} an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.
         - google_analytics_campaign {Array|string} optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.
         - metadata {Array} metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.
         - recipient_metadata {Array} Per-recipient metadata that will override the global values specified in the metadata parameter.
             - recipient_metadata[] {Object} metadata for a single recipient
                 - rcpt {String} the email address of the recipient that the metadata is associated with
                 - values {Array} an associated array containing the recipient's unique metadata. If a key exists in both the per-recipient metadata and the global metadata, the per-recipient metadata will be used.
         - attachments {Array} an array of supported attachments to add to the message
             - attachments[] {Object} a single supported attachment
                 - type {String} the MIME type of the attachment
                 - name {String} the file name of the attachment
                 - content {String} the content of the attachment as a base64-encoded string
         - images {Array} an array of embedded images to add to the message
             - images[] {Object} a single embedded image
                 - type {String} the MIME type of the image - must start with "image/"
                 - name {String} the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
                 - content {String} the content of the image as a base64-encoded string
    @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
    @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
    @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    sendTemplate: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["async"] ?= false
        params["ip_pool"] ?= null
        params["send_at"] ?= null

        @master.call('messages/send-template', params, onsuccess, onerror)

    ###
    Search the content of recently sent messages and optionally narrow by date range, tags and senders
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} query the search terms to find matching messages for
    @option params {String} date_from start date
    @option params {String} date_to end date
    @option params {Array} tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags
    @option params {Array} senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders
    @option params {Array} api_keys an array of API keys to narrow the search to, will return messages sent by ANY of the keys
    @option params {Integer} limit the maximum number of results to return, defaults to 100, 1000 is the maximum
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    search: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["query"] ?= '*'
        params["date_from"] ?= null
        params["date_to"] ?= null
        params["tags"] ?= null
        params["senders"] ?= null
        params["api_keys"] ?= null
        params["limit"] ?= 100

        @master.call('messages/search', params, onsuccess, onerror)

    ###
    Search the content of recently sent messages and return the aggregated hourly stats for matching messages
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} query the search terms to find matching messages for
    @option params {String} date_from start date
    @option params {String} date_to end date
    @option params {Array} tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags
    @option params {Array} senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    searchTimeSeries: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["query"] ?= '*'
        params["date_from"] ?= null
        params["date_to"] ?= null
        params["tags"] ?= null
        params["senders"] ?= null

        @master.call('messages/search-time-series', params, onsuccess, onerror)

    ###
    Get the information for a single recently sent message
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('messages/info', params, onsuccess, onerror)

    ###
    Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} raw_message the full MIME document of an email message
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    parse: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('messages/parse', params, onsuccess, onerror)

    ###
    Take a raw MIME document for a message, and send it exactly as if it were sent through Mandrill's SMTP servers
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} raw_message the full MIME document of an email message
    @option params {String|null} from_email optionally define the sender address - otherwise we'll use the address found in the provided headers
    @option params {String|null} from_name optionally define the sender alias
    @option params {Array|null} to optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document
         - to[] {String} the email address of the recipient
    @option params {Boolean} async enable a background sending mode that is optimized for bulk sending. In async mode, messages/sendRaw will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
    @option params {String} ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
    @option params {String} send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
    @option params {String} return_path_domain a custom domain to use for the messages's return-path
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    sendRaw: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["from_email"] ?= null
        params["from_name"] ?= null
        params["to"] ?= null
        params["async"] ?= false
        params["ip_pool"] ?= null
        params["send_at"] ?= null
        params["return_path_domain"] ?= null

        @master.call('messages/send-raw', params, onsuccess, onerror)

    ###
    Queries your scheduled emails by sender or recipient, or both.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} to an optional recipient address to restrict results to
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    listScheduled: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["to"] ?= null

        @master.call('messages/list-scheduled', params, onsuccess, onerror)

    ###
    Cancels a scheduled email.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    cancelScheduled: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('messages/cancel-scheduled', params, onsuccess, onerror)

    ###
    Reschedules a scheduled email.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
    @option params {String} send_at the new UTC timestamp when the message should sent. Mandrill can't time travel, so if you specify a time in past the message will be sent immediately
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    reschedule: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('messages/reschedule', params, onsuccess, onerror)
class Whitelists
    constructor: (@master) ->


    ###
    Adds an email to your email rejection whitelist. If the address is
currently on your blacklist, that blacklist entry will be removed
automatically.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} email an email address to add to the whitelist
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    add: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('whitelists/add', params, onsuccess, onerror)

    ###
    Retrieves your email rejection whitelist. You can provide an email
address or search prefix to limit the results. Returns up to 1000 results.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} email an optional email address or prefix to search by
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["email"] ?= null

        @master.call('whitelists/list', params, onsuccess, onerror)

    ###
    Removes an email address from the whitelist.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} email the email address to remove from the whitelist
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('whitelists/delete', params, onsuccess, onerror)
class Ips
    constructor: (@master) ->


    ###
    Lists your dedicated IPs.
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/list', params, onsuccess, onerror)

    ###
    Retrieves information about a single dedicated ip.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} ip a dedicated IP address
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/info', params, onsuccess, onerror)

    ###
    Requests an additional dedicated IP for your account. Accounts may
have one outstanding request at any time, and provisioning requests
are processed within 24 hours.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {Boolean} warmup whether to enable warmup mode for the ip
    @option params {String} pool the id of the pool to add the dedicated ip to, or null to use your account's default pool
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    provision: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["warmup"] ?= false
        params["pool"] ?= null

        @master.call('ips/provision', params, onsuccess, onerror)

    ###
    Begins the warmup process for a dedicated IP. During the warmup process,
Mandrill will gradually increase the percentage of your mail that is sent over
the warming-up IP, over a period of roughly 30 days. The rest of your mail
will be sent over shared IPs or other dedicated IPs in the same pool.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} ip a dedicated ip address
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    startWarmup: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/start-warmup', params, onsuccess, onerror)

    ###
    Cancels the warmup process for a dedicated IP.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} ip a dedicated ip address
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    cancelWarmup: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/cancel-warmup', params, onsuccess, onerror)

    ###
    Moves a dedicated IP to a different pool.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} ip a dedicated ip address
    @option params {String} pool the name of the new pool to add the dedicated ip to
    @option params {Boolean} create_pool whether to create the pool if it does not exist; if false and the pool does not exist, an Unknown_Pool will be thrown.
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    setPool: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["create_pool"] ?= false

        @master.call('ips/set-pool', params, onsuccess, onerror)

    ###
    Deletes a dedicated IP. This is permanent and cannot be undone.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} ip the dedicated ip to remove from your account
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/delete', params, onsuccess, onerror)

    ###
    Lists your dedicated IP pools.
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    listPools: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/list-pools', params, onsuccess, onerror)

    ###
    Describes a single dedicated IP pool.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} pool a pool name
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    poolInfo: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/pool-info', params, onsuccess, onerror)

    ###
    Creates a pool and returns it. If a pool already exists with this
name, no action will be performed.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} pool the name of a pool to create
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    createPool: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/create-pool', params, onsuccess, onerror)

    ###
    Deletes a pool. A pool must be empty before you can delete it, and you cannot delete your default pool.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} pool the name of the pool to delete
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    deletePool: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('ips/delete-pool', params, onsuccess, onerror)
class Internal
    constructor: (@master) ->

class Subaccounts
    constructor: (@master) ->


    ###
    Get the list of subaccounts defined for the account, optionally filtered by a prefix
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} q an optional prefix to filter the subaccounts' ids and names
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["q"] ?= null

        @master.call('subaccounts/list', params, onsuccess, onerror)

    ###
    Add a new subaccount
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id a unique identifier for the subaccount to be used in sending calls
    @option params {String} name an optional display name to further identify the subaccount
    @option params {String} notes optional extra text to associate with the subaccount
    @option params {Integer} custom_quota an optional manual hourly quota for the subaccount. If not specified, Mandrill will manage this based on reputation
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    add: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["name"] ?= null
        params["notes"] ?= null
        params["custom_quota"] ?= null

        @master.call('subaccounts/add', params, onsuccess, onerror)

    ###
    Given the ID of an existing subaccount, return the data about it
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id the unique identifier of the subaccount to query
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('subaccounts/info', params, onsuccess, onerror)

    ###
    Update an existing subaccount
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id the unique identifier of the subaccount to update
    @option params {String} name an optional display name to further identify the subaccount
    @option params {String} notes optional extra text to associate with the subaccount
    @option params {Integer} custom_quota an optional manual hourly quota for the subaccount. If not specified, Mandrill will manage this based on reputation
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    update: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["name"] ?= null
        params["notes"] ?= null
        params["custom_quota"] ?= null

        @master.call('subaccounts/update', params, onsuccess, onerror)

    ###
    Delete an existing subaccount. Any email related to the subaccount will be saved, but stats will be removed and any future sending calls to this subaccount will fail.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id the unique identifier of the subaccount to delete
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('subaccounts/delete', params, onsuccess, onerror)

    ###
    Pause a subaccount's sending. Any future emails delivered to this subaccount will be queued for a maximum of 3 days until the subaccount is resumed.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id the unique identifier of the subaccount to pause
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    pause: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('subaccounts/pause', params, onsuccess, onerror)

    ###
    Resume a paused subaccount's sending
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} id the unique identifier of the subaccount to resume
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    resume: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('subaccounts/resume', params, onsuccess, onerror)
class Urls
    constructor: (@master) ->


    ###
    Get the 100 most clicked URLs
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('urls/list', params, onsuccess, onerror)

    ###
    Return the 100 most clicked URLs that match the search query given
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} q a search query
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    search: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('urls/search', params, onsuccess, onerror)

    ###
    Return the recent history (hourly stats for the last 30 days) for a url
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} url an existing URL
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    timeSeries: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('urls/time-series', params, onsuccess, onerror)
class Webhooks
    constructor: (@master) ->


    ###
    Get the list of all webhooks defined on the account
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('webhooks/list', params, onsuccess, onerror)

    ###
    Add a new webhook
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} url the URL to POST batches of events
    @option params {String} description an optional description of the webhook
    @option params {Array} events an optional list of events that will be posted to the webhook
         - events[] {String} the individual event to listen for
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    add: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["description"] ?= null
        params["events"] ?= []

        @master.call('webhooks/add', params, onsuccess, onerror)

    ###
    Given the ID of an existing webhook, return the data about it
    @param {Object} params the hash of the parameters to pass to the request
    @option params {Integer} id the unique identifier of a webhook belonging to this account
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('webhooks/info', params, onsuccess, onerror)

    ###
    Update an existing webhook
    @param {Object} params the hash of the parameters to pass to the request
    @option params {Integer} id the unique identifier of a webhook belonging to this account
    @option params {String} url the URL to POST batches of events
    @option params {String} description an optional description of the webhook
    @option params {Array} events an optional list of events that will be posted to the webhook
         - events[] {String} the individual event to listen for
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    update: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}

        params["description"] ?= null
        params["events"] ?= []

        @master.call('webhooks/update', params, onsuccess, onerror)

    ###
    Delete an existing webhook
    @param {Object} params the hash of the parameters to pass to the request
    @option params {Integer} id the unique identifier of a webhook belonging to this account
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    delete: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('webhooks/delete', params, onsuccess, onerror)
class Senders
    constructor: (@master) ->


    ###
    Return the senders that have tried to use this account.
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    list: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/list', params, onsuccess, onerror)

    ###
    Returns the sender domains that have been added to this account.
    @param {Object} params the hash of the parameters to pass to the request
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    domains: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/domains', params, onsuccess, onerror)

    ###
    Adds a sender domain to your account. Sender domains are added automatically as you
send, but you can use this call to add them ahead of time.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} domain a domain name
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    addDomain: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/add-domain', params, onsuccess, onerror)

    ###
    Checks the SPF and DKIM settings for a domain. If you haven't already added this domain to your
account, it will be added automatically.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} domain a domain name
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    checkDomain: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/check-domain', params, onsuccess, onerror)

    ###
    Sends a verification email in order to verify ownership of a domain.
Domain verification is an optional step to confirm ownership of a domain. Once a
domain has been verified in a Mandrill account, other accounts may not have their
messages signed by that domain unless they also verify the domain. This prevents
other Mandrill accounts from sending mail signed by your domain.
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} domain a domain name at which you can receive email
    @option params {String} mailbox a mailbox at the domain where the verification email should be sent
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    verifyDomain: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/verify-domain', params, onsuccess, onerror)

    ###
    Return more detailed information about a single sender, including aggregates of recent stats
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} address the email address of the sender
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    info: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/info', params, onsuccess, onerror)

    ###
    Return the recent history (hourly stats for the last 30 days) for a sender
    @param {Object} params the hash of the parameters to pass to the request
    @option params {String} address the email address of the sender
    @param {Function} onsuccess an optional callback to execute when the API call is successfully made
    @param {Function} onerror an optional callback to execute when the API call errors out - defaults to throwing the error as an exception
    ###
    timeSeries: (params={}, onsuccess, onerror) ->
        if typeof params == 'function'
            onerror = onsuccess
            onsuccess = params
            params = {}


        @master.call('senders/time-series', params, onsuccess, onerror)