kono_mailup 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -0
  3. data/app/controllers/kono_mailup/application_controller.rb +1 -1
  4. data/app/controllers/kono_mailup/tokens_controller.rb +12 -9
  5. data/db/migrate/20171124083941_create_settings.rb +1 -1
  6. data/lib/generators/kono_mailup/install/install_generator.rb +6 -4
  7. data/lib/generators/kono_mailup/install/templates/initializers.rb +4 -0
  8. data/lib/kono_mailup.rb +5 -0
  9. data/lib/kono_mailup/engine.rb +4 -0
  10. data/lib/kono_mailup/version.rb +1 -1
  11. data/vendor/mailup-ruby/lib/mailup.rb +229 -0
  12. data/vendor/mailup-ruby/lib/mailup/console/base.rb +115 -0
  13. data/vendor/mailup-ruby/lib/mailup/console/email.rb +80 -0
  14. data/vendor/mailup-ruby/lib/mailup/console/group.rb +125 -0
  15. data/vendor/mailup-ruby/lib/mailup/console/images.rb +69 -0
  16. data/vendor/mailup-ruby/lib/mailup/console/import.rb +46 -0
  17. data/vendor/mailup-ruby/lib/mailup/console/list.rb +913 -0
  18. data/vendor/mailup-ruby/lib/mailup/console/recipient.rb +70 -0
  19. data/vendor/mailup-ruby/lib/mailup/console/user.rb +77 -0
  20. data/vendor/mailup-ruby/lib/mailup/errors.rb +18 -0
  21. data/vendor/mailup-ruby/lib/mailup/public/base.rb +18 -0
  22. data/vendor/mailup-ruby/lib/mailup/public/console.rb +75 -0
  23. data/vendor/mailup-ruby/lib/mailup/stats/base.rb +41 -0
  24. data/vendor/mailup-ruby/lib/mailup/stats/message.rb +284 -0
  25. data/vendor/mailup-ruby/lib/mailup/stats/recipient.rb +303 -0
  26. data/vendor/mailup-ruby/lib/mailup/version.rb +4 -0
  27. data/vendor/mailup-ruby/rails/init.rb +1 -0
  28. data/vendor/omniauth-mailup/lib/omniauth-mailup.rb +2 -0
  29. data/vendor/omniauth-mailup/lib/omniauth-mailup/version.rb +5 -0
  30. data/vendor/omniauth-mailup/lib/omniauth/strategies/mailup.rb +41 -0
  31. metadata +45 -12
  32. data/README.rdoc +0 -3
  33. data/app/assets/images/kono_mailup/.keep +0 -0
