1 | var mocha = require('mocha');
|
2 | var assert = require('assert');
|
3 | var nconf = require('nconf');
|
4 | var testingKeys = nconf.env().file({
|
5 | file: __dirname + '/testing_keys.json'
|
6 | });
|
7 | var util = require('util');
|
8 | var merge = require('merge');
|
9 |
|
10 | var postmark = require('../lib/postmark/index.js');
|
11 |
|
12 | describe('client stats operations', function() {
|
13 |
|
14 | this.timeout(30000);
|
15 | var _client = null;
|
16 |
|
17 | beforeEach(function() {
|
18 | _client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN'));
|
19 | });
|
20 |
|
21 | it('can get message opens', function(done) {
|
22 | _client.getMessageOpens({
|
23 | count: 5
|
24 | }, done);
|
25 | });
|
26 |
|
27 | it('can get delivery statistics', function(done) {
|
28 | _client.getDeliveryStatistics(done);
|
29 | });
|
30 |
|
31 | it('can get sent counts', function(done) {
|
32 | _client.getSentCounts(done);
|
33 | });
|
34 |
|
35 | it('can get bounce counts', function(done) {
|
36 | _client.getBounceCounts(done);
|
37 | });
|
38 |
|
39 | it('can get spam complaints', function(done) {
|
40 | _client.getSpamComplaints(done);
|
41 | });
|
42 |
|
43 | it('can get tracked email counts', function(done) {
|
44 | _client.getTrackedEmailCounts(done);
|
45 | });
|
46 |
|
47 | it('can get email open counts', function(done) {
|
48 | _client.getEmailOpenCounts(done);
|
49 | });
|
50 |
|
51 | it('can get email platform usage', function(done) {
|
52 | _client.getEmailPlatformUsage(done);
|
53 | });
|
54 |
|
55 | it('can get email client usage', function(done) {
|
56 | _client.getEmailClientUsage(done);
|
57 | });
|
58 |
|
59 | it('can get bounce counts', function(done) {
|
60 | _client.getMessageOpens(done);
|
61 | });
|
62 |
|
63 | it('can get message opens for single message', function(done) {
|
64 | _client.getMessageOpens({
|
65 | count: 1
|
66 | }, function(err, batch) {
|
67 | _client.getMessageOpensForSingleMessage(batch.Opens[0].MessageID, {
|
68 | count: 1
|
69 | },
|
70 | done);
|
71 | });
|
72 | });
|
73 |
|
74 | it('can get outbound overview', function(done) {
|
75 | var now = new Date();
|
76 | var yesterday = new Date(now.valueOf() - (24 * 3600 * 1000));
|
77 | var toDate = '' + now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
|
78 | var fromDate = '' + yesterday.getFullYear() + '-' + (yesterday.getMonth() + 1) + '-' + yesterday.getDate();
|
79 |
|
80 | _client.getOuboundOverview({
|
81 | fromdate: fromDate,
|
82 | todate: toDate
|
83 | }, done);
|
84 | });
|
85 |
|
86 | }); |
\ | No newline at end of file |