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,70 @@
1
+ module MailUp
2
+ module Console
3
+ class Recipient
4
+ attr_accessor :api
5
+
6
+ def initialize(api)
7
+ @api = api
8
+ end
9
+
10
+ # Update a recipient with the specified details into address book.
11
+ #
12
+ # @param [Hash] recipient A hash of recipient attributes:
13
+ # @option recipient [String] :Name of the recipient (required).
14
+ # @option recipient [String] :Email of the recipient (required).
15
+ # @option recipient [String] :MobilePrefix of the recipient.
16
+ # @option recipient [String] :MobileNumber of the recipient.
17
+ # @option recipient [Array] :Fields to include.
18
+ #
19
+ # @return [JSON] The updated Recipient object with the following attributes:
20
+ # * idRecipient [Integer]
21
+ # * Name [String]
22
+ # * Email [String]
23
+ # * MobilePrefix [String]
24
+ # * MobileNumber [String]
25
+ # * Fields [Array]
26
+ #
27
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateRecipientDetail
28
+ #
29
+ # @example
30
+ #
31
+ # recipient = {
32
+ # idRecipient: "1234"
33
+ # Name: "Joe Public",
34
+ # Email: "joe@public.com"
35
+ # }
36
+ # updated_recipient = mailup.console.recipient.update(recipient)
37
+ # updated_recipient['Name']
38
+ # => "Joe Public"
39
+ #
40
+ def update(recipient)
41
+ @api.put("#{@api.path}/Recipient/Detail", body: recipient)
42
+ end
43
+
44
+ # Retrieve recipient dynamic field definitions.
45
+ #
46
+ # @return [JSON] Results and data including:
47
+ # * IsPaginated [Boolean]
48
+ # * Items [Array<Hash>]
49
+ # * PageNumber [Integer]
50
+ # * PageSize [Integer]
51
+ # * Skipped [Integer]
52
+ # * TotalElementsCount [Integer]
53
+ #
54
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetDynamicFields
55
+ #
56
+ # @example
57
+ #
58
+ # fields = mailup.console.recipient.fields
59
+ # fields.size
60
+ # => 10
61
+ # fields['Items'].first['Description']
62
+ # => "Field description..."
63
+ #
64
+ def fields(params = {})
65
+ @api.get("#{@api.path}/Recipient/DynamicFields", params: params)
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,77 @@
1
+ module MailUp
2
+ module Console
3
+ class User
4
+ attr_accessor :api
5
+
6
+ def initialize(api)
7
+ @api = api
8
+ end
9
+
10
+ # Retrieve the admin console lists for the current user.
11
+ #
12
+ # @param [Hash] params Optional params or filters:
13
+ # @option params [Integer] :pageNumber The page number to return.
14
+ # @option params [Integer] :pageSize The number of results to per page.
15
+ # @option params [String] :filterby A filtering expression.
16
+ # @option params [String] :orderby The sorting condition for the results.
17
+ #
18
+ # @return [JSON] Results and data including:
19
+ # * IsPaginated [Boolean]
20
+ # * Items [Array<Hash>]
21
+ # * PageNumber [Integer]
22
+ # * PageSize [Integer]
23
+ # * Skipped [Integer]
24
+ # * TotalElementsCount [Integer]
25
+ #
26
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetConsoleListsByUser
27
+ #
28
+ # @example
29
+ #
30
+ # lists = mailup.console.user.lists
31
+ # lists = mailup.console.user.lists
32
+ # lists['TotalElementsCount']
33
+ # => 10
34
+ # lists['Items'].first['Name']
35
+ # => "Test List"
36
+ #
37
+ # lists = mailup.console.user.lists(pageNumber: 0, pageSize: 250)
38
+ #
39
+ def lists(params = {})
40
+ @api.get("#{@api.path}/User/Lists", params: params)
41
+ end
42
+
43
+ # Retrieve the email messages (cloned and not cloned) for the current user.
44
+ #
45
+ # @param [Hash] params Optional params or filters:
46
+ # @option params [Integer] :pageNumber The page number to return.
47
+ # @option params [Integer] :pageSize The number of results to per page.
48
+ # @option params [String] :filterby A filtering expression.
49
+ # @option params [String] :orderby The sorting condition for the results.
50
+ #
51
+ # @return [JSON] Results and data including:
52
+ # * IsPaginated [Boolean]
53
+ # * Items [Array<Hash>]
54
+ # * PageNumber [Integer]
55
+ # * PageSize [Integer]
56
+ # * Skipped [Integer]
57
+ # * TotalElementsCount [Integer]
58
+ #
59
+ # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetMailMessagesByUser
60
+ #
61
+ # @example
62
+ #
63
+ # emails = mailup.console.user.emails
64
+ # emails['TotalElementsCount']
65
+ # => 10
66
+ # emails['Items'].first['Subject']
67
+ # => "Test Subject"
68
+ #
69
+ # emails = mailup.console.user.emails(pageNumber: 0, pageSize: 1)
70
+ #
71
+ def emails(params={})
72
+ @api.get("#{@api.path}/User/Emails", params: params)
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,18 @@
1
+ module MailUp
2
+ class Error < StandardError
3
+ end
4
+ class BadRequest < Error
5
+ end
6
+ class ClientError < Error
7
+ end
8
+ class NotFound < Error
9
+ end
10
+ class ServerError < Error
11
+ end
12
+ class TooManyRequests < Error
13
+ end
14
+ class Unauthorized < Error
15
+ end
16
+ class Unavailable < Error
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module MailUp
2
+ module Public
3
+ class Base
4
+ attr_accessor :api
5
+
6
+ def initialize(api) # :nodoc:
7
+ @api = api
8
+ @api.path = "/API/v#{MailUp::API_VERSION}/Rest/PublicService.svc"
9
+ end
10
+
11
+ # Resource nodes
12
+ def console
13
+ Console.new @api
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,75 @@
1
+ module MailUp
2
+ module Public
3
+ class Console
4
+ attr_accessor :api
5
+
6
+ def initialize(api)
7
+ @api = api
8
+ end
9
+
10
+ # Create a new trial console.
11
+ #
12
+ # @param [Hash] account A hash of account attributes.
13
+ # @option params [String] :NameAndSurname The company name.
14
+ # @option params [String] :Email The email address for the trial account.
15
+ # @option params [String] :Company The company name.
16
+ # @option params [String] :Language The account language.
17
+ # @option params [Boolean] :IsUSA Is this a US account?
18
+ # @option params [Boolean] :RegisterToNewsletter Does this account accept marketing?
19
+ #
20
+ # @return [JSON] The trial console including:
21
+ # * Hash [String]
22
+ # * Id [Integer]
23
+ #
24
+ # @see http://help.mailup.com/display/mailupapi/Public+methods+v1.1#Publicmethodsv1.1-RequestNewTrialConsole
25
+ #
26
+ # @example
27
+ #
28
+ # account = {
29
+ # NameAndSurname: "Joe Public",
30
+ # Email: "joe@public.com",
31
+ # Company: "ACME",
32
+ # PhoneNumber: "15555551212",
33
+ # Language: "En",
34
+ # IsUSA: true,
35
+ # RegisterToNewsletter: true
36
+ # }
37
+ # trial = mailup.public.console.new(account)
38
+ # trial['id']
39
+ # => 1329874
40
+ #
41
+ def activate_trial(account = {})
42
+ @api.provisioning_request("#{@api.path}/Console/TrialActivation", account)
43
+ end
44
+
45
+ # Retrieve the information about current trial activation status.
46
+ #
47
+ # @param [Hash] account A hash of account attributes.
48
+ # @option params [String] :Hash The Hash of the trial activation request.
49
+ # @option params [Integer] :Id The Id of the trial activation request.
50
+ #
51
+ # @return [JSON] An activation status object including:
52
+ # * Code [Integer]
53
+ # * Descriptin [String]
54
+ #
55
+ # @see http://help.mailup.com/display/mailupapi/Public+methods+v1.1#Publicmethodsv1.1-RequestTrialConsoleActivationStatus
56
+ #
57
+ # @example
58
+ #
59
+ # account = {
60
+ # Hash: "1k23hj432jh4kh3j24k",
61
+ # Id: "1324"
62
+ # }
63
+ # status = mailup.public.console.status(account)
64
+ # status['Code']
65
+ # => 1234
66
+ # status['Description']
67
+ # => "Status description..."
68
+ #
69
+ def status(account = {})
70
+ @api.provisioning_request("#{@api.path}/Console/TrialActivationStatus", account)
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,41 @@
1
+ module MailUp
2
+ module Stats
3
+ class Base
4
+ attr_accessor :api
5
+
6
+ def initialize(api) # :nodoc:
7
+ @api = api
8
+ @api.path = "/API/v#{MailUp::API_VERSION}/Rest/MailStatisticsService.svc"
9
+ end
10
+
11
+ # Create a message object
12
+ #
13
+ # @param [Integer] id The message_id of the message to access.
14
+ #
15
+ # @return [MailUp::Stats::Message]
16
+ #
17
+ # @example
18
+ #
19
+ # message = mailup.stats.message(1)
20
+ #
21
+ def message(id)
22
+ Message.new id, @api
23
+ end
24
+
25
+ # Create a recipient object
26
+ #
27
+ # @param [Integer] id The recipient_id of the recipient to access.
28
+ #
29
+ # @return [MailUp::Stats::Recipient]
30
+ #
31
+ # @example
32
+ #
33
+ # recipient = mailup.stats.recipient(154)
34
+ #
35
+ def recipient(id)
36
+ Recipient.new id, @api
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,284 @@
1
+ module MailUp
2
+ module Stats
3
+ class Message
4
+ attr_accessor :api
5
+
6
+ def initialize(id, api)
7
+ @api = api
8
+ @id = id
9
+ end
10
+
11
+ # Paged list of recipients who received the specified email.
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/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-ListMessageRecipients
28
+ #
29
+ # @example
30
+ #
31
+ # recipients = mailup.stats.message(9).recipients
32
+ # recipients['TotalElementsCount']
33
+ # => 10
34
+ # recipients['Items'].first['Email']
35
+ # => "joe@public.com"
36
+ #
37
+ def recipients(params = {})
38
+ @api.get("#{@api.path}/Message/#{@id}/List/Recipients", params: params)
39
+ end
40
+
41
+ # Count of recipients who received the specified email.
42
+ #
43
+ #
44
+ # @return [Integer] Count of recipients.
45
+ #
46
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-CountMessageRecipients
47
+ #
48
+ # @example
49
+ #
50
+ # recipients = mailup.stats.message(9).recipients_count
51
+ # => 10
52
+ #
53
+ def recipients_count
54
+ @api.get("#{@api.path}/Message/#{@id}/Count/Recipients")
55
+ end
56
+ alias_method :received_count, :recipients_count
57
+
58
+ # Paged list of views of the specified email.
59
+ #
60
+ # @param [Hash] params Optional params or filters:
61
+ # @option params [Integer] :pageNumber The page number to return.
62
+ # @option params [Integer] :pageSize The number of results to per page.
63
+ # @option params [String] :filterby A filtering expression.
64
+ # @option params [String] :orderby The sorting condition for the results.
65
+ #
66
+ # @return [JSON] Results and data including:
67
+ # * IsPaginated [Boolean]
68
+ # * Items [Array<Hash>]
69
+ # * PageNumber [Integer]
70
+ # * PageSize [Integer]
71
+ # * Skipped [Integer]
72
+ # * TotalElementsCount [Integer]
73
+ #
74
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-ListMessageViews
75
+ #
76
+ # @example
77
+ #
78
+ # views = mailup.stats.message(9).views
79
+ # views['TotalElementsCount']
80
+ # => 10
81
+ #
82
+ def views(params = {})
83
+ @api.get("#{@api.path}/Message/#{@id}/List/Views", params: params)
84
+ end
85
+
86
+ # Count of views of the specified email.
87
+ #
88
+ #
89
+ # @return [Integer] Count of views.
90
+ #
91
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-CountMessageViews
92
+ #
93
+ # @example
94
+ #
95
+ # views = mailup.stats.message(9).views_count
96
+ # => 3453
97
+ #
98
+ def views_count
99
+ @api.get("#{@api.path}/Message/#{@id}/Count/Views")
100
+ end
101
+
102
+ # Paged list of bounces from the specified email.
103
+ #
104
+ # @param [Hash] params Optional params or filters:
105
+ # @option params [Integer] :pageNumber The page number to return.
106
+ # @option params [Integer] :pageSize The number of results to per page.
107
+ # @option params [String] :filterby A filtering expression.
108
+ # @option params [String] :orderby The sorting condition for the results.
109
+ #
110
+ # @return [JSON] Results and data including:
111
+ # * IsPaginated [Boolean]
112
+ # * Items [Array<Hash>]
113
+ # * PageNumber [Integer]
114
+ # * PageSize [Integer]
115
+ # * Skipped [Integer]
116
+ # * TotalElementsCount [Integer]
117
+ #
118
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-ListMessageBounces
119
+ #
120
+ # @example
121
+ #
122
+ # bounces = mailup.stats.message(9).bounces
123
+ # bounces['TotalElementsCount']
124
+ # => 10
125
+ #
126
+ def bounces(params = {})
127
+ @api.get("#{@api.path}/Message/#{@id}/List/Bounces", params: params)
128
+ end
129
+
130
+ # Count of bounces from the specified mail.
131
+ #
132
+ #
133
+ # @return [Integer] Count of bounces.
134
+ #
135
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-CountMessageBounces
136
+ #
137
+ # @example
138
+ #
139
+ # bounces = mailup.stats.message(9).bounces_count
140
+ # => 3453
141
+ #
142
+ def bounces_count
143
+ @api.get("#{@api.path}/Message/#{@id}/Count/Bounces")
144
+ end
145
+
146
+ # Paged list of unsubscriptions from the specified email.
147
+ #
148
+ # @param [Hash] params Optional params or filters:
149
+ # @option params [Integer] :pageNumber The page number to return.
150
+ # @option params [Integer] :pageSize The number of results to per page.
151
+ # @option params [String] :filterby A filtering expression.
152
+ # @option params [String] :orderby The sorting condition for the results.
153
+ #
154
+ # @return [JSON] Results and data including:
155
+ # * IsPaginated [Boolean]
156
+ # * Items [Array<Hash>]
157
+ # * PageNumber [Integer]
158
+ # * PageSize [Integer]
159
+ # * Skipped [Integer]
160
+ # * TotalElementsCount [Integer]
161
+ #
162
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-ListMessageUnsubscriptions
163
+ #
164
+ # @example
165
+ #
166
+ # unsubs = mailup.stats.message(9).unsubscribes
167
+ # unsubs['TotalElementsCount']
168
+ # => 10
169
+ #
170
+ def unsubscribes(params = {})
171
+ @api.get("#{@api.path}/Message/#{@id}/List/Unsubscriptions", params: params)
172
+ end
173
+
174
+ # Count of unsubscriptions from the specified email.
175
+ #
176
+ #
177
+ # @return [Integer] Count of unsubscribes.
178
+ #
179
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-CountMessageUnsubscriptions
180
+ #
181
+ # @example
182
+ #
183
+ # unsubs = mailup.stats.message(9).unsubscribes_count
184
+ # => 234
185
+ #
186
+ def unsubscribes_count
187
+ @api.get("#{@api.path}/Message/#{@id}/Count/Unsubscriptions")
188
+ end
189
+
190
+ # Paged list of clicks on a link in the specified email.
191
+ #
192
+ # @param [Hash] params Optional params or filters:
193
+ # @option params [Integer] :pageNumber The page number to return.
194
+ # @option params [Integer] :pageSize The number of results to per page.
195
+ # @option params [String] :filterby A filtering expression.
196
+ # @option params [String] :orderby The sorting condition for the results.
197
+ #
198
+ # @return [JSON] Results and data including:
199
+ # * IsPaginated [Boolean]
200
+ # * Items [Array<Hash>]
201
+ # * PageNumber [Integer]
202
+ # * PageSize [Integer]
203
+ # * Skipped [Integer]
204
+ # * TotalElementsCount [Integer]
205
+ #
206
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-ListMessageClicks
207
+ #
208
+ # @example
209
+ #
210
+ # clicks = mailup.stats.message(9).clicks
211
+ # clicks['TotalElementsCount']
212
+ # => 10
213
+ # clicks['Items'].first['Count']
214
+ # => 3
215
+ #
216
+ def clicks(params = {})
217
+ @api.get("#{@api.path}/Message/#{@id}/List/Clicks", params: params)
218
+ end
219
+
220
+ # Count of clicks on a link in the specified email.
221
+ #
222
+ #
223
+ # @return [Integer] Count of bounces.
224
+ #
225
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-CountMessageClicks
226
+ #
227
+ # @example
228
+ #
229
+ # clicks = mailup.stats.message(9).clicks_count
230
+ # => 3453
231
+ #
232
+ def clicks_count
233
+ @api.get("#{@api.path}/Message/#{@id}/Count/Clicks")
234
+ end
235
+
236
+ # Paged list of clicks on a link in the specified email.
237
+ #
238
+ # @param [Hash] params Optional params or filters:
239
+ # @option params [Integer] :pageNumber The page number to return.
240
+ # @option params [Integer] :pageSize The number of results to per page.
241
+ # @option params [String] :filterby A filtering expression.
242
+ # @option params [String] :orderby The sorting condition for the results.
243
+ #
244
+ # @return [JSON] Results and data including:
245
+ # * IsPaginated [Boolean]
246
+ # * Items [Array<Hash>]
247
+ # * PageNumber [Integer]
248
+ # * PageSize [Integer]
249
+ # * Skipped [Integer]
250
+ # * TotalElementsCount [Integer]
251
+ #
252
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-ListMessageUrlClicks
253
+ #
254
+ # @example
255
+ #
256
+ # url_clicks = mailup.stats.message(9).url_clicks
257
+ # url_clicks['TotalElementsCount']
258
+ # => 10
259
+ # url_clicks['Items'].first['Count']
260
+ # => 3
261
+ #
262
+ def url_clicks(params = {})
263
+ @api.get("#{@api.path}/Message/#{@id}/List/UrlClicks", params: params)
264
+ end
265
+
266
+ # Count of clicks on a link in the specified email.
267
+ #
268
+ #
269
+ # @return [Integer] Count of bounces.
270
+ #
271
+ # @see http://help.mailup.com/display/mailupapi/Email+statistics+methods+v1.1#Emailstatisticsmethodsv1.1-CountMessageClicks
272
+ #
273
+ # @example
274
+ #
275
+ # url_clicks = mailup.stats.message(9).url_clicks_count
276
+ # => 3453
277
+ #
278
+ def url_clicks_count
279
+ @api.get("#{@api.path}/Message/#{@id}/Count/UrlClicks")
280
+ end
281
+
282
+ end
283
+ end
284
+ end