unifonic_integration 0.1.1 → 0.1.3
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 +9 -4
- data/lib/unifonic_integration/client.rb +15 -14
- data/lib/unifonic_integration/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1149192ea4eda376f35c9a21836e7bb7bf2edd9d72e7e084ecee7141cff093e0
|
4
|
+
data.tar.gz: '06481f2b30d7477f2cd3549ed6415976c44240c30898fb1ea0ae546062ecd0b0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf6e4c5babd9b0a560fabdcd2898001fdcdc1d426603e2563765a82d72be5235582c064ed9a8530af97e1ef730602a4392014adcb6038ef44cb645c88e38fea0
|
7
|
+
data.tar.gz: 54b199ad447ce3af1b907189ddb7fa1313db64703e597705b5b971f4a0c17fe13f3d10a53ce41b3515866e313dce519d583df16884118ec0de1dec34014ebb9d
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# UnifonicIntegration
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This is an integration with with unifonic SMS API that allow you to send sms messages and scheduled messages
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,14 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
$ rails generate unifonic_integration:install
|
24
|
+
|
25
|
+
This Will create a file in config/initializers/unifonic_integration.rb, Edit this file to set your configrations
|
26
|
+
|
27
|
+
$ UnifonicIntegration.configure do |config|
|
28
|
+
config.app_sid = UNIFONIC_APP_SID
|
29
|
+
config.sender_id = UNIFONIC_SENDER_ID
|
30
|
+
end
|
26
31
|
|
27
32
|
## Development
|
28
33
|
|
@@ -10,16 +10,12 @@ module UnifonicIntegration
|
|
10
10
|
attr_accessor :config
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@config =
|
13
|
+
@config = UnifonicIntegration.configuration
|
14
|
+
validate_configuration
|
14
15
|
end
|
15
16
|
|
16
17
|
def send_message(body, recipient)
|
17
|
-
|
18
|
-
unless validate_recipient(recipient)
|
19
|
-
puts "Invalid recipient phone number format. Please provide a valid international format."
|
20
|
-
return
|
21
|
-
end
|
22
|
-
|
18
|
+
validate_recipient(recipient)
|
23
19
|
endpoint = '/messages?async=false'
|
24
20
|
set_headers
|
25
21
|
set_message_params(body, recipient)
|
@@ -29,16 +25,13 @@ module UnifonicIntegration
|
|
29
25
|
end
|
30
26
|
|
31
27
|
def validate_recipient(recipient)
|
32
|
-
|
33
|
-
|
28
|
+
if recipient.to_s.start_with?('+', '00')
|
29
|
+
raise ArgumentError, "Phone number should not start with '+' or '00'."
|
30
|
+
end
|
34
31
|
end
|
35
32
|
|
36
33
|
def send_scheduled_message(body, recipient, time_scheduled)
|
37
|
-
|
38
|
-
puts "Invalid recipient phone number format. Please provide a valid international format."
|
39
|
-
return
|
40
|
-
end
|
41
|
-
|
34
|
+
validate_recipient(recipient)
|
42
35
|
endpoint = '/messages/scheduledmessages?async=false'
|
43
36
|
set_headers
|
44
37
|
set_scheduled_message_params(body, recipient, time_scheduled)
|
@@ -66,5 +59,13 @@ module UnifonicIntegration
|
|
66
59
|
Recipient: recipient
|
67
60
|
}
|
68
61
|
end
|
62
|
+
def validate_configuration
|
63
|
+
unless @config.app_sid && @config.sender_id
|
64
|
+
raise ConfigurationError, "UnifonicIntegration gem not properly configured. Please set app_sid and sender_id."
|
65
|
+
end
|
66
|
+
end
|
69
67
|
end
|
68
|
+
|
69
|
+
class ConfigurationError < StandardError; end
|
70
|
+
|
70
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unifonic_integration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Elsamahy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.3.7
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: SMS Unifonic
|