unifonic_integration 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1c947f72ec779398665ace9b3617a827134ce130cac63114be1e4a716080c48
4
- data.tar.gz: 0ee6fc7ec4adb5dfcf8505c18d1562f7e4aea011806ef7de64031566fadb4aa7
3
+ metadata.gz: 1149192ea4eda376f35c9a21836e7bb7bf2edd9d72e7e084ecee7141cff093e0
4
+ data.tar.gz: '06481f2b30d7477f2cd3549ed6415976c44240c30898fb1ea0ae546062ecd0b0'
5
5
  SHA512:
6
- metadata.gz: ce15d512face145fef31aaf2aa0084ca82ecaccd4a7c79d44155693f668c3c015a01897832cd9f6483188a70340d6ee28bbf32c860c9f81cf6046a28f306aa1f
7
- data.tar.gz: 3a5b5ebf394c476013633a042da36a02aab263048c9b220dea8533e3c5b2e4ce58735a84935a3c0aa700195c898affc89134bc13a446f3c1caaaa58aecb68ef5
6
+ metadata.gz: bf6e4c5babd9b0a560fabdcd2898001fdcdc1d426603e2563765a82d72be5235582c064ed9a8530af97e1ef730602a4392014adcb6038ef44cb645c88e38fea0
7
+ data.tar.gz: 54b199ad447ce3af1b907189ddb7fa1313db64703e597705b5b971f4a0c17fe13f3d10a53ce41b3515866e313dce519d583df16884118ec0de1dec34014ebb9d
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # UnifonicIntegration
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/unifonic_integration`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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
 
@@ -11,15 +11,11 @@ module UnifonicIntegration
11
11
 
12
12
  def initialize
13
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
- cleaned_number = recipient.to_s.gsub(/^(\+|00)/, '')
33
- cleaned_number =~ /\A\d+\z/
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
- unless validate_recipient(recipient)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UnifonicIntegration
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  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.2
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-17 00:00:00.000000000 Z
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.2.3
76
+ rubygems_version: 3.3.7
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: SMS Unifonic