tolliver 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -11
  3. data/app/models/tolliver/notification.rb +0 -1
  4. data/app/models/tolliver/notification_attachment.rb +16 -0
  5. data/app/models/tolliver/notification_delivery.rb +1 -3
  6. data/app/models/tolliver/notification_receiver.rb +0 -2
  7. data/app/models/tolliver/notification_template.rb +0 -1
  8. data/app/views/{notification_mailer → tolliver/notification_mailer}/notify.html.erb +0 -0
  9. data/app/views/tolliver/notification_mailer/notify.text.erb +1 -0
  10. data/config/locales/en.yml +1 -1
  11. data/db/migrate/20160121093817_create_notifications.rb +1 -12
  12. data/db/migrate/20160121094838_create_notification_receivers.rb +6 -4
  13. data/db/migrate/20160509144238_create_notification_templates.rb +4 -4
  14. data/db/migrate/20170630190600_create_notification_deliveries.rb +10 -3
  15. data/db/migrate/20201027150000_create_notification_attachments.rb +17 -0
  16. data/lib/tolliver.rb +44 -47
  17. data/lib/tolliver/errors/bad_request.rb +17 -0
  18. data/lib/tolliver/errors/not_found.rb +17 -0
  19. data/lib/tolliver/errors/standard_error.rb +17 -0
  20. data/lib/tolliver/mailers/notification_mailer.rb +10 -13
  21. data/lib/tolliver/models/notification.rb +11 -64
  22. data/lib/tolliver/models/notification_attachment.rb +35 -0
  23. data/lib/tolliver/models/notification_delivery.rb +32 -40
  24. data/lib/tolliver/models/notification_receiver.rb +3 -25
  25. data/lib/tolliver/models/notification_template.rb +6 -10
  26. data/lib/tolliver/services/delivery.rb +52 -8
  27. data/lib/tolliver/services/methods/email.rb +42 -0
  28. data/lib/tolliver/services/methods/sms.rb +51 -0
  29. data/lib/tolliver/services/methods/sms/plivo.rb +51 -0
  30. data/lib/tolliver/services/notification.rb +109 -178
  31. data/lib/tolliver/services/policies/batch.rb +90 -0
  32. data/lib/tolliver/services/policies/instantly.rb +50 -0
  33. metadata +20 -14
  34. data/app/views/notification_mailer/notify.text.erb +0 -1
  35. data/lib/tolliver/models/notification_delivery/batch.rb +0 -77
  36. data/lib/tolliver/models/notification_delivery/instantly.rb +0 -55
  37. data/lib/tolliver/models/notification_receiver/email.rb +0 -46
  38. data/lib/tolliver/models/notification_receiver/sms.rb +0 -45
  39. data/lib/tolliver/services/sms/plivo.rb +0 -49
@@ -1,49 +0,0 @@
1
- # *****************************************************************************
2
- # * Copyright (c) 2019 Matěj Outlý
3
- # *****************************************************************************
4
- # *
5
- # * Plivo SMS provider
6
- # *
7
- # * Author: Matěj Outlý
8
- # * Date : 1. 12. 2017
9
- # *
10
- # *****************************************************************************
11
-
12
- require "plivo"
13
-
14
- module Tolliver
15
- module Services
16
- module Sms
17
- class Plivo
18
-
19
- def initialize(params = {})
20
- if params[:auth_id].blank? || params[:auth_token].blank?
21
- raise "Please provide Auth ID and Auth Token in provider params."
22
- end
23
- @auth_id = params[:auth_id]
24
- @auth_token = params[:auth_token]
25
- @api = ::Plivo::RestAPI.new(@auth_id, @auth_token)
26
- end
27
-
28
- def deliver(receiver, message)
29
-
30
- # Check message length.
31
- if message.bytesize > 200
32
- raise "Message too long."
33
- end
34
-
35
- # Request API
36
- response = @api.send_message({
37
- "src" => Tolliver.sms_sender, # TODO: This should be improved to take sender from number pool and remember number / message mapping
38
- "dst" => receiver.to_s,
39
- "text" => message.to_s,
40
- "method" => "POST"
41
- })
42
-
43
- return true
44
- end
45
-
46
- end
47
- end
48
- end
49
- end