@@ -0,0 +1,80 @@
1
+ module MailUp
2
+ module Console
3
+ class Email
4
+ attr_accessor :api
5
+
6
+ def initialize(api)
7
+ @api = api
8
+ end
9
+
10
+ # Send single email message to specified recipient.
11
+ #
12
+ # @param [Integer] message_id The ID of the message to send.
13
+ # @param [String] email The email address of the recipient.
14
+ #
15
+ # @return [JSON] A Send object with the following attributes:
16
+ # * idMessage [Integer]
17
+ # * Sent [Integer]
18
+ # * UnprocessedRecipients [Array]
19
+ # * InvalidRecipients [Array]
20
+ #
21
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-SendMailMessageToRecipient
22
+ #
23
+ # @example
24
+ #
25
+ # send = mailup.console.email.send(5, 'joe@public.com')
26
+ # send['Sent']
27
+ # => 1
28
+ #
29
+ def send(message_id, email)
30
+ @api.post("#{@api.path}/Email/Send", body: {:idMessage => message_id, :Email => email})
31
+ end
32
+
33
+ # Schedules a mailing for immediate sending
34
+ #
35
+ # @param [Integer] Id Sending.
36
+ #
37
+ def send_immediate_confirmation(sending_id)
38
+ @api.post("#{@api.path}/Email/Sendings/#{sending_id}/Immediate")
39
+ end
40
+
41
+ # Retrieves the earliest date to schedule the given sending task.
42
+ #
43
+ # @param [Integer] Id Sending.
44
+ #
45
+ def get_deferred_confirmation_date(sending_id)
46
+ @api.get("#{@api.path}/Email/Sendings/#{sending_id}/Deferred")
47
+ end
48
+
49
+ # Sets up a mailing for scheduled delivery
50
+ #
51
+ # @param [Integer] Id Sending.
52
+ # @param [String] :Date date/time for a deferred sending(should be UTC).
53
+ #
54
+ def send_deferred_confirmation(sending_id, date = nil)
55
+ @api.post("#{@api.path}/Email/Sendings/#{sending_id}/Deferred", body: {'Date' => date})
56
+ end
57
+
58
+ # Retrieves the list of email messages that are currently queued up for "immediate sending".
59
+ #
60
+ #
61
+ def get_immediate_confirmation_queque
62
+ @api.get("#{@api.path}/Email/Sendings/Immediate")
63
+ end
64
+
65
+ # Retrieves the list of email messages that are currently queued up for "deferred sending".
66
+ #
67
+ #
68
+ def get_deferred_confirmation_queque
69
+ @api.get("#{@api.path}/Email/Sendings/Deferred")
70
+ end
71
+
72
+ # Retrieves the list of email messages that are neither "scheduled" nor queued up for "immediate sending".
73
+ #
74
+ #
75
+ def get_undefined_confirmation_queque
76
+ @api.get("#{@api.path}/Email/Sendings/Undefined")
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,125 @@
1
+ module MailUp
2
+ module Console
3
+ class Group
4
+ attr_accessor :api
5
+
6
+ def initialize(id, api)
7
+ @api = api
8
+ @id = id
9
+ end
10
+
11
+ # Import a recipient to the specified group(synchronous import).
12
+ #
13
+ # @param [Hash] recipient data, see ConsoleRecipientItems (See http://help.mailup.com/display/mailupapi/Models+v1.1#Modelsv1.1-ConsoleRecipientItem).
14
+ # @param [Hash] params Optional params or filters:
15
+ # @option params [Boolean] :ConfirmEmail Confirmed opt-in option. Default false.
16
+ #
17
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AsyncImportRecipientsToGroup
18
+ #
19
+ def add_recipient(recipient, params = {})
20
+ @api.post("#{@api.path}/Group/#{@id}/Recipient", body: recipient, params: params)
21
+ end
22
+
23
+ # Async Import recipients to the specified group.
24
+ #
25
+ # @param [Array] recipients an array ConsoleRecipientItems (See http://help.mailup.com/display/mailupapi/Models+v1.1#Modelsv1.1-ConsoleRecipientItem).
26
+ # @param [Hash] params Optional params or filters:
27
+ # @option params [Boolean] :ConfirmEmail Confirmed opt-in option. Default false.
28
+ #
29
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AsyncImportRecipientsToGroup
30
+ #
31
+ def add_recipients(recipients, params = {})
32
+ @api.post("#{@api.path}/Group/#{@id}/Recipients", body: recipients, params: params)
33
+ end
34
+
35
+ # Retrieve the recipients in the specified group.
36
+ #
37
+ # @param [Hash] params Optional params or filters:
38
+ # @option params [Integer] :pageNumber The page number to return.
39
+ # @option params [Integer] :pageSize The number of results to per page.
40
+ # @option params [String] :filterby A filtering expression.
41
+ # @option params [String] :orderby The sorting condition for the results.
42
+ #
43
+ # @return [JSON] Results and data including:
44
+ # * IsPaginated [Boolean]
45
+ # * Items [Array<Hash>]
46
+ # * PageNumber [Integer]
47
+ # * PageSize [Integer]
48
+ # * Skipped [Integer]
49
+ # * TotalElementsCount [Integer]
50
+ #
51
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetRecipientsByGroup
52
+ #
53
+ # @example
54
+ #
55
+ # recipients = mailup.console.group(5).recipients
56
+ # recipients['TotalElementsCount']
57
+ # => 125
58
+ # recipients['Items'].first['Name']
59
+ # => "Joe Public"
60
+ #
61
+ def recipients(params = {})
62
+ @api.get("#{@api.path}/Group/#{@id}/Recipients", params: params)
63
+ end
64
+
65
+ # Subscribe the recipient with the related id to the specified group.
66
+ #
67
+ # @param [Integer] recipient_id The ID of the recipient.
68
+ #
69
+ # @return [Boolean] `true` if successful.
70
+ #
71
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-SubscribeRecipientToGroup
72
+ #
73
+ # @example
74
+ #
75
+ # susbcribe = mailup.console.group(5).subscribe(126)
76
+ # => true
77
+ #
78
+ def subscribe(recipient_id)
79
+ @api.post("#{@api.path}/Group/#{@id}/Subscribe/#{recipient_id}")
80
+ end
81
+
82
+ # Unsubscribe the recipient with the related id from the specified group.
83
+ #
84
+ # @param [Integer] recipient_id The ID of the recipient.
85
+ #
86
+ # @return [Boolean] `true` if successful.
87
+ #
88
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UnsubscribeRecipientFromGroup
89
+ #
90
+ # @example
91
+ #
92
+ # unsusbcribe = mailup.console.group(5).unsubscribe(126)
93
+ # => true
94
+ #
95
+ def unsubscribe(recipient_id)
96
+ @api.delete("#{@api.path}/Group/#{@id}/Unsubscribe/#{recipient_id}")
97
+ end
98
+
99
+ # Send email message to all recipient in group.
100
+ #
101
+ # @param [Integer] message_id of the message.
102
+ # @param [Hash] params Optional params or filters:
103
+ # @option params [String] :datetime date/time for a deferred sending(should be UTC).
104
+ #
105
+ # @return [JSON] A Send object with the following attributes:
106
+ # * idMessage [Integer]
107
+ # * Sent [Integer]
108
+ # * UnprocessedRecipients [Array]
109
+ # * InvalidRecipients [Array]
110
+ #
111
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-SendMailMessageToRecipientInGroup
112
+ #
113
+ # @example
114
+ #
115
+ # send = mailup.console.group(5).send_message(1340)
116
+ # send['Sent']
117
+ # => 1794
118
+ #
119
+ def send_message(message_id, params = {})
120
+ @api.post("#{@api.path}/Group/#{@id}/Email/#{message_id}/Send", params: params)
121
+ end
122
+
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,69 @@
1
+ module MailUp
2
+ module Console
3
+ class Images
4
+ attr_accessor :api
5
+
6
+ def initialize(api)
7
+ @api = api
8
+ end
9
+
10
+ # Get the list of all shared images for the current console.
11
+ #
12
+ # @return [Array<String>] An array of Image strings.
13
+ #
14
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetSharedImages
15
+ #
16
+ # @example
17
+ #
18
+ # images = mailup.console.images.list
19
+ # images.size
20
+ # => 50
21
+ #
22
+ def list
23
+ @api.get("#{@api.path}/Images")
24
+ end
25
+
26
+ # Add a new image to the shared images list.
27
+ #
28
+ # @param [Hash] image A hash of image attributes:
29
+ # @option image [String] Name of the image.
30
+ # @option image [String] Base64 data for the image.
31
+ #
32
+ # @return [Array] An array of Image strings.
33
+ #
34
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AddSharedImage
35
+ #
36
+ # @example
37
+ #
38
+ # image = {
39
+ # Name: "TemplateHeader.jpg",
40
+ # Data: "..."
41
+ # }
42
+ # images = mailup.console.images.add_image(image)
43
+ # images.size
44
+ # => 51
45
+ #
46
+ def add_image(image)
47
+ @api.post("#{@api.path}/Images", body:image)
48
+ end
49
+
50
+ # Delete the image corresponding to the provided full path name.
51
+ #
52
+ # @param [String] path The path of the image to delete.
53
+ #
54
+ # @return [Boolean] `true` if successful.
55
+ #
56
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-DeleteImage
57
+ #
58
+ # @example
59
+ #
60
+ # delete = mailup.console.images.delete_image("#{image_path}")
61
+ # => true
62
+ #
63
+ def delete_image(path)
64
+ @api.delete("#{@api.path}/Images", body: path.to_s)
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,46 @@
1
+ module MailUp
2
+ module Console
3
+ class Import
4
+ attr_accessor :api
5
+
6
+ def initialize(id, api)
7
+ @api = api
8
+ @id = id
9
+ end
10
+
11
+ # Get import status.
12
+ #
13
+ # @return [JSON] A Status object with the following attributes:
14
+ # * idImport [Integer]
15
+ # * Completed [Boolean]
16
+ # * UpdatedRecipients [Integer]
17
+ # * ValidRecipients [Integer]
18
+ # * CreatedRecipients [Integer]
19
+ # * ImportedRecipients [Integer]
20
+ # * NotValidRecipients [Integer]
21
+ #
22
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetImportStatus
23
+ #
24
+ # @example
25
+ #
26
+ # status = mailup.console.import(9).status
27
+ # status['Completed']
28
+ # => true
29
+ # status['UpdatedRecipients']
30
+ # => 159
31
+ #
32
+ def status
33
+ @api.get("#{@api.path}/Import/#{@id}")
34
+ end
35
+
36
+ # Get Sending Confirmation Email Id.
37
+ #
38
+ # @see http://help.mailup.com/display/mailupapi/Recipients#Recipients-SendConfirmationEmail
39
+ #
40
+ def confirmation_email_id
41
+ @api.get("#{@api.path}/Import/#{@id}/Sending")
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,913 @@
1
+ module MailUp
2
+ module Console
3
+ class List
4
+ attr_accessor :api
5
+
6
+ def initialize(id, api)
7
+ @api = api
8
+ @id = id
9
+ end
10
+
11
+ # Retrieve groups for the specified list
12
+ #
13
+ # @param [Hash] params Optional params or filters:
14
+ # @option params [Integer] :pageNumber The page number to return.
15
+ # @option params [Integer] :pageSize The number of results to per page.
16
+ # @option params [String] :filterby A filtering expression.
17
+ # @option params [String] :orderby The sorting condition for the results.
18
+ #
19
+ # @return [JSON] Results and data including:
20
+ # * IsPaginated [Boolean]
21
+ # * Items [Array<Hash>]
22
+ # * PageNumber [Integer]
23
+ # * PageSize [Integer]
24
+ # * Skipped [Integer]
25
+ # * TotalElementsCount [Integer]
26
+ #
27
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetConsoleGroupsByList
28
+ #
29
+ # @example
30
+ #
31
+ # list = mailup.console.list(2)
32
+ # groups = list.groups
33
+ # groups['TotalElementsCount']
34
+ # => 10
35
+ #
36
+ # groups = mailup.console.list(2).groups(pageNumber: 0, pageSize: 1)
37
+ #
38
+ def groups(params = {})
39
+ @api.get("#{@api.path}/List/#{@id}/Groups", params: params)
40
+ end
41
+
42
+ # Create a new group for the specified list.
43
+ #
44
+ # @param [Hash] group A hash of group attributes.
45
+ # @option group [String] :Name of the group (required).
46
+ # @option group [String] :Notes to associate with the group (required).
47
+ # @option group [Boolean] :Deletable to flag whether the group can be deleted (required).
48
+ #
49
+ # @return [JSON] The new Group including:
50
+ # * idList [Integer]
51
+ # * idGroup [Integer]
52
+ # * Name [String]
53
+ # * Notes [String]
54
+ # * Deletable [Boolean]
55
+ #
56
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateGroup
57
+ #
58
+ # @example
59
+ #
60
+ # group = {
61
+ # Name: "New Group",
62
+ # Notes: "Created with mailup-rest gem",
63
+ # Deletable: true
64
+ # }
65
+ # new_group = mailup.console.list(2).add_group(group)
66
+ # new_group['idGroup']
67
+ # => 18
68
+ #
69
+ def add_group(group)
70
+ @api.post("#{@api.path}/List/#{@id}/Group", body: group)
71
+ end
72
+
73
+ # Update a group for the specified list.
74
+ #
75
+ # @param [Hash] group A hash of group attributes.
76
+ # @option group [String] :Name of the group (required).
77
+ # @option group [String] :Notes to associate with the group (required).
78
+ # @option group [Boolean] :Deletable to flag whether the group can be deleted (required).
79
+ #
80
+ # @return [JSON] The updated Group including:
81
+ # * idList [Integer]
82
+ # * idGroup [Integer]
83
+ # * Name [String]
84
+ # * Notes [String]
85
+ # * Deletable [Boolean]
86
+ #
87
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateGroup
88
+ #
89
+ # @example
90
+ #
91
+ # group = {
92
+ # Name: "Updated Group",
93
+ # Notes: "Updated with mailup-rest gem",
94
+ # Deletable: true
95
+ # }
96
+ # update = mailup.console.list(2).update_group(50, group)
97
+ # update['idGroup']
98
+ # => "Updated Title"
99
+ #
100
+ def update_group(group_id, group)
101
+ @api.put("#{@api.path}/List/#{@id}/Group/#{group_id}", body: group)
102
+ end
103
+
104
+ # Delete a group from the specified list.
105
+ #
106
+ # @param [Integer] group_id The ID of the group to delete.
107
+ #
108
+ # @return [Boolean] `true` if successful
109
+ #
110
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-DeleteGroup
111
+ #
112
+ # Example:
113
+ #
114
+ # delete = mailup.console.list(2).delete_group(49)
115
+ # => true
116
+ #
117
+ def delete_group(group_id)
118
+ @api.delete("#{@api.path}/List/#{@id}/Group/#{group_id}")
119
+ end
120
+
121
+ # Retrieve the groups subscribed by the recipient in the specified list.
122
+ #
123
+ # @param [Integer] recipient_id The ID of the recipient.
124
+ # @param [Hash] params Optional params or filters:
125
+ # @option params [Integer] :pageNumber The page number to return.
126
+ # @option params [Integer] :pageSize The number of results to per page.
127
+ # @option params [String] :filterby A filtering expression.
128
+ # @option params [String] :orderby The sorting condition for the results.
129
+ #
130
+ # @return [JSON] Results and data including:
131
+ # * IsPaginated [Boolean]
132
+ # * Items [Array<Hash>]
133
+ # * PageNumber [Integer]
134
+ # * PageSize [Integer]
135
+ # * Skipped [Integer]
136
+ # * TotalElementsCount [Integer]
137
+ #
138
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetConsoleGroupsByRecipient
139
+ #
140
+ # @example
141
+ #
142
+ # groups = mailup.console.list(2).recipient_groups(5)
143
+ # groups['TotalElementsCount']
144
+ # => 3
145
+ # groups['Items'].first['Name']
146
+ # => "Group Name"
147
+ #
148
+ # groups = mailup.console.list(2).recipient_groups(5, pageNumber: 0, pageSize: 1)
149
+ #
150
+ def recipient_groups(recipient_id, params = {})
151
+ @api.get("#{@api.path}/List/#{@id}/Recipient/#{recipient_id}/Groups", params: params)
152
+ end
153
+
154
+ # Retrieve pending recipients in the specified list.
155
+ #
156
+ # @param [Hash] params Optional params or filters:
157
+ # @option params [Integer] :pageNumber The page number to return.
158
+ # @option params [Integer] :pageSize The number of results to per page.
159
+ # @option params [String] :filterby A filtering expression.
160
+ # @option params [String] :orderby The sorting condition for the results.
161
+ #
162
+ # @return [JSON] Results and data including:
163
+ # * IsPaginated [Boolean]
164
+ # * Items [Array<Hash>]
165
+ # * PageNumber [Integer]
166
+ # * PageSize [Integer]
167
+ # * Skipped [Integer]
168
+ # * TotalElementsCount [Integer]
169
+ #
170
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetPendingRecipientsByList
171
+ #
172
+ # @example
173
+ #
174
+ # pending = mailup.console.list(2).pending
175
+ # pending['TotalElementsCount']
176
+ # => 3
177
+ # pending['Items'].first['Name']
178
+ # => "Joe Public"
179
+ #
180
+ # pending = mailup.console.list(2).pending(pageNumber: 0, pageSize: 1)
181
+ #
182
+ def pending(params = {})
183
+ @api.get("#{@api.path}/List/#{@id}/Recipients/Pending", params: params)
184
+ end
185
+
186
+ # Retrieve subscribed recipients in the specified list.
187
+ #
188
+ # @param [Hash] params Optional params or filters:
189
+ # @option params [Integer] :pageNumber The page number to return.
190
+ # @option params [Integer] :pageSize The number of results to per page.
191
+ # @option params [String] :filterby A filtering expression.
192
+ # @option params [String] :orderby The sorting condition for the results.
193
+ #
194
+ # @return [JSON] Results and data including:
195
+ # * IsPaginated [Boolean]
196
+ # * Items [Array<Hash>]
197
+ # * PageNumber [Integer]
198
+ # * PageSize [Integer]
199
+ # * Skipped [Integer]
200
+ # * TotalElementsCount [Integer]
201
+ #
202
+ # @see http://help.mailup.com/display/mailupapi/Admin+Console+Methods#AdminConsoleMethods-GetSubscribedRecipientsByList
203
+ #
204
+ # @example
205
+ #
206
+ # subscribed = mailup.console.list(2).subscribed
207
+ # subscribed['TotalElementsCount']
208
+ # => 10
209
+ # subscribed['Items'].first['Name']
210
+ # => "Joe Public"
211
+ #
212
+ # subscribed = mailup.console.list(2).subscribed(pageNumber: 0, pageSize: 1)
213
+ #
214
+ def subscribed(params = {})
215
+ @api.get("#{@api.path}/List/#{@id}/Recipients/Subscribed", params: params)
216
+ end
217
+
218
+ # Retrieve unsubscribed recipients in the specified list.
219
+ #
220
+ # @param [Hash] params Optional params or filters:
221
+ # @option params [Integer] :pageNumber The page number to return.
222
+ # @option params [Integer] :pageSize The number of results to per page.
223
+ # @option params [String] :filterby A filtering expression.
224
+ # @option params [String] :orderby The sorting condition for the results.
225
+ #
226
+ # @return [JSON] Results and data including:
227
+ # * IsPaginated [Boolean]
228
+ # * Items [Array<Hash>]
229
+ # * PageNumber [Integer]
230
+ # * PageSize [Integer]
231
+ # * Skipped [Integer]
232
+ # * TotalElementsCount [Integer]
233
+ #
234
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetUnsubscribedRecipientsByList
235
+ #
236
+ # @example
237
+ #
238
+ # unsubscribed = mailup.console.list(2).unsusbcribed
239
+ # unsubscribed['TotalElementsCount']
240
+ # => 10
241
+ # unsubscribed['Items'].first['Name']
242
+ # => "Joe Public"
243
+ #
244
+ # unsubscribed = mailup.console.list(2).unsusbcribed(pageNumber: 0, pageSize: 1)
245
+ #
246
+ def unsubscribed(params = {})
247
+ @api.get("#{@api.path}/List/#{@id}/Recipients/Unsubscribed", params: params)
248
+ end
249
+
250
+ # Import a single recipient to a list(synchronous import).
251
+ #
252
+ # @param [Hash] recipients An array of Recipients.
253
+ # * idRecipient [Integer] (optional)
254
+ # * Name [String]
255
+ # * Email [String]
256
+ # * MobilePrefix [String]
257
+ # * MobileNumber [String]
258
+ # * Fields [Array]
259
+ #
260
+ # @param [Hash] params Optional params or filters:
261
+ # @option params [Boolean] :ConfirmEmail Confirmed opt-in option. Default false.
262
+ # @option params [String] :importType By setting as 'asOptout' allows you to "import as unsubscribed" a list of specified recipients.
263
+ #
264
+ # @return [Integer] The number of imported recipients.
265
+ #
266
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AsyncImportRecipientsToList
267
+ #
268
+ def import_recipient(recipient, params = {})
269
+ @api.post("#{@api.path}/List/#{@id}/Recipient", {params: params, body: recipient})
270
+ end
271
+
272
+ # Import multiple recipients to a list.
273
+ #
274
+ # @param [Array<Hash>] recipients An array of Recipients.
275
+ # * idRecipient [Integer] (optional)
276
+ # * Name [String]
277
+ # * Email [String]
278
+ # * MobilePrefix [String]
279
+ # * MobileNumber [String]
280
+ # * Fields [Array]
281
+ #
282
+ # @param [Hash] params Optional params or filters:
283
+ # @option params [Boolean] :ConfirmEmail Confirmed opt-in option. Default false.
284
+ # @option params [String] :importType By setting as 'asOptout' allows you to "import as unsubscribed" a list of specified recipients.
285
+ #
286
+ # @return [Integer] The number of imported recipients.
287
+ #
288
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AsyncImportRecipientsToList
289
+ #
290
+ def import_recipients(recipients, params = {})
291
+ @api.post("#{@api.path}/List/#{@id}/Recipients", {params: params, body: recipients})
292
+ end
293
+
294
+ # Subscribe a recipient from the specified list.
295
+ #
296
+ # @param [Integer] recipient_id The ID of the recipient.
297
+ #
298
+ # @return [Boolean] `true` if successful.
299
+ #
300
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-SubscribeRecipientToList
301
+ #
302
+ # @example
303
+ #
304
+ # susbcribe = mailup.console.list(2).subscribe(126)
305
+ # => true
306
+ #
307
+ def subscribe(recipient_id)
308
+ @api.post("#{@api.path}/List/#{@id}/Subscribe/#{recipient_id}")
309
+ end
310
+
311
+ # Unsubscribe a recipient in the specified list.
312
+ #
313
+ # @param [Integer] recipient_id The ID of the recipient.
314
+ #
315
+ # @return [Boolean] `true` if successful.
316
+ #
317
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-RemoveRecipientFromList
318
+ #
319
+ # @example
320
+ #
321
+ # unsusbcribe = mailup.console.list(2).unsubscribe(126)
322
+ # => true
323
+ #
324
+ def unsubscribe(recipient_id)
325
+ @api.delete("#{@api.path}/List/#{@id}/Unsubscribe/#{recipient_id}")
326
+ end
327
+
328
+ # Get the enabled tag list for the specified list id.
329
+ #
330
+ # @param [Hash] params Optional params or filters:
331
+ # @option params [Integer] :pageNumber The page number to return.
332
+ # @option params [Integer] :pageSize The number of results to per page.
333
+ # @option params [String] :filterby A filtering expression.
334
+ # @option params [String] :orderby The sorting condition for the results.
335
+ #
336
+ # @return [JSON] Results and data including:
337
+ # * IsPaginated [Boolean]
338
+ # * Items [Array<Hash>]
339
+ # * PageNumber [Integer]
340
+ # * PageSize [Integer]
341
+ # * Skipped [Integer]
342
+ # * TotalElementsCount [Integer]
343
+ #
344
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetTags
345
+ #
346
+ # @example
347
+ #
348
+ # tags = mailup.console.list(2).tags
349
+ # tags['TotalElementsCount']
350
+ # => 10
351
+ # tags['Items'].first['Enabled']
352
+ # => true
353
+ #
354
+ def tags(params = {})
355
+ @api.get("#{@api.path}/List/#{@id}/Tags", params: params)
356
+ end
357
+ alias_method :enabled_tags, :tags
358
+
359
+ # Add a new tag in the specified list.
360
+ #
361
+ # @param [String] name The name of the tag to create.
362
+ #
363
+ # @return [JSON] The created Tag with the following attributes:
364
+ # * Id [Integer]
365
+ # * Name [String]
366
+ # * Enabled [Boolean]
367
+ #
368
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateTag
369
+ #
370
+ # @example
371
+ #
372
+ # new_tag = mailup.console.list(2).add_tag("My New Tag")
373
+ #
374
+ def add_tag(tag)
375
+ @api.post("#{@api.path}/List/#{@id}/Tag", body: tag)
376
+ end
377
+
378
+ # Update a tag in the specified list.
379
+ #
380
+ # @param [Hash] tag A hash of tag attributes:
381
+ # @option tag [String] :Name of the tag (required).
382
+ # @option tag [Boolean] :Enabled true if tag is enabled.
383
+ #
384
+ # @return [JSON] The updated Tag with the following attributes:
385
+ # * Id [Integer]
386
+ # * Name [String]
387
+ # * Enabled [Boolean]
388
+ #
389
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateTag
390
+ #
391
+ # @example
392
+ #
393
+ # tag = {
394
+ # Id: 1,
395
+ # Name: "Updated Tag",
396
+ # Enabled: false
397
+ # }
398
+ # updated_tag = mailup.console.list(2).update_tag(1, tag)
399
+ # updated_tag
400
+ # => false
401
+ #
402
+ def update_tag(tag_id, tag)
403
+ @api.put("#{@api.path}/List/#{@id}/Tag/#{tag_id}", body: tag)
404
+ end
405
+
406
+ # Delete a tag from the specified list.
407
+ #
408
+ # @param [Integer] idTag The ID of the tag to delete.
409
+ #
410
+ # @return [Boolean] `true` if successful.
411
+ #
412
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-DeleteTag
413
+ #
414
+ # Example:
415
+ #
416
+ # delete = mailup.console.list(2).delete_tag(1)
417
+ # => true
418
+ #
419
+ def delete_tag(tag_id)
420
+ @api.delete("#{@api.path}/List/#{@id}/Tag/#{tag_id}")
421
+ end
422
+
423
+ # Get the attachment list for the specific message.
424
+ #
425
+ # @param [Integer] message_id The ID of the message.
426
+ # @param [Hash] params Optional params or filters:
427
+ # @option params [Integer] :pageNumber The page number to return.
428
+ # @option params [Integer] :pageSize The number of results to per page.
429
+ # @option params [String] :filterby A filtering expression.
430
+ # @option params [String] :orderby The sorting condition for the results.
431
+ #
432
+ # @return [JSON] An array of Attachments with the following attributes:
433
+ # * Slot [Integer]
434
+ # * Name [String]
435
+ # * Path [String]
436
+ #
437
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetMessageAttachments
438
+ #
439
+ # @example
440
+ #
441
+ # attachments = mailup.console.list(2).attachments(34)
442
+ # attachments.size
443
+ # => 3
444
+ #
445
+ def attachments(message_id, params = {})
446
+ @api.get("#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment", params: params)
447
+ end
448
+
449
+ # Add an attachment to the specified message.
450
+ #
451
+ # @param [Integer] message_id The ID of the message.
452
+ # @param [Integer] slot The slot for the attachment.
453
+ # @param [Hash] attachment A hash of recipient attributes:
454
+ # @option attachment [String] :Name of the attachment (required).
455
+ # @option attachment [String] :Path of the attachment (required).
456
+ #
457
+ # @return [JSON] The created Attachment with the following attributes:
458
+ # * Slot [Integer]
459
+ # * Name [String]
460
+ # * Path [String]
461
+ #
462
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AddMessageAttachments
463
+ #
464
+ # @example
465
+ #
466
+ # attachment = {
467
+ # Name: "PDF Attachment",
468
+ # Path: "https://abc123.mailup.com/attachments/..."
469
+ # }
470
+ # attach = mailup.console.list(2).add_attachment(24, 1, attachment)
471
+ # attach.Name
472
+ # => "PDF Attachment"
473
+ #
474
+ def add_attachment(message_id, slot, attachment)
475
+ @api.post("#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment/#{slot}", body: attachment)
476
+ end
477
+
478
+ # Delete an attachment from the specified message.
479
+ #
480
+ # @param [Integer] message_id The ID of the message.
481
+ # @param [Integer] slot The slot of the attachment.
482
+ #
483
+ # @return [Boolean] `true` if successful.
484
+ #
485
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-DeleteMessageAttachments
486
+ #
487
+ # Example:
488
+ #
489
+ # delete = mailup.console.list(2).delete_attachment(49, 3)
490
+ # => true
491
+ #
492
+ def delete_attachment(message_id, slot)
493
+ @api.delete("#{@api.path}/List/#{@id}/Email/#{message_id}/#{slot}")
494
+ end
495
+
496
+ # Get all the images for the specified list.
497
+ #
498
+ # @param [Hash] params Optional params or filters:
499
+ # @option params [Integer] :pageNumber The page number to return.
500
+ # @option params [Integer] :pageSize The number of results to per page.
501
+ # @option params [String] :filterby A filtering expression.
502
+ # @option params [String] :orderby The sorting condition for the results.
503
+ #
504
+ # @return [Array<String>] An array of Image strings.
505
+ #
506
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetListImages
507
+ #
508
+ # @example
509
+ #
510
+ # images = mailup.console.list(2).images
511
+ # images.size
512
+ # => 3
513
+ #
514
+ def images(params = {})
515
+ @api.get("#{@api.path}/List/#{@id}/Images", params: params)
516
+ end
517
+
518
+ # Add a new image to the specified mailing list.
519
+ #
520
+ # @param [Hash] image A hash of Image attributes.
521
+ # @option image [String] Name of the image (required).
522
+ # @option image [String] Data Base64 data for the image (required).
523
+ #
524
+ # @return [String] the created Image URL.
525
+ #
526
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AddListImage
527
+ #
528
+ # @example
529
+ #
530
+ # image = {
531
+ # Name: "New Image",
532
+ # Data: "..."
533
+ # }
534
+ # new_image = mailup.console.list(2).add_image(image)
535
+ # => "https://mailup.com/images/..."
536
+ #
537
+ def add_image(image)
538
+ @api.post("#{@api.path}/List/#{@id}/Images", body: image)
539
+ end
540
+
541
+ # Create an email message in the specified list id from template.
542
+ #
543
+ # @param [Integer] template_id The ID of the template.
544
+ #
545
+ # @return [JSON] The created Message with the following attributes:
546
+ # * idList [Integer]
547
+ # * idMessage [Integer]
548
+ # * Subject [String]
549
+ #
550
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateEmailMessageFromTemplate
551
+ #
552
+ # @example
553
+ #
554
+ # new_message = mailup.console.list(2).add_message_from_template(5)
555
+ # new_message['Subject']
556
+ # => "Subject From Template"
557
+ #
558
+ def add_message_from_template(template_id)
559
+ @api.post("#{@api.path}/List/#{@id}/Email/Template/#{template_id}")
560
+ end
561
+
562
+ # Create an email message in the specified list id.
563
+ #
564
+ # @param [Hash] message A hash of Message attributes:
565
+ # @option message [String] :Subject of the message (required).
566
+ # @option message [String] :Content of the message (required).
567
+ # @option message [String] :Notes of the message (required).
568
+ # @option message [Boolean] :IsConfirmation if it's a confirmation (required).
569
+ # @option message [Boolean] :Embed this message (required).
570
+ # @option message [Array] :Fields to include (See {MailUp::Console::Email#fields}).
571
+ # @option message [Array] :Tags to include (See {#enabled_tags}).
572
+ #
573
+ # @return [JSON] The created Message with the following attributes:
574
+ # * idList [Integer]
575
+ # * idMessage [Integer]
576
+ # * Subject [String]
577
+ #
578
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateEmailMessage
579
+ #
580
+ # @example
581
+ #
582
+ # new_message = mailup.console.list(2).add_message(message)
583
+ # new_message['Subject']
584
+ # => "Message Subject"
585
+ #
586
+ def add_message(message)
587
+ @api.post("#{@api.path}/List/#{@id}/Email", body: message)
588
+ end
589
+
590
+ # Modify an email message in the specified list id.
591
+ #
592
+ # @param [Integer] message_id The ID of the message.
593
+ # @param [Hash] message A hash of message attributes:
594
+ # @option message [String] :Subject of the message (required).
595
+ # @option message [String] :Content of the message (required).
596
+ # @option message [String] :Notes of the message (required).
597
+ # @option message [Boolean] :IsConfirmation if it's a confirmation (required).
598
+ # @option message [Boolean] :Embed this message (required).
599
+ # @option message [Array] :Fields to include (See {MailUp::Console::Email#fields}).
600
+ # @option message [Array] :Tags to include (See {#enabled_tags}).
601
+ #
602
+ # @return [JSON] The updated Message with the following attributes:
603
+ # * idList [Integer]
604
+ # * idMessage [Integer]
605
+ # * Subject [String]
606
+ #
607
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateEmailMessage
608
+ #
609
+ # @example
610
+ #
611
+ # update = mailup.console.list(2).update_message(5, message)
612
+ # update['Subject']
613
+ # => "Updated Subject"
614
+ #
615
+ def update_message(message_id, message)
616
+ @api.put("#{@api.path}/List/#{@id}/Email/#{message_id}", body: message)
617
+ end
618
+
619
+ # Modify the email message online visibility.
620
+ #
621
+ # @param [Integer] message_id The ID of the message.
622
+ # @param [Boolean] visibility The visibility of the message.
623
+ #
624
+ # @return [Boolean] `true` if successful.
625
+ #
626
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateOnlineEmailMessageVisibility
627
+ #
628
+ # @example
629
+ #
630
+ # update = mailup.console.list(2).update_message_visibility(5, true)
631
+ # => true
632
+ #
633
+ def update_message_visibility(message_id, visibility)
634
+ @api.put("#{@api.path}/List/#{@id}/Email/#{message_id}/Online/Visibility", body: visibility)
635
+ end
636
+
637
+ # Delete an email message from the specified list id.
638
+ #
639
+ # @param [Integer] message_id The ID of the message.
640
+ #
641
+ # @return [Boolean] `true` if successful.
642
+ #
643
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-DeleteEmailMessage
644
+ #
645
+ # Example:
646
+ #
647
+ # delete = mailup.console.list(2).delete_message(49)
648
+ # => true
649
+ #
650
+ def delete_message(message_id)
651
+ @api.delete("#{@api.path}/List/#{@id}/Email/#{message_id}")
652
+ end
653
+
654
+ # Retrieve the email message details by specified id.
655
+ #
656
+ # @param [Integer] message_id The ID of the message.
657
+ #
658
+ # @return [JSON] The Message with the following attributes:
659
+ # * Attachments [Array]
660
+ # * Notes [String]
661
+ # * Content [String]
662
+ # * Fields [Array]
663
+ # * Tags [Array]
664
+ # * Embed [Boolean]
665
+ # * IsConfirmation [Boolean]
666
+ # * idList [Integer]
667
+ # * idMessage [Integer]
668
+ # * Subject [String]
669
+ #
670
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetMessageDetails
671
+ # Example:
672
+ #
673
+ # message = mailup.console.list(2).message_details(49)
674
+ # message['Subject']
675
+ # => "Message Subject"
676
+ #
677
+ def message_details(message_id)
678
+ @api.get("#{@api.path}/List/#{@id}/Email/#{message_id}")
679
+ end
680
+
681
+ # Retrieve email messages (cloned and uncloned) for this list.
682
+ #
683
+ # @param [Hash] params Optional params or filters:
684
+ # @option params [Integer] :pageNumber The page number to return.
685
+ # @option params [Integer] :pageSize The number of results to per page.
686
+ # @option params [String] :filterby A filtering expression.
687
+ # @option params [String] :orderby The sorting condition for the results.
688
+ #
689
+ # @return [JSON] Results and data including:
690
+ # * IsPaginated [Boolean]
691
+ # * Items [Array<Hash>]
692
+ # * PageNumber [Integer]
693
+ # * PageSize [Integer]
694
+ # * Skipped [Integer]
695
+ # * TotalElementsCount [Integer]
696
+ #
697
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetMailMessagesByList
698
+ #
699
+ # @example
700
+ #
701
+ # emails = mailup.console.list(2).emails
702
+ # emails['TotalElementsCount']
703
+ # => 10
704
+ # emails['Items'].first['Subject']
705
+ # => "Test Subject"
706
+ # emails['Items'].first['idList']
707
+ # => 2
708
+ #
709
+ def emails(params = {})
710
+ @api.get("#{@api.path}/List/#{@id}/Emails", params: params)
711
+ end
712
+
713
+ # Retrieve the email messages visible online through the website by the specified list id.
714
+ #
715
+ # @param [Hash] params Optional params or filters:
716
+ # @option params [Integer] :pageNumber The page number to return.
717
+ # @option params [Integer] :pageSize The number of results to per page.
718
+ # @option params [String] :filterby A filtering expression.
719
+ # @option params [String] :orderby The sorting condition for the results.
720
+ #
721
+ # @return [JSON] Results and data including:
722
+ # * IsPaginated [Boolean]
723
+ # * Items [Array<Hash>]
724
+ # * PageNumber [Integer]
725
+ # * PageSize [Integer]
726
+ # * Skipped [Integer]
727
+ # * TotalElementsCount [Integer]
728
+ #
729
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetPublishedMailMessagesByList
730
+ #
731
+ # @example
732
+ #
733
+ # emails = mailup.console.list(2).online_emails
734
+ # emails['TotalElementsCount']
735
+ # => 10
736
+ # emails['Items'].first['Subject']
737
+ # => "Test Subject"
738
+ # emails['Items'].first['idList']
739
+ # => 1
740
+ #
741
+ def online_emails(params = {})
742
+ @api.get("#{@api.path}/List/#{@id}/Online/Emails", params: params)
743
+ end
744
+ alias_method :visible_emails, :online_emails
745
+
746
+ # Retrieve the archived email messages by the specified list id.
747
+ #
748
+ # @param [Hash] params Optional params or filters:
749
+ # @option params [Integer] :pageNumber The page number to return.
750
+ # @option params [Integer] :pageSize The number of results to per page.
751
+ # @option params [String] :filterby A filtering expression.
752
+ # @option params [String] :orderby The sorting condition for the results.
753
+ #
754
+ # @return [JSON] Results and data including:
755
+ # * IsPaginated [Boolean]
756
+ # * Items [Array<Hash>]
757
+ # * PageNumber [Integer]
758
+ # * PageSize [Integer]
759
+ # * Skipped [Integer]
760
+ # * TotalElementsCount [Integer]
761
+ #
762
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetArchivedMailMessagesByList
763
+ #
764
+ # @example
765
+ #
766
+ # emails = mailup.console.list(2).archived_emails
767
+ # emails.size
768
+ # => 10
769
+ # emails['Items'].first['Subject']
770
+ # => "Test Subject"
771
+ # emails['Items'].first['idList']
772
+ # => 1
773
+ #
774
+ def archived_emails(params = {})
775
+ @api.get("#{@api.path}/List/#{@id}/Archived/Emails", params: params)
776
+ end
777
+
778
+ # Get email message send history.
779
+ #
780
+ # @param [Integer] message_id The ID of the message.
781
+ # @param [Hash] params Optional params or filters:
782
+ # @option params [Integer] :pageNumber The page number to return.
783
+ # @option params [Integer] :pageSize The number of results to per page.
784
+ # @option params [String] :filterby A filtering expression.
785
+ # @option params [String] :orderby The sorting condition for the results.
786
+ #
787
+ # @return [JSON] Results and data including:
788
+ # * IsPaginated [Boolean]
789
+ # * Items [Array<Hash>]
790
+ # * PageNumber [Integer]
791
+ # * PageSize [Integer]
792
+ # * Skipped [Integer]
793
+ # * TotalElementsCount [Integer]
794
+ #
795
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetMailMessageSendHistory
796
+ #
797
+ # @example
798
+ #
799
+ # history = mailup.console.list(2).send_history(5)
800
+ # history['TotalElementsCount']
801
+ # => 10
802
+ #
803
+ def send_history(message_id, params = {})
804
+ @api.get("#{@api.path}/List/#{@id}/Email/#{message_id}/SendHistory", params: params)
805
+ end
806
+
807
+ # Send an email message to the recipients in the specified list.
808
+ #
809
+ # @param [Integer] message_id The ID of the list.
810
+ # @param [Hash] params Optional params or filters:
811
+ # @option params [String] :datetime date/time for a deferred sending(should be UTC).
812
+ #
813
+ # @return [JSON] A Send object with the following attributes:
814
+ # * idMessage [Integer]
815
+ # * Sent [Integer]
816
+ # * UnprocessedRecipients [Array]
817
+ # * InvalidRecipients [Array]
818
+ #
819
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-SendMailMessageToRecipientInList
820
+ #
821
+ # @example
822
+ #
823
+ # send = mailup.console.list(2).send_message(5)
824
+ # send['Sent']
825
+ # => 1794
826
+ #
827
+ def send_message(message_id, params = {})
828
+ @api.post("#{@api.path}/List/#{@id}/Email/#{message_id}/Send", params: params)
829
+ end
830
+
831
+ # Retrieve the list of the current defined message templates in the specified list.
832
+ #
833
+ # @param [Hash] params Optional params or filters:
834
+ # @option params [Integer] :pageNumber The page number to return.
835
+ # @option params [Integer] :pageSize The number of results to per page.
836
+ # @option params [String] :filterby A filtering expression.
837
+ # @option params [String] :orderby The sorting condition for the results.
838
+ #
839
+ # @return [JSON] Results and data including:
840
+ # * IsPaginated [Boolean]
841
+ # * Items [Array<Hash>]
842
+ # * PageNumber [Integer]
843
+ # * PageSize [Integer]
844
+ # * Skipped [Integer]
845
+ # * TotalElementsCount [Integer]
846
+ #
847
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetEmailTemplates
848
+ #
849
+ # @example
850
+ #
851
+ # templates = mailup.console.list(2).templates
852
+ # templates['TotalElementsCount']
853
+ # => 10
854
+ # templates['Items'].first['Id']
855
+ # => 278
856
+ #
857
+ def templates(params = {})
858
+ @api.get("#{@api.path}/List/#{@id}/Templates", params: params)
859
+ end
860
+
861
+ # Retrieve the details for the specified message template in the specified list.
862
+ #
863
+ # @param [Integer] template_id The ID of the template.
864
+ # @param [Hash] params Optional params or filters:
865
+ # @option params [Integer] :pageNumber The page number to return.
866
+ # @option params [Integer] :pageSize The number of results to per page.
867
+ # @option params [String] :filterby A filtering expression.
868
+ # @option params [String] :orderby The sorting condition for the results.
869
+ #
870
+ # @return [JSON>] A Template object with the following attributes:
871
+ # * Content [String]
872
+ # * Id [Integer]
873
+ # * Title [String]
874
+ # * Text [String]
875
+ # * Thumbnail [String]
876
+ #
877
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetEmailTemplateDetails
878
+ #
879
+ # @example
880
+ #
881
+ # template = mailup.console.list(2).template_details(15)
882
+ # template.Id
883
+ # => 15
884
+ #
885
+ def template_details(template_id)
886
+ @api.get("#{@api.path}/List/#{@id}/Templates/#{template_id}")
887
+ end
888
+
889
+ # Update a list.
890
+ #
891
+ # @param [Hash] params to update a list
892
+ #
893
+ # @return [JSON] Results and data including:
894
+ #
895
+ # * List Attributes [<Hash>]
896
+ #
897
+ # @see http://help.mailup.com/display/mailupapi/Manage+Lists+and+Groups#ManageListsandGroups-UpdateList
898
+ #
899
+ # @example
900
+ #
901
+ # list = mailup.console.list(2).update_list({"Name":"New List Name"})
902
+ # list['Name']
903
+ # => "New List Name"
904
+ #
905
+ def update_list(params={})
906
+ update_params = params
907
+ update_params['IdList'] = @id
908
+ @api.put("#{@api.path}/User/List/#{@id}", body: update_params)
909
+ end
910
+
911
+ end
912
+ end
913
+ end