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.
- checksums.yaml +4 -4
- data/README.md +21 -11
- data/app/models/tolliver/notification.rb +0 -1
- data/app/models/tolliver/notification_attachment.rb +16 -0
- data/app/models/tolliver/notification_delivery.rb +1 -3
- data/app/models/tolliver/notification_receiver.rb +0 -2
- data/app/models/tolliver/notification_template.rb +0 -1
- data/app/views/{notification_mailer → tolliver/notification_mailer}/notify.html.erb +0 -0
- data/app/views/tolliver/notification_mailer/notify.text.erb +1 -0
- data/config/locales/en.yml +1 -1
- data/db/migrate/20160121093817_create_notifications.rb +1 -12
- data/db/migrate/20160121094838_create_notification_receivers.rb +6 -4
- data/db/migrate/20160509144238_create_notification_templates.rb +4 -4
- data/db/migrate/20170630190600_create_notification_deliveries.rb +10 -3
- data/db/migrate/20201027150000_create_notification_attachments.rb +17 -0
- data/lib/tolliver.rb +44 -47
- data/lib/tolliver/errors/bad_request.rb +17 -0
- data/lib/tolliver/errors/not_found.rb +17 -0
- data/lib/tolliver/errors/standard_error.rb +17 -0
- data/lib/tolliver/mailers/notification_mailer.rb +10 -13
- data/lib/tolliver/models/notification.rb +11 -64
- data/lib/tolliver/models/notification_attachment.rb +35 -0
- data/lib/tolliver/models/notification_delivery.rb +32 -40
- data/lib/tolliver/models/notification_receiver.rb +3 -25
- data/lib/tolliver/models/notification_template.rb +6 -10
- data/lib/tolliver/services/delivery.rb +52 -8
- data/lib/tolliver/services/methods/email.rb +42 -0
- data/lib/tolliver/services/methods/sms.rb +51 -0
- data/lib/tolliver/services/methods/sms/plivo.rb +51 -0
- data/lib/tolliver/services/notification.rb +109 -178
- data/lib/tolliver/services/policies/batch.rb +90 -0
- data/lib/tolliver/services/policies/instantly.rb +50 -0
- metadata +20 -14
- data/app/views/notification_mailer/notify.text.erb +0 -1
- data/lib/tolliver/models/notification_delivery/batch.rb +0 -77
- data/lib/tolliver/models/notification_delivery/instantly.rb +0 -55
- data/lib/tolliver/models/notification_receiver/email.rb +0 -46
- data/lib/tolliver/models/notification_receiver/sms.rb +0 -45
- 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
|