it_cloud_sms 0.2.1 → 0.4
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 +5 -5
- data/lib/it_cloud_sms.rb +25 -14
- metadata +15 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 974a76b8eb0240e90db48a26ebac4679dbff4afc26964f549d45ec70504ccb12
|
|
4
|
+
data.tar.gz: 03a8b427ea96e835330246e5a46c97cad4bdcf0744686b5e7a5b9da0390ddb38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: add6fdcb79680ecd1206067506a176a41c25c6fe6c78eb1d6280a7c544c64192fbb6500e6835928e23def11d1f4aa2dc09da26ae97246915a1e706f090112515
|
|
7
|
+
data.tar.gz: c8cf33a5429ccf007ea9913f2e98a36f320796c1800e11c52fde5f27278b56803e1c7bd5560a1bb0c8a0bf604b5217dc912112f46f91d7b3964437e794d40531
|
data/lib/it_cloud_sms.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'net/https'
|
|
|
4
4
|
|
|
5
5
|
module ItCloudSms
|
|
6
6
|
|
|
7
|
-
APIUri = URI.parse("https://
|
|
7
|
+
APIUri = URI.parse("https://contacto-masivo.com/sms/back_sms/public/api/sendsms")
|
|
8
8
|
|
|
9
9
|
class << self
|
|
10
10
|
|
|
@@ -25,8 +25,8 @@ module ItCloudSms
|
|
|
25
25
|
# Example:
|
|
26
26
|
# >> ItCloudSms.send_sms(:login => "login",
|
|
27
27
|
# :password => "password",
|
|
28
|
-
# :destination => "+573102111111" || ["+573102111111", "+573102111112"], # Up to
|
|
29
|
-
# :message => "Message with
|
|
28
|
+
# :destination => "+573102111111" || ["+573102111111", "+573102111112"], # Up to 5000 numbers
|
|
29
|
+
# :message => "Message with 765 chars maximum")
|
|
30
30
|
def send_sms(options = {})
|
|
31
31
|
# Check for login
|
|
32
32
|
login = options[:login] || @@login
|
|
@@ -40,17 +40,21 @@ module ItCloudSms
|
|
|
40
40
|
options[:destination] = [options[:destination]] unless options[:destination].kind_of?(Array)
|
|
41
41
|
|
|
42
42
|
# Check for max destinations
|
|
43
|
-
raise ArgumentError, "Max of
|
|
43
|
+
raise ArgumentError, "Max of 5000 destinations exceeded" if (options[:destination].size > 5000)
|
|
44
44
|
|
|
45
45
|
destinations = []
|
|
46
46
|
options[:destination].each do |phone|
|
|
47
47
|
raise ArgumentError, "Recipient must be a telephone number with international format: #{phone.to_s}" unless parsed = GlobalPhone.parse(phone.to_s)
|
|
48
|
-
|
|
48
|
+
if parsed.international_string.to_s =~ /^\+1/
|
|
49
|
+
destinations << parsed.international_string.gsub(/^\+1/, "01") # Replace initial +1 with 01 for IT Cloud requirements
|
|
50
|
+
else
|
|
51
|
+
destinations << parsed.international_string.gsub("+", "") # Remove + from international string
|
|
52
|
+
end
|
|
49
53
|
end
|
|
50
54
|
|
|
51
55
|
message = options[:message].to_s
|
|
52
56
|
raise ArgumentError, "Message must be present" if message.blank?
|
|
53
|
-
raise ArgumentError, "Message is
|
|
57
|
+
raise ArgumentError, "Message is 765 chars maximum" if message.size > 765
|
|
54
58
|
|
|
55
59
|
http = Net::HTTP.new(APIUri.host, APIUri.port)
|
|
56
60
|
http.use_ssl = true
|
|
@@ -58,9 +62,10 @@ module ItCloudSms
|
|
|
58
62
|
|
|
59
63
|
request = Net::HTTP::Post.new(APIUri.request_uri)
|
|
60
64
|
request.set_form_data({'user' => login,
|
|
61
|
-
'
|
|
65
|
+
'token' => password,
|
|
62
66
|
'GSM' => destinations.join(","),
|
|
63
|
-
'SMSText' => message
|
|
67
|
+
'SMSText' => message,
|
|
68
|
+
'metodo_envio' => '1via'})
|
|
64
69
|
|
|
65
70
|
response = http.request(request)
|
|
66
71
|
if response.code == "200"
|
|
@@ -86,13 +91,19 @@ module ItCloudSms
|
|
|
86
91
|
destination[:description] = "System under maintenance"
|
|
87
92
|
when "-7" then
|
|
88
93
|
destination[:description] = "Max cellphones reached"
|
|
89
|
-
when "
|
|
90
|
-
destination[:description] = "
|
|
94
|
+
when "-8" then
|
|
95
|
+
destination[:description] = "Cellphone number in black list"
|
|
96
|
+
when "-9" then
|
|
97
|
+
destination[:description] = "message rejected for content"
|
|
98
|
+
when "-10" then
|
|
99
|
+
destination[:description] = "Message with no link authorized"
|
|
100
|
+
when "-11" then
|
|
101
|
+
destination[:description] = "Error in metodo_envio variable"
|
|
91
102
|
else
|
|
92
|
-
if destination[:code].to_i
|
|
93
|
-
destination[:description] = "Unknown error"
|
|
94
|
-
else
|
|
103
|
+
if destination[:code].to_i > 0
|
|
95
104
|
destination[:description] = "OK"
|
|
105
|
+
else
|
|
106
|
+
destination[:description] = "Unknown error"
|
|
96
107
|
end
|
|
97
108
|
end
|
|
98
109
|
end
|
|
@@ -103,4 +114,4 @@ module ItCloudSms
|
|
|
103
114
|
end
|
|
104
115
|
|
|
105
116
|
end
|
|
106
|
-
end
|
|
117
|
+
end
|
metadata
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: it_cloud_sms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: '0.4'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Angel García Pérez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: global_phone
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 1.0.1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 1.0.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - ~>
|
|
45
|
+
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: 0.8.7
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - ~>
|
|
52
|
+
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 0.8.7
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rspec
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ">"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: 1.3.1
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ">"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: 1.3.1
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: json
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
description: A gateway to send SMS using HTTP POST, through IT Cloud Services Colombia,
|
|
@@ -97,17 +97,16 @@ require_paths:
|
|
|
97
97
|
- lib
|
|
98
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
|
100
|
-
- -
|
|
100
|
+
- - ">="
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
102
|
version: '0'
|
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
requirements:
|
|
105
|
-
- -
|
|
105
|
+
- - ">="
|
|
106
106
|
- !ruby/object:Gem::Version
|
|
107
107
|
version: '0'
|
|
108
108
|
requirements: []
|
|
109
|
-
|
|
110
|
-
rubygems_version: 2.0.14
|
|
109
|
+
rubygems_version: 3.2.5
|
|
111
110
|
signing_key:
|
|
112
111
|
specification_version: 4
|
|
113
112
|
summary: IT Cloud Services Colombia send SMS HTTP gateway
|