Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
masmovil-smsclient
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gems
masmovil-smsclient
Commits
7fa9715b
Commit
7fa9715b
authored
Jun 10, 2020
by
Jose Ernesto Suarez
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' into 'master'
Development See merge request
!2
parents
279d7268
dc56957b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
26 deletions
+110
-26
.rspec_status
.rspec_status
+13
-6
client.rb
lib/masmovil-smsclient/client.rb
+48
-16
configuration.rb
lib/masmovil-smsclient/configuration.rb
+18
-1
spec_helper.rb
spec/spec_helper.rb
+1
-1
zoholib_spec.rb
spec/zoholib_spec.rb
+30
-2
No files found.
.rspec_status
View file @
7fa9715b
example_id | status | run_time |
example_id | status | run_time |
----------------------------- | ------ | --------------- |
----------------------------- | ------- | --------------- |
./spec/zoholib_spec.rb[1:1] | passed | 0.00085 seconds |
./spec/zoholib_spec.rb[1:1] | passed | 0.00168 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.00064 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.04786 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00058 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00112 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.00007 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.0001 seconds |
./spec/zoholib_spec.rb[1:3:3] | pending | 0.00001 seconds |
./spec/zoholib_spec.rb[1:3:4] | pending | 0 seconds |
./spec/zoholib_spec.rb[1:3:5] | pending | 0.00001 seconds |
./spec/zoholib_spec.rb[1:3:6] | pending | 0 seconds |
./spec/zoholib_spec.rb[1:3:7] | pending | 0 seconds |
./spec/zoholib_spec.rb[1:4:1] | passed | 0.00023 seconds |
./spec/zoholib_spec.rb[1:4:2] | failed | 0.82752 seconds |
lib/masmovil-smsclient/client.rb
View file @
7fa9715b
...
@@ -6,24 +6,28 @@ module Wedoops
...
@@ -6,24 +6,28 @@ module Wedoops
module
MasmovilSmsclient
module
MasmovilSmsclient
class
Client
class
Client
def
initialize
(
options
=
{})
def
initialize
(
options
=
Wedoops
::
MasmovilSmsclient
::
Configuration
.
new
)
@logger
=
Logger
.
new
(
STDOUT
)
@logger
=
Logger
.
new
(
STDOUT
)
@config
=
options
@proxy
=
nil
setup_proxy
if
@config
.
option
.
has_key?
(
:proxy
)
initialize_client
initialize_client
end
end
def
sendSMS
def
sendSMS
@logger
.
info
(
"Calling thing..."
)
@logger
.
info
(
"Calling thing..."
)
message
=
{
message
=
{
:user
=>
nil
,
:user
=>
"APPSimplant19"
,
:pass
=>
nil
,
:pass
=>
"h6pG0S60"
,
:src
=>
nil
,
:src
=>
"+34619766776"
,
:dst
=>
nil
,
:dst
=>
"+34619766776"
,
:msg
=>
nil
,
:msg
=>
"Yeep"
,
:date
=>
nil
,
:date
=>
DateTime
.
now
,
:name
=>
nil
:name
=>
"pepe"
}
}
begin
begin
response
=
@client
.
call
(
:sendSMS
)
do
# pp @client
response
=
@client
.
call
(
:send_sms
)
do
message
(
message
)
message
(
message
)
end
end
rescue
Exception
=>
e
rescue
Exception
=>
e
...
@@ -36,13 +40,41 @@ module Wedoops
...
@@ -36,13 +40,41 @@ module Wedoops
private
private
def
initialize_client
def
initialize_client
@client
=
Savon
.
client
do
@logger
.
debug
(
"Initlizing savon"
)
wsdl
'https://websms.xtratelecom.es/api_php/server.wsdl'
unless
@proxy
.
nil?
pretty_print_xml
true
# TO-DO: Fix the authentication as needed
#convert_request_keys_to :camelcase
#secret = Base64.strict_encode64("#{@proxy[:user]}:#{@proxy[:password]}")
log
false
#@logger.debug(@proxy)
log_level
:info
#header={ "Proxy-Authorization" => "Basic #{secret}","Authorization" => "Basic"}
#@logger.debug(header)
@client
=
Savon
.
client
(
wsdl:
'https://websms.xtratelecom.es/api_php/server.wsdl'
,
pretty_print_xml:
true
,
#convert_request_keys_to :camelcase
log:
true
,
log_level: :info
,
logger:
@logger
,
# basic_auth: [@proxy[:user],@proxy[:password]] ,
filters:
[
:password
],
proxy:
"
#{
@proxy
[
:address
]
}
"
,
#headers: header
)
else
@client
=
Savon
.
client
(
wsdl:
'https://websms.xtratelecom.es/api_php/server.wsdl'
,
pretty_print_xml:
true
,
#convert_request_keys_to :camelcase
log:
true
,
log_level: :debug
,
)
end
end
# end
end
def
setup_proxy
@proxy
=
@config
.
option
[
:proxy
]
end
end
...
...
lib/masmovil-smsclient/configuration.rb
View file @
7fa9715b
...
@@ -9,9 +9,26 @@ module Wedoops
...
@@ -9,9 +9,26 @@ module Wedoops
attr_accessor
:option
attr_accessor
:option
def
initialize
def
initialize
@option
=
nil
@option
=
Hash
.
new
end
end
def
uses_proxy?
@option
.
has_key?
(
:proxy
)
end
def
valid_proxy?
return
false
unless
self
.
uses_proxy?
validate_proxy_options
(
@option
[
:proxy
])
end
private
def
validate_proxy_options
(
options
)
return
false
unless
options
[
:user
].
kind_of?
String
return
false
unless
options
[
:password
].
kind_of?
String
# TO-DO : control if the address is an address object. Maybe need initialization?
return
false
unless
options
[
:address
].
kind_of?
String
end
end
end
end
end
...
...
spec/spec_helper.rb
View file @
7fa9715b
...
@@ -7,7 +7,7 @@ RSpec.configure do |conf|
...
@@ -7,7 +7,7 @@ RSpec.configure do |conf|
conf
.
before
(
:all
)
do
conf
.
before
(
:all
)
do
Wedoops
::
MasmovilSmsclient
.
configure
do
|
config
|
Wedoops
::
MasmovilSmsclient
.
configure
do
|
config
|
puts
"Trying to config"
puts
"Trying to config"
config
.
option
=
""
config
.
option
=
{
proxy:
{
user:
"masmovil"
,
password:
"0ckpsirlY2i9W5tzAk6j"
,
address:
"http://masmovil:0ckpsirlY2i9W5tzAk6j@prx.wedoops.io:443"
}}
end
end
end
end
...
...
spec/zoholib_spec.rb
View file @
7fa9715b
...
@@ -15,9 +15,37 @@ RSpec.describe Wedoops::MasmovilSmsclient do
...
@@ -15,9 +15,37 @@ RSpec.describe Wedoops::MasmovilSmsclient do
expect
(
Wedoops
::
MasmovilSmsclient
.
configuration
).
to
be_a_kind_of
(
Wedoops
::
MasmovilSmsclient
::
Configuration
)
expect
(
Wedoops
::
MasmovilSmsclient
.
configuration
).
to
be_a_kind_of
(
Wedoops
::
MasmovilSmsclient
::
Configuration
)
end
end
it
'The option is a string'
do
it
'The option is a Hash'
do
expect
(
Wedoops
::
MasmovilSmsclient
.
configuration
.
option
).
to
be_an
(
String
)
expect
(
Wedoops
::
MasmovilSmsclient
.
configuration
.
option
).
to
be_an
(
Hash
)
end
xit
'The option proxy works'
do
end
xit
'I an Query if I have a proxy'
do
end
xit
'I can validate user'
do
end
xit
'I can validate a password'
do
end
xit
'The address is a valid URL'
do
end
end
end
end
describe
'SOAP Client'
do
it
'Can load'
do
expect
(
Wedoops
::
MasmovilSmsclient
::
Client
.
new
).
to
be_an
(
Wedoops
::
MasmovilSmsclient
::
Client
)
end
it
'Can Send a SMS'
do
client
=
Wedoops
::
MasmovilSmsclient
::
Client
.
new
(
Wedoops
::
MasmovilSmsclient
.
configuration
)
response
=
client
.
sendSMS
pp
response
expect
(
response
).
to
be_an
(
String
)
end
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment