textveloper 0.0.4 → 0.1.0
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 +4 -4
- data/README.md +21 -5
- data/lib/textveloper.rb +52 -19
- data/lib/textveloper/version.rb +1 -1
- data/spec/lib/textveloper_spec.rb +10 -4
- data/textveloper.gemspec +3 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b319232d0b5416a1bb5c3a5db7fc07c36d562b6a
|
4
|
+
data.tar.gz: 801291100be2db0724dc55857f90466295f9b18d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12d7ce43a18810952e8f781b56b1cb8f183422ca04e4dec151b36357e86f5393dfae4847e1e31ed9debee481f97bec9d5f8cb6d04e4654b84b53e62b1fcc4470
|
7
|
+
data.tar.gz: 7f13e94a967db670b54b74582fbf9d7689eea0d7da6e1b0136e71b8904f3f425f9c792e52faeda79ec9e8ac01950f196588eb15a1c95580a48d0b5192900dff9
|
data/README.md
CHANGED
@@ -37,8 +37,8 @@ sms = Textveloper::Sdk.new(cuenta_token,subcuenta_token)
|
|
37
37
|
|
38
38
|
Este metodo retorna un Hash object (de ser exitoso esta seria la respuesta)
|
39
39
|
|
40
|
-
```
|
41
|
-
{:
|
40
|
+
```ruby
|
41
|
+
{:"04141234567" => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"}}
|
42
42
|
```
|
43
43
|
|
44
44
|
### Enviar mensajes "cadena" o masivos
|
@@ -56,14 +56,30 @@ Este metodo retorna un Hash object (de ser exitoso esta seria la respuesta)
|
|
56
56
|
|
57
57
|
Retorna un hash con la respuesta asociada a cada número telefónico
|
58
58
|
|
59
|
+
|
59
60
|
```ruby
|
60
61
|
{
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
62
|
+
:"04141234567" => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"},
|
63
|
+
:"04149876543" => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"},
|
64
|
+
:"04164567890" => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"}
|
64
65
|
}
|
65
66
|
```
|
66
67
|
|
68
|
+
### Historial
|
69
|
+
|
70
|
+
#### Transferencias
|
71
|
+
Pendiente
|
72
|
+
|
73
|
+
#### Mensajes Enviados
|
74
|
+
Pendiente
|
75
|
+
|
76
|
+
#### Compras
|
77
|
+
Pendiente
|
78
|
+
|
79
|
+
### Consulta de Puntos
|
80
|
+
Pendiente
|
81
|
+
|
82
|
+
|
67
83
|
|
68
84
|
## Contributing
|
69
85
|
|
data/lib/textveloper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "textveloper/version"
|
2
2
|
require "curb"
|
3
|
+
require "json"
|
3
4
|
|
4
5
|
module Textveloper
|
5
6
|
|
@@ -17,9 +18,12 @@ module Textveloper
|
|
17
18
|
:puntos_subcuenta => 'saldo-subcuenta',
|
18
19
|
:compras => 'historial-compras',
|
19
20
|
:envios => 'historial-envios',
|
21
|
+
:transferencias => 'historial-transferencias'
|
20
22
|
}
|
21
23
|
end
|
22
24
|
|
25
|
+
#Servicio SMS
|
26
|
+
|
23
27
|
def send_sms(number,message)
|
24
28
|
response = []
|
25
29
|
data = {
|
@@ -32,15 +36,6 @@ module Textveloper
|
|
32
36
|
show_format_response([number],response)
|
33
37
|
end
|
34
38
|
|
35
|
-
def subaccount_balance
|
36
|
-
data = {
|
37
|
-
:cuenta_token => @account_token_number,
|
38
|
-
:subcuenta_token => @subaccount_token_number
|
39
|
-
}
|
40
|
-
response = Curl.post(url + api_actions[:puntos_subcuenta] + '/', data).body_str
|
41
|
-
hash_contructor(response)
|
42
|
-
end
|
43
|
-
|
44
39
|
def mass_messages(numbers, message)
|
45
40
|
response = []
|
46
41
|
numbers.each do |number|
|
@@ -54,32 +49,70 @@ module Textveloper
|
|
54
49
|
end
|
55
50
|
show_format_response(numbers,response)
|
56
51
|
end
|
52
|
+
|
53
|
+
#Historial de Transacciones
|
54
|
+
|
55
|
+
def account_balance
|
56
|
+
data = {
|
57
|
+
:cuenta_token => @account_token_number,
|
58
|
+
}
|
59
|
+
hash_contructor(Curl.post(url + api_actions[:puntos_cuenta] + '/', data).body_str)
|
60
|
+
end
|
61
|
+
|
62
|
+
def subaccount_balance
|
63
|
+
data = {
|
64
|
+
:cuenta_token => @account_token_number,
|
65
|
+
:subcuenta_token => @subaccount_token_number
|
66
|
+
}
|
67
|
+
hash_contructor(Curl.post(url + api_actions[:puntos_subcuenta] + '/', data).body_str)
|
68
|
+
end
|
69
|
+
|
70
|
+
def account_history
|
71
|
+
data = {
|
72
|
+
:cuenta_token => @account_token_number,
|
73
|
+
:subcuenta_token => @subaccount_token_number
|
74
|
+
}
|
75
|
+
hash_contructor(Curl.post(url + api_actions[:envios] + '/',data).body_str)
|
76
|
+
end
|
77
|
+
|
78
|
+
def buy_history
|
79
|
+
data = {
|
80
|
+
:cuenta_token => @account_token_number
|
81
|
+
}
|
82
|
+
hash_contructor(Curl.post(url + api_actions[:compras] + '/',data).body_str)
|
83
|
+
end
|
84
|
+
|
85
|
+
def transfer_history
|
86
|
+
data = {
|
87
|
+
:cuenta_token => @account_token_number,
|
88
|
+
:subcuenta_token => @subaccount_token_number
|
89
|
+
}
|
90
|
+
hash_contructor(Curl.post(url + api_actions[:transferencias] + '/',data).body_str)
|
91
|
+
end
|
57
92
|
|
93
|
+
#metodos de formato de data
|
94
|
+
|
58
95
|
def show_format_response(numbers,response)
|
59
96
|
data = {}
|
60
97
|
hash_constructor_with_numbers(numbers,response, data)
|
61
98
|
end
|
62
99
|
|
63
|
-
def hash_contructor(response)
|
64
|
-
Hash[*response.split(/\W+/)[1..-1]]
|
65
|
-
end
|
66
|
-
|
67
100
|
def hash_constructor_with_numbers(numbers,response, data)
|
68
101
|
numbers.each_with_index do |number, index|
|
69
|
-
data[number.to_sym] =
|
102
|
+
data[number.to_sym] = hash_contructor( response[index])
|
70
103
|
end
|
71
104
|
data
|
72
105
|
end
|
73
106
|
|
74
107
|
def format_phone(phone_number)
|
75
108
|
phone_number.gsub(/\W/,"").sub(/^58/,"").sub(/(^4)/, '0\1')
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
# end
|
109
|
+
end
|
110
|
+
|
111
|
+
def hash_contructor(response)
|
112
|
+
JSON.parse(response)
|
81
113
|
end
|
82
114
|
|
115
|
+
|
83
116
|
private
|
84
117
|
|
85
118
|
def url
|
data/lib/textveloper/version.rb
CHANGED
@@ -7,8 +7,9 @@ describe Textveloper do
|
|
7
7
|
let(:notificator){Textveloper::Sdk.new(account_token,subaccount_token)}
|
8
8
|
let(:tel_numbers){["04147890123","04141234567","04161234567"]}
|
9
9
|
let(:mensaje){"Enviado desde textveloper plataform"}
|
10
|
+
let(:response){"{\"transaccion\":\"exitosa\",\"mensaje_transaccion\":\"MENSAJE_ENVIADO\"}"}
|
10
11
|
let(:hash_response){{"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"}}
|
11
|
-
let(:points){"{\"transaccion\":\"exitosa\",\"puntos_enviados\":\"0\",\"total_puntos\":\"0\",\"puntos_disponibles\":\"0\"
|
12
|
+
let(:points){"{\"transaccion\":\"exitosa\",\"puntos_enviados\":\"0\",\"total_puntos\":\"0\",\"puntos_disponibles\":\"0\"}"}
|
12
13
|
let(:hash_response_points){{"transaccion"=>"exitosa", "puntos_enviados"=>"0", "total_puntos" => "0", "puntos_disponibles" => "0"}}
|
13
14
|
let(:url){'http://api.textveloper.com/'}
|
14
15
|
|
@@ -24,7 +25,7 @@ describe Textveloper do
|
|
24
25
|
it 'envio de mensaje simple' do
|
25
26
|
stub_request(:post, "http://api.textveloper.com/enviar/").
|
26
27
|
with(:body => "cuenta_token=account_token&subcuenta_token=subaccount_token&telefono=04121234567&mensaje=Enviado+desde+textveloper+plataform").
|
27
|
-
to_return(:status => 200, :body =>
|
28
|
+
to_return(:status => 200, :body => response, :headers => {})
|
28
29
|
|
29
30
|
notificator.send_sms("04121234567",mensaje).should == {:"04121234567"=>hash_response}
|
30
31
|
end
|
@@ -33,7 +34,7 @@ describe Textveloper do
|
|
33
34
|
tel_numbers.each do |number|
|
34
35
|
stub_request(:post, "http://api.textveloper.com/enviar/").
|
35
36
|
with(:body => "cuenta_token=account_token&subcuenta_token=subaccount_token&telefono=#{number}&mensaje=Enviado+desde+textveloper+plataform").
|
36
|
-
to_return(:status => 200, :body =>
|
37
|
+
to_return(:status => 200, :body => response, :headers => {})
|
37
38
|
end
|
38
39
|
notificator.mass_messages(tel_numbers,mensaje).should == {:"04147890123"=>hash_response, :"04141234567"=>hash_response, :"04161234567"=>hash_response}
|
39
40
|
end
|
@@ -42,7 +43,6 @@ describe Textveloper do
|
|
42
43
|
let(:data){Hash.new}
|
43
44
|
let(:numero){["04146578904"]}
|
44
45
|
let(:numeros){["04147890123","04141234567"]}
|
45
|
-
let(:response){"{\"transaccion\":\"exitosa\",\"mensaje_transaccion\":\"MENSAJE_ENVIADO\"}"}
|
46
46
|
|
47
47
|
it "un telefono" do
|
48
48
|
notificator.hash_constructor_with_numbers(numero,[response], data).should == {:"04146578904"=>hash_response}
|
@@ -60,8 +60,14 @@ describe Textveloper do
|
|
60
60
|
notificator.format_phone("0412-123-45-67").should eq("04121234567")
|
61
61
|
notificator.format_phone("0412.123.45.67").should eq("04121234567")
|
62
62
|
notificator.format_phone("+58-412.158.58.58").should eq("04121585858")
|
63
|
+
notificator.format_phone("58.412.1.2.3.4.5.6.7").should eq("04121234567")
|
64
|
+
notificator.format_phone("+58 412 123 45 67").should eq("04121234567")
|
65
|
+
|
63
66
|
end
|
64
67
|
|
68
|
+
it "formatear response a hash " do
|
69
|
+
notificator.hash_contructor(points).should eq(hash_response_points)
|
70
|
+
end
|
65
71
|
|
66
72
|
|
67
73
|
end
|
data/textveloper.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["gimenezanderson@gmail.com"]
|
11
11
|
spec.description = %q{Envío de mensajes de texto en Venezuela a tráves del servicio de Textveloper}
|
12
12
|
spec.summary = %q{Gema para el envío de sms en Venezuela a tráves del servicio de Textveloper}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/GusGA/Textveloper"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "curb"
|
22
|
-
|
22
|
+
spec.add_dependency 'json'
|
23
|
+
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
25
|
spec.add_development_dependency "rake"
|
25
26
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textveloper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gustavo Gimenez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,7 +127,7 @@ files:
|
|
113
127
|
- spec/lib/textveloper_spec.rb
|
114
128
|
- spec/spec_helper.rb
|
115
129
|
- textveloper.gemspec
|
116
|
-
homepage:
|
130
|
+
homepage: https://github.com/GusGA/Textveloper
|
117
131
|
licenses:
|
118
132
|
- MIT
|
119
133
|
metadata: {}
|