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
Show 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 |
----------------------------- | ------ | --------------- |
./spec/zoholib_spec.rb[1:1] | passed | 0.00085 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.00064 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00058 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.00007 seconds |
----------------------------- | ------- | --------------- |
./spec/zoholib_spec.rb[1:1] | passed | 0.00168 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.04786 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00112 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
module
MasmovilSmsclient
class
Client
def
initialize
(
options
=
{}
)
def
initialize
(
options
=
Wedoops
::
MasmovilSmsclient
::
Configuration
.
new
)
@logger
=
Logger
.
new
(
STDOUT
)
@config
=
options
@proxy
=
nil
setup_proxy
if
@config
.
option
.
has_key?
(
:proxy
)
initialize_client
end
def
sendSMS
@logger
.
info
(
"Calling thing..."
)
message
=
{
:user
=>
nil
,
:pass
=>
nil
,
:src
=>
nil
,
:dst
=>
nil
,
:msg
=>
nil
,
:date
=>
nil
,
:name
=>
nil
:user
=>
"APPSimplant19"
,
:pass
=>
"h6pG0S60"
,
:src
=>
"+34619766776"
,
:dst
=>
"+34619766776"
,
:msg
=>
"Yeep"
,
:date
=>
DateTime
.
now
,
:name
=>
"pepe"
}
begin
response
=
@client
.
call
(
:sendSMS
)
do
# pp @client
response
=
@client
.
call
(
:send_sms
)
do
message
(
message
)
end
rescue
Exception
=>
e
...
...
@@ -36,13 +40,41 @@ module Wedoops
private
def
initialize_client
@client
=
Savon
.
client
do
wsdl
'https://websms.xtratelecom.es/api_php/server.wsdl'
pretty_print_xml
true
@logger
.
debug
(
"Initlizing savon"
)
unless
@proxy
.
nil?
# TO-DO: Fix the authentication as needed
#secret = Base64.strict_encode64("#{@proxy[:user]}:#{@proxy[:password]}")
#@logger.debug(@proxy)
#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
false
log_level
:info
log:
true
,
log_level: :debug
,
)
end
# end
end
def
setup_proxy
@proxy
=
@config
.
option
[
:proxy
]
end
...
...
lib/masmovil-smsclient/configuration.rb
View file @
7fa9715b
...
...
@@ -9,9 +9,26 @@ module Wedoops
attr_accessor
:option
def
initialize
@option
=
nil
@option
=
Hash
.
new
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
...
...
spec/spec_helper.rb
View file @
7fa9715b
...
...
@@ -7,7 +7,7 @@ RSpec.configure do |conf|
conf
.
before
(
:all
)
do
Wedoops
::
MasmovilSmsclient
.
configure
do
|
config
|
puts
"Trying to config"
config
.
option
=
""
config
.
option
=
{
proxy:
{
user:
"masmovil"
,
password:
"0ckpsirlY2i9W5tzAk6j"
,
address:
"http://masmovil:0ckpsirlY2i9W5tzAk6j@prx.wedoops.io:443"
}}
end
end
...
...
spec/zoholib_spec.rb
View file @
7fa9715b
...
...
@@ -15,9 +15,37 @@ RSpec.describe Wedoops::MasmovilSmsclient do
expect
(
Wedoops
::
MasmovilSmsclient
.
configuration
).
to
be_a_kind_of
(
Wedoops
::
MasmovilSmsclient
::
Configuration
)
end
it
'The option is a
string
'
do
expect
(
Wedoops
::
MasmovilSmsclient
.
configuration
.
option
).
to
be_an
(
String
)
it
'The option is a
Hash
'
do
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
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
\ 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