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
45f229db
Commit
45f229db
authored
May 28, 2020
by
Jose Ernesto Suarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First approach for make the proxy work
parent
3e4e57d9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
28 deletions
+97
-28
.rspec_status
.rspec_status
+13
-8
client.rb
lib/masmovil-smsclient/client.rb
+47
-15
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
+18
-3
No files found.
.rspec_status
View file @
45f229db
example_id | status | run_time |
example_id | status | run_time |
----------------------------- | ------ | --------------------- |
----------------------------- | ------- | --------------- |
./spec/zoholib_spec.rb[1:1] | passed | 0.00051 seconds |
./spec/zoholib_spec.rb[1:1] | passed | 0.00046 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.00033 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.0004 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00036 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00028 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.00006 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.00007 seconds |
./spec/zoholib_spec.rb[1:4:1] | passed | 0.00014 seconds |
./spec/zoholib_spec.rb[1:3:3] | pending | 0.00001 seconds |
./spec/zoholib_spec.rb[1:4:2] | failed | 1 minute 0.02 seconds |
./spec/zoholib_spec.rb[1:3:4] | pending | 0.00001 seconds |
./spec/zoholib_spec.rb[1:3:5] | pending | 0 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.0002 seconds |
./spec/zoholib_spec.rb[1:4:2] | failed | 59.35 seconds |
lib/masmovil-smsclient/client.rb
View file @
45f229db
...
@@ -6,23 +6,27 @@ module Wedoops
...
@@ -6,23 +6,27 @@ 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
# pp @client
response
=
@client
.
call
(
:sendSMS
)
do
response
=
@client
.
call
(
:sendSMS
)
do
message
(
message
)
message
(
message
)
end
end
...
@@ -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
true
#@logger.debug(@proxy)
log_level
:debug
#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 @
45f229db
...
@@ -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 @
45f229db
...
@@ -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 @
45f229db
...
@@ -15,8 +15,23 @@ RSpec.describe Wedoops::MasmovilSmsclient do
...
@@ -15,8 +15,23 @@ 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
...
@@ -27,7 +42,7 @@ RSpec.describe Wedoops::MasmovilSmsclient do
...
@@ -27,7 +42,7 @@ RSpec.describe Wedoops::MasmovilSmsclient do
end
end
it
'Can Send a SMS'
do
it
'Can Send a SMS'
do
client
=
Wedoops
::
MasmovilSmsclient
::
Client
.
new
client
=
Wedoops
::
MasmovilSmsclient
::
Client
.
new
(
Wedoops
::
MasmovilSmsclient
.
configuration
)
response
=
client
.
sendSMS
response
=
client
.
sendSMS
pp
response
pp
response
expect
(
response
).
to
be_an
(
String
)
expect
(
response
).
to
be_an
(
String
)
...
...
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