mandrill-rb 1.0.52 → 1.0.53

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,219 @@
1
+ module Mandrill
2
+ class Templates
3
+ attr_accessor :master
4
+
5
+ def initialize(master)
6
+ @master = master
7
+ end
8
+
9
+ # Add a new template
10
+ # @param [String] name the name for the new template - must be unique
11
+ # @param [String] from_email a default sending address for emails sent using this template
12
+ # @param [String] from_name a default from name to be used
13
+ # @param [String] subject a default subject line to be used
14
+ # @param [String] code the HTML code for the template with mc:edit attributes for the editable elements
15
+ # @param [String] text a default text part to be used when sending with this template
16
+ # @param [Boolean] publish set to false to add a draft template without publishing
17
+ # @param [Array] labels an optional array of up to 10 labels to use for filtering templates
18
+ # - [String] labels[] a single label
19
+ # @return [Hash] the information saved about the new template
20
+ # - [String] slug the immutable unique code name of the template
21
+ # - [String] name the name of the template
22
+ # - [Array] labels the list of labels applied to the template
23
+ # - [String] labels[] a single label
24
+ # - [String] code the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
25
+ # - [String] subject the subject line of the template, if provided - draft version
26
+ # - [String] from_email the default sender address for the template, if provided - draft version
27
+ # - [String] from_name the default sender from name for the template, if provided - draft version
28
+ # - [String] text the default text part of messages sent with the template, if provided - draft version
29
+ # - [String] publish_name the same as the template name - kept as a separate field for backwards compatibility
30
+ # - [String] publish_code the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
31
+ # - [String] publish_subject the subject line of the template, if provided
32
+ # - [String] publish_from_email the default sender address for the template, if provided
33
+ # - [String] publish_from_name the default sender from name for the template, if provided
34
+ # - [String] publish_text the default text part of messages sent with the template, if provided
35
+ # - [String] published_at the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
36
+ # - [String] created_at the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
37
+ # - [String] updated_at the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
38
+ def add(name, from_email=nil, from_name=nil, subject=nil, code=nil, text=nil, publish=true, labels=[])
39
+ _params = {:name => name, :from_email => from_email, :from_name => from_name, :subject => subject, :code => code, :text => text, :publish => publish, :labels => labels}
40
+ return @master.call 'templates/add', _params
41
+ end
42
+
43
+ # Get the information for an existing template
44
+ # @param [String] name the immutable name of an existing template
45
+ # @return [Hash] the requested template information
46
+ # - [String] slug the immutable unique code name of the template
47
+ # - [String] name the name of the template
48
+ # - [Array] labels the list of labels applied to the template
49
+ # - [String] labels[] a single label
50
+ # - [String] code the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
51
+ # - [String] subject the subject line of the template, if provided - draft version
52
+ # - [String] from_email the default sender address for the template, if provided - draft version
53
+ # - [String] from_name the default sender from name for the template, if provided - draft version
54
+ # - [String] text the default text part of messages sent with the template, if provided - draft version
55
+ # - [String] publish_name the same as the template name - kept as a separate field for backwards compatibility
56
+ # - [String] publish_code the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
57
+ # - [String] publish_subject the subject line of the template, if provided
58
+ # - [String] publish_from_email the default sender address for the template, if provided
59
+ # - [String] publish_from_name the default sender from name for the template, if provided
60
+ # - [String] publish_text the default text part of messages sent with the template, if provided
61
+ # - [String] published_at the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
62
+ # - [String] created_at the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
63
+ # - [String] updated_at the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
64
+ def info(name)
65
+ _params = {:name => name}
66
+ return @master.call 'templates/info', _params
67
+ end
68
+
69
+ # Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.
70
+ # @param [String] name the immutable name of an existing template
71
+ # @param [String] from_email the new default sending address
72
+ # @param [String] from_name the new default from name
73
+ # @param [String] subject the new default subject line
74
+ # @param [String] code the new code for the template
75
+ # @param [String] text the new default text part to be used
76
+ # @param [Boolean] publish set to false to update the draft version of the template without publishing
77
+ # @param [Array] labels an optional array of up to 10 labels to use for filtering templates
78
+ # - [String] labels[] a single label
79
+ # @return [Hash] the template that was updated
80
+ # - [String] slug the immutable unique code name of the template
81
+ # - [String] name the name of the template
82
+ # - [Array] labels the list of labels applied to the template
83
+ # - [String] labels[] a single label
84
+ # - [String] code the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
85
+ # - [String] subject the subject line of the template, if provided - draft version
86
+ # - [String] from_email the default sender address for the template, if provided - draft version
87
+ # - [String] from_name the default sender from name for the template, if provided - draft version
88
+ # - [String] text the default text part of messages sent with the template, if provided - draft version
89
+ # - [String] publish_name the same as the template name - kept as a separate field for backwards compatibility
90
+ # - [String] publish_code the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
91
+ # - [String] publish_subject the subject line of the template, if provided
92
+ # - [String] publish_from_email the default sender address for the template, if provided
93
+ # - [String] publish_from_name the default sender from name for the template, if provided
94
+ # - [String] publish_text the default text part of messages sent with the template, if provided
95
+ # - [String] published_at the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
96
+ # - [String] created_at the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
97
+ # - [String] updated_at the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
98
+ def update(name, from_email=nil, from_name=nil, subject=nil, code=nil, text=nil, publish=true, labels=nil)
99
+ _params = {:name => name, :from_email => from_email, :from_name => from_name, :subject => subject, :code => code, :text => text, :publish => publish, :labels => labels}
100
+ return @master.call 'templates/update', _params
101
+ end
102
+
103
+ # Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.
104
+ # @param [String] name the immutable name of an existing template
105
+ # @return [Hash] the template that was published
106
+ # - [String] slug the immutable unique code name of the template
107
+ # - [String] name the name of the template
108
+ # - [Array] labels the list of labels applied to the template
109
+ # - [String] labels[] a single label
110
+ # - [String] code the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
111
+ # - [String] subject the subject line of the template, if provided - draft version
112
+ # - [String] from_email the default sender address for the template, if provided - draft version
113
+ # - [String] from_name the default sender from name for the template, if provided - draft version
114
+ # - [String] text the default text part of messages sent with the template, if provided - draft version
115
+ # - [String] publish_name the same as the template name - kept as a separate field for backwards compatibility
116
+ # - [String] publish_code the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
117
+ # - [String] publish_subject the subject line of the template, if provided
118
+ # - [String] publish_from_email the default sender address for the template, if provided
119
+ # - [String] publish_from_name the default sender from name for the template, if provided
120
+ # - [String] publish_text the default text part of messages sent with the template, if provided
121
+ # - [String] published_at the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
122
+ # - [String] created_at the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
123
+ # - [String] updated_at the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
124
+ def publish(name)
125
+ _params = {:name => name}
126
+ return @master.call 'templates/publish', _params
127
+ end
128
+
129
+ # Delete a template
130
+ # @param [String] name the immutable name of an existing template
131
+ # @return [Hash] the template that was deleted
132
+ # - [String] slug the immutable unique code name of the template
133
+ # - [String] name the name of the template
134
+ # - [Array] labels the list of labels applied to the template
135
+ # - [String] labels[] a single label
136
+ # - [String] code the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
137
+ # - [String] subject the subject line of the template, if provided - draft version
138
+ # - [String] from_email the default sender address for the template, if provided - draft version
139
+ # - [String] from_name the default sender from name for the template, if provided - draft version
140
+ # - [String] text the default text part of messages sent with the template, if provided - draft version
141
+ # - [String] publish_name the same as the template name - kept as a separate field for backwards compatibility
142
+ # - [String] publish_code the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
143
+ # - [String] publish_subject the subject line of the template, if provided
144
+ # - [String] publish_from_email the default sender address for the template, if provided
145
+ # - [String] publish_from_name the default sender from name for the template, if provided
146
+ # - [String] publish_text the default text part of messages sent with the template, if provided
147
+ # - [String] published_at the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
148
+ # - [String] created_at the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
149
+ # - [String] updated_at the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
150
+ def delete(name)
151
+ _params = {:name => name}
152
+ return @master.call 'templates/delete', _params
153
+ end
154
+
155
+ # Return a list of all the templates available to this user
156
+ # @param [String] label an optional label to filter the templates
157
+ # @return [Array] an array of structs with information about each template
158
+ # - [Hash] return[] the information on each template in the account
159
+ # - [String] slug the immutable unique code name of the template
160
+ # - [String] name the name of the template
161
+ # - [Array] labels the list of labels applied to the template
162
+ # - [String] labels[] a single label
163
+ # - [String] code the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
164
+ # - [String] subject the subject line of the template, if provided - draft version
165
+ # - [String] from_email the default sender address for the template, if provided - draft version
166
+ # - [String] from_name the default sender from name for the template, if provided - draft version
167
+ # - [String] text the default text part of messages sent with the template, if provided - draft version
168
+ # - [String] publish_name the same as the template name - kept as a separate field for backwards compatibility
169
+ # - [String] publish_code the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
170
+ # - [String] publish_subject the subject line of the template, if provided
171
+ # - [String] publish_from_email the default sender address for the template, if provided
172
+ # - [String] publish_from_name the default sender from name for the template, if provided
173
+ # - [String] publish_text the default text part of messages sent with the template, if provided
174
+ # - [String] published_at the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
175
+ # - [String] created_at the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
176
+ # - [String] updated_at the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
177
+ def list(label=nil)
178
+ _params = {:label => label}
179
+ return @master.call 'templates/list', _params
180
+ end
181
+
182
+ # Return the recent history (hourly stats for the last 30 days) for a template
183
+ # @param [String] name the name of an existing template
184
+ # @return [Array] the array of history information
185
+ # - [Hash] return[] the stats for a single hour
186
+ # - [String] time the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
187
+ # - [Integer] sent the number of emails that were sent during the hour
188
+ # - [Integer] hard_bounces the number of emails that hard bounced during the hour
189
+ # - [Integer] soft_bounces the number of emails that soft bounced during the hour
190
+ # - [Integer] rejects the number of emails that were rejected during the hour
191
+ # - [Integer] complaints the number of spam complaints received during the hour
192
+ # - [Integer] opens the number of emails opened during the hour
193
+ # - [Integer] unique_opens the number of unique opens generated by messages sent during the hour
194
+ # - [Integer] clicks the number of tracked URLs clicked during the hour
195
+ # - [Integer] unique_clicks the number of unique clicks generated by messages sent during the hour
196
+ def time_series(name)
197
+ _params = {:name => name}
198
+ return @master.call 'templates/time-series', _params
199
+ end
200
+
201
+ # Inject content and optionally merge fields into a template, returning the HTML that results
202
+ # @param [String] template_name the immutable name of a template that exists in the user's account
203
+ # @param [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
204
+ # - [Hash] template_content[] the injection of a single piece of content into a single editable region
205
+ # - [String] name the name of the mc:edit editable region to inject into
206
+ # - [String] content the content to inject
207
+ # @param [Array] merge_vars optional merge variables to use for injecting merge field content. If this is not provided, no merge fields will be replaced.
208
+ # - [Hash] merge_vars[] a single merge variable
209
+ # - [String] name the merge variable's name. Merge variable names are case-insensitive and may not start with _
210
+ # - [String] content the merge variable's content
211
+ # @return [Hash] the result of rendering the given template with the content and merge field values injected
212
+ # - [String] html the rendered HTML as a string
213
+ def render(template_name, template_content, merge_vars=nil)
214
+ _params = {:template_name => template_name, :template_content => template_content, :merge_vars => merge_vars}
215
+ return @master.call 'templates/render', _params
216
+ end
217
+
218
+ end
219
+ end
@@ -0,0 +1,96 @@
1
+ module Mandrill
2
+ class Urls
3
+ attr_accessor :master
4
+
5
+ def initialize(master)
6
+ @master = master
7
+ end
8
+
9
+ # Get the 100 most clicked URLs
10
+ # @return [Array] the 100 most clicked URLs and their stats
11
+ # - [Hash] return[] the individual URL stats
12
+ # - [String] url the URL to be tracked
13
+ # - [Integer] sent the number of emails that contained the URL
14
+ # - [Integer] clicks the number of times the URL has been clicked from a tracked email
15
+ # - [Integer] unique_clicks the number of unique emails that have generated clicks for this URL
16
+ def list()
17
+ _params = {}
18
+ return @master.call 'urls/list', _params
19
+ end
20
+
21
+ # Return the 100 most clicked URLs that match the search query given
22
+ # @param [String] q a search query
23
+ # @return [Array] the 100 most clicked URLs matching the search query
24
+ # - [Hash] return[] the URL matching the query
25
+ # - [String] url the URL to be tracked
26
+ # - [Integer] sent the number of emails that contained the URL
27
+ # - [Integer] clicks the number of times the URL has been clicked from a tracked email
28
+ # - [Integer] unique_clicks the number of unique emails that have generated clicks for this URL
29
+ def search(q)
30
+ _params = {:q => q}
31
+ return @master.call 'urls/search', _params
32
+ end
33
+
34
+ # Return the recent history (hourly stats for the last 30 days) for a url
35
+ # @param [String] url an existing URL
36
+ # @return [Array] the array of history information
37
+ # - [Hash] return[] the information for a single hour
38
+ # - [String] time the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
39
+ # - [Integer] sent the number of emails that were sent with the URL during the hour
40
+ # - [Integer] clicks the number of times the URL was clicked during the hour
41
+ # - [Integer] unique_clicks the number of unique clicks generated for emails sent with this URL during the hour
42
+ def time_series(url)
43
+ _params = {:url => url}
44
+ return @master.call 'urls/time-series', _params
45
+ end
46
+
47
+ # Get the list of tracking domains set up for this account
48
+ # @return [Array] the tracking domains and their status
49
+ # - [Hash] return[] the individual tracking domain
50
+ # - [String] domain the tracking domain name
51
+ # - [String] created_at the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
52
+ # - [String] last_tested_at when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
53
+ # - [Hash] cname details about the domain's CNAME record
54
+ # - [Boolean] valid whether the domain's CNAME record is valid for use with Mandrill
55
+ # - [String] valid_after when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
56
+ # - [String] error an error describing the CNAME record, or null if the record is correct
57
+ # - [Boolean] valid_tracking whether this domain can be used as a tracking domain for email.
58
+ def tracking_domains()
59
+ _params = {}
60
+ return @master.call 'urls/tracking-domains', _params
61
+ end
62
+
63
+ # Add a tracking domain to your account
64
+ # @param [String] domain a domain name
65
+ # @return [Hash] information about the domain
66
+ # - [String] domain the tracking domain name
67
+ # - [String] created_at the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
68
+ # - [String] last_tested_at when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
69
+ # - [Hash] cname details about the domain's CNAME record
70
+ # - [Boolean] valid whether the domain's CNAME record is valid for use with Mandrill
71
+ # - [String] valid_after when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
72
+ # - [String] error an error describing the CNAME record, or null if the record is correct
73
+ # - [Boolean] valid_tracking whether this domain can be used as a tracking domain for email.
74
+ def add_tracking_domain(domain)
75
+ _params = {:domain => domain}
76
+ return @master.call 'urls/add-tracking-domain', _params
77
+ end
78
+
79
+ # Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call
80
+ # @param [String] domain an existing tracking domain name
81
+ # @return [Hash] information about the tracking domain
82
+ # - [String] domain the tracking domain name
83
+ # - [String] created_at the date and time that the tracking domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
84
+ # - [String] last_tested_at when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
85
+ # - [Hash] cname details about the domain's CNAME record
86
+ # - [Boolean] valid whether the domain's CNAME record is valid for use with Mandrill
87
+ # - [String] valid_after when the domain's CNAME record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
88
+ # - [String] error an error describing the CNAME record, or null if the record is correct
89
+ # - [Boolean] valid_tracking whether this domain can be used as a tracking domain for email.
90
+ def check_tracking_domain(domain)
91
+ _params = {:domain => domain}
92
+ return @master.call 'urls/check-tracking-domain', _params
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,117 @@
1
+ module Mandrill
2
+ class Users
3
+ attr_accessor :master
4
+
5
+ def initialize(master)
6
+ @master = master
7
+ end
8
+
9
+ # Return the information about the API-connected user
10
+ # @return [Hash] the user information including username, key, reputation, quota, and historical sending stats
11
+ # - [String] username the username of the user (used for SMTP authentication)
12
+ # - [String] created_at the date and time that the user's Mandrill account was created as a UTC string in YYYY-MM-DD HH:MM:SS format
13
+ # - [String] public_id a unique, permanent identifier for this user
14
+ # - [Integer] reputation the reputation of the user on a scale from 0 to 100, with 75 generally being a "good" reputation
15
+ # - [Integer] hourly_quota the maximum number of emails Mandrill will deliver for this user each hour. Any emails beyond that will be accepted and queued for later delivery. Users with higher reputations will have higher hourly quotas
16
+ # - [Integer] backlog the number of emails that are queued for delivery due to exceeding your monthly or hourly quotas
17
+ # - [Hash] stats an aggregate summary of the account's sending stats
18
+ # - [Hash] today stats for this user so far today
19
+ # - [Integer] sent the number of emails sent for this user so far today
20
+ # - [Integer] hard_bounces the number of emails hard bounced for this user so far today
21
+ # - [Integer] soft_bounces the number of emails soft bounced for this user so far today
22
+ # - [Integer] rejects the number of emails rejected for sending this user so far today
23
+ # - [Integer] complaints the number of spam complaints for this user so far today
24
+ # - [Integer] unsubs the number of unsubscribes for this user so far today
25
+ # - [Integer] opens the number of times emails have been opened for this user so far today
26
+ # - [Integer] unique_opens the number of unique opens for emails sent for this user so far today
27
+ # - [Integer] clicks the number of URLs that have been clicked for this user so far today
28
+ # - [Integer] unique_clicks the number of unique clicks for emails sent for this user so far today
29
+ # - [Hash] last_7_days stats for this user in the last 7 days
30
+ # - [Integer] sent the number of emails sent for this user in the last 7 days
31
+ # - [Integer] hard_bounces the number of emails hard bounced for this user in the last 7 days
32
+ # - [Integer] soft_bounces the number of emails soft bounced for this user in the last 7 days
33
+ # - [Integer] rejects the number of emails rejected for sending this user in the last 7 days
34
+ # - [Integer] complaints the number of spam complaints for this user in the last 7 days
35
+ # - [Integer] unsubs the number of unsubscribes for this user in the last 7 days
36
+ # - [Integer] opens the number of times emails have been opened for this user in the last 7 days
37
+ # - [Integer] unique_opens the number of unique opens for emails sent for this user in the last 7 days
38
+ # - [Integer] clicks the number of URLs that have been clicked for this user in the last 7 days
39
+ # - [Integer] unique_clicks the number of unique clicks for emails sent for this user in the last 7 days
40
+ # - [Hash] last_30_days stats for this user in the last 30 days
41
+ # - [Integer] sent the number of emails sent for this user in the last 30 days
42
+ # - [Integer] hard_bounces the number of emails hard bounced for this user in the last 30 days
43
+ # - [Integer] soft_bounces the number of emails soft bounced for this user in the last 30 days
44
+ # - [Integer] rejects the number of emails rejected for sending this user in the last 30 days
45
+ # - [Integer] complaints the number of spam complaints for this user in the last 30 days
46
+ # - [Integer] unsubs the number of unsubscribes for this user in the last 30 days
47
+ # - [Integer] opens the number of times emails have been opened for this user in the last 30 days
48
+ # - [Integer] unique_opens the number of unique opens for emails sent for this user in the last 30 days
49
+ # - [Integer] clicks the number of URLs that have been clicked for this user in the last 30 days
50
+ # - [Integer] unique_clicks the number of unique clicks for emails sent for this user in the last 30 days
51
+ # - [Hash] last_60_days stats for this user in the last 60 days
52
+ # - [Integer] sent the number of emails sent for this user in the last 60 days
53
+ # - [Integer] hard_bounces the number of emails hard bounced for this user in the last 60 days
54
+ # - [Integer] soft_bounces the number of emails soft bounced for this user in the last 60 days
55
+ # - [Integer] rejects the number of emails rejected for sending this user in the last 60 days
56
+ # - [Integer] complaints the number of spam complaints for this user in the last 60 days
57
+ # - [Integer] unsubs the number of unsubscribes for this user in the last 60 days
58
+ # - [Integer] opens the number of times emails have been opened for this user in the last 60 days
59
+ # - [Integer] unique_opens the number of unique opens for emails sent for this user in the last 60 days
60
+ # - [Integer] clicks the number of URLs that have been clicked for this user in the last 60 days
61
+ # - [Integer] unique_clicks the number of unique clicks for emails sent for this user in the last 60 days
62
+ # - [Hash] last_90_days stats for this user in the last 90 days
63
+ # - [Integer] sent the number of emails sent for this user in the last 90 days
64
+ # - [Integer] hard_bounces the number of emails hard bounced for this user in the last 90 days
65
+ # - [Integer] soft_bounces the number of emails soft bounced for this user in the last 90 days
66
+ # - [Integer] rejects the number of emails rejected for sending this user in the last 90 days
67
+ # - [Integer] complaints the number of spam complaints for this user in the last 90 days
68
+ # - [Integer] unsubs the number of unsubscribes for this user in the last 90 days
69
+ # - [Integer] opens the number of times emails have been opened for this user in the last 90 days
70
+ # - [Integer] unique_opens the number of unique opens for emails sent for this user in the last 90 days
71
+ # - [Integer] clicks the number of URLs that have been clicked for this user in the last 90 days
72
+ # - [Integer] unique_clicks the number of unique clicks for emails sent for this user in the last 90 days
73
+ # - [Hash] all_time stats for the lifetime of the user's account
74
+ # - [Integer] sent the number of emails sent in the lifetime of the user's account
75
+ # - [Integer] hard_bounces the number of emails hard bounced in the lifetime of the user's account
76
+ # - [Integer] soft_bounces the number of emails soft bounced in the lifetime of the user's account
77
+ # - [Integer] rejects the number of emails rejected for sending this user so far today
78
+ # - [Integer] complaints the number of spam complaints in the lifetime of the user's account
79
+ # - [Integer] unsubs the number of unsubscribes in the lifetime of the user's account
80
+ # - [Integer] opens the number of times emails have been opened in the lifetime of the user's account
81
+ # - [Integer] unique_opens the number of unique opens for emails sent in the lifetime of the user's account
82
+ # - [Integer] clicks the number of URLs that have been clicked in the lifetime of the user's account
83
+ # - [Integer] unique_clicks the number of unique clicks for emails sent in the lifetime of the user's account
84
+ def info()
85
+ _params = {}
86
+ return @master.call 'users/info', _params
87
+ end
88
+
89
+ # Validate an API key and respond to a ping (anal JSON parser version)
90
+ # @return [Hash] a struct with one key "PING" with a static value "PONG!"
91
+ def ping()
92
+ _params = {}
93
+ return @master.call 'users/ping2', _params
94
+ end
95
+
96
+ # Return the senders that have tried to use this account, both verified and unverified
97
+ # @return [Array] an array of sender data, one for each sending addresses used by the account
98
+ # - [Hash] return[] the information on each sending address in the account
99
+ # - [String] address the sender's email address
100
+ # - [String] created_at the date and time that the sender was first seen by Mandrill as a UTC date string in YYYY-MM-DD HH:MM:SS format
101
+ # - [Integer] sent the total number of messages sent by this sender
102
+ # - [Integer] hard_bounces the total number of hard bounces by messages by this sender
103
+ # - [Integer] soft_bounces the total number of soft bounces by messages by this sender
104
+ # - [Integer] rejects the total number of rejected messages by this sender
105
+ # - [Integer] complaints the total number of spam complaints received for messages by this sender
106
+ # - [Integer] unsubs the total number of unsubscribe requests received for messages by this sender
107
+ # - [Integer] opens the total number of times messages by this sender have been opened
108
+ # - [Integer] clicks the total number of times tracked URLs in messages by this sender have been clicked
109
+ # - [Integer] unique_opens the number of unique opens for emails sent for this sender
110
+ # - [Integer] unique_clicks the number of unique clicks for emails sent for this sender
111
+ def senders()
112
+ _params = {}
113
+ return @master.call 'users/senders', _params
114
+ end
115
+
116
+ end
117
+ end
@@ -0,0 +1,3 @@
1
+ module Mandrill
2
+ VERSION = "1.0.53"
3
+ end
@@ -0,0 +1,112 @@
1
+ module Mandrill
2
+ class Webhooks
3
+ attr_accessor :master
4
+
5
+ def initialize(master)
6
+ @master = master
7
+ end
8
+
9
+ # Get the list of all webhooks defined on the account
10
+ # @return [Array] the webhooks associated with the account
11
+ # - [Hash] return[] the individual webhook info
12
+ # - [Integer] id a unique integer indentifier for the webhook
13
+ # - [String] url The URL that the event data will be posted to
14
+ # - [String] description a description of the webhook
15
+ # - [String] auth_key the key used to requests for this webhook
16
+ # - [Array] events The message events that will be posted to the hook
17
+ # - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
18
+ # - [String] created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
19
+ # - [String] last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
20
+ # - [Integer] batches_sent the number of event batches that have ever been sent to this webhook
21
+ # - [Integer] events_sent the total number of events that have ever been sent to this webhook
22
+ # - [String] last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen
23
+ def list()
24
+ _params = {}
25
+ return @master.call 'webhooks/list', _params
26
+ end
27
+
28
+ # Add a new webhook
29
+ # @param [String] url the URL to POST batches of events
30
+ # @param [String] description an optional description of the webhook
31
+ # @param [Array] events an optional list of events that will be posted to the webhook
32
+ # - [String] events[] the individual event to listen for
33
+ # @return [Hash] the information saved about the new webhook
34
+ # - [Integer] id a unique integer indentifier for the webhook
35
+ # - [String] url The URL that the event data will be posted to
36
+ # - [String] description a description of the webhook
37
+ # - [String] auth_key the key used to requests for this webhook
38
+ # - [Array] events The message events that will be posted to the hook
39
+ # - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
40
+ # - [String] created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
41
+ # - [String] last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
42
+ # - [Integer] batches_sent the number of event batches that have ever been sent to this webhook
43
+ # - [Integer] events_sent the total number of events that have ever been sent to this webhook
44
+ # - [String] last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen
45
+ def add(url, description=nil, events=[])
46
+ _params = {:url => url, :description => description, :events => events}
47
+ return @master.call 'webhooks/add', _params
48
+ end
49
+
50
+ # Given the ID of an existing webhook, return the data about it
51
+ # @param [Integer] id the unique identifier of a webhook belonging to this account
52
+ # @return [Hash] the information about the webhook
53
+ # - [Integer] id a unique integer indentifier for the webhook
54
+ # - [String] url The URL that the event data will be posted to
55
+ # - [String] description a description of the webhook
56
+ # - [String] auth_key the key used to requests for this webhook
57
+ # - [Array] events The message events that will be posted to the hook
58
+ # - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
59
+ # - [String] created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
60
+ # - [String] last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
61
+ # - [Integer] batches_sent the number of event batches that have ever been sent to this webhook
62
+ # - [Integer] events_sent the total number of events that have ever been sent to this webhook
63
+ # - [String] last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen
64
+ def info(id)
65
+ _params = {:id => id}
66
+ return @master.call 'webhooks/info', _params
67
+ end
68
+
69
+ # Update an existing webhook
70
+ # @param [Integer] id the unique identifier of a webhook belonging to this account
71
+ # @param [String] url the URL to POST batches of events
72
+ # @param [String] description an optional description of the webhook
73
+ # @param [Array] events an optional list of events that will be posted to the webhook
74
+ # - [String] events[] the individual event to listen for
75
+ # @return [Hash] the information for the updated webhook
76
+ # - [Integer] id a unique integer indentifier for the webhook
77
+ # - [String] url The URL that the event data will be posted to
78
+ # - [String] description a description of the webhook
79
+ # - [String] auth_key the key used to requests for this webhook
80
+ # - [Array] events The message events that will be posted to the hook
81
+ # - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
82
+ # - [String] created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
83
+ # - [String] last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
84
+ # - [Integer] batches_sent the number of event batches that have ever been sent to this webhook
85
+ # - [Integer] events_sent the total number of events that have ever been sent to this webhook
86
+ # - [String] last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen
87
+ def update(id, url, description=nil, events=[])
88
+ _params = {:id => id, :url => url, :description => description, :events => events}
89
+ return @master.call 'webhooks/update', _params
90
+ end
91
+
92
+ # Delete an existing webhook
93
+ # @param [Integer] id the unique identifier of a webhook belonging to this account
94
+ # @return [Hash] the information for the deleted webhook
95
+ # - [Integer] id a unique integer indentifier for the webhook
96
+ # - [String] url The URL that the event data will be posted to
97
+ # - [String] description a description of the webhook
98
+ # - [String] auth_key the key used to requests for this webhook
99
+ # - [Array] events The message events that will be posted to the hook
100
+ # - [String] events[] the individual message event (send, hard_bounce, soft_bounce, open, click, spam, unsub, or reject)
101
+ # - [String] created_at the date and time that the webhook was created as a UTC string in YYYY-MM-DD HH:MM:SS format
102
+ # - [String] last_sent_at the date and time that the webhook last successfully received events as a UTC string in YYYY-MM-DD HH:MM:SS format
103
+ # - [Integer] batches_sent the number of event batches that have ever been sent to this webhook
104
+ # - [Integer] events_sent the total number of events that have ever been sent to this webhook
105
+ # - [String] last_error if we've ever gotten an error trying to post to this webhook, the last error that we've seen
106
+ def delete(id)
107
+ _params = {:id => id}
108
+ return @master.call 'webhooks/delete', _params
109
+ end
110
+
111
+ end
112
+ end