textveloper 0.0.1
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 +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +7 -0
- data/lib/textveloper.rb +79 -0
- data/lib/textveloper/version.rb +3 -0
- data/spec/lib/textveloper_spec.rb +58 -0
- data/spec/spec_helper.rb +2 -0
- data/textveloper.gemspec +26 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4cf309e3eb758c682ed7e3e8c0ed10f73edb85ad
|
4
|
+
data.tar.gz: 40242f8716b5743e655168db139e5e13cb526894
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d531a07c4d0485e7c24d577ced551150eec3e6e4a72de36d5b76e92786c61d055082eb431cc87dbf140c99d1059f010901941832f4032fda76be5566873ff43f
|
7
|
+
data.tar.gz: 89fdf06e744a419231eb6d00f8ef167b456b666d97a673a5851cd470d0a9c792df4fc4e8b1a2d0f2f7f6a524780d189e2e59d8f5406f8d42d2ae1cb6b94cbf97
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Gustavo Gimenez
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Textveloper
|
2
|
+
|
3
|
+
Envío de mensajes de texto a tráves del servicio de mesajeria de [Textveloper](http://textveloper.com)
|
4
|
+
|
5
|
+
[](https://codeclimate.com/repos/523697cdc7f3a37543001042/feed)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'textveloper'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install textveloper
|
20
|
+
|
21
|
+
## Uso
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
sms = Textveloper::Sdk.new(cuenta_token,subcuenta_token)
|
25
|
+
```
|
26
|
+
|
27
|
+
### Enviar mensajes individuales
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
sms.send_sms(numero,mensaje)
|
31
|
+
sms.send_sms("04141234567","Hola Mundo")
|
32
|
+
```
|
33
|
+
|
34
|
+
Este metodo retorna un Hash object (de ser exitoso esta seria la respuesta)
|
35
|
+
|
36
|
+
```
|
37
|
+
{:'04141234567' => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"}}
|
38
|
+
```
|
39
|
+
|
40
|
+
### Enviar mensajes "cadena" o masivos
|
41
|
+
único mensaje a multiples números celulares
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
sms.mass_messages(arreglo_de_numeros, mensaje)
|
45
|
+
```
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
telefonos = ["04121234567","04149876543","04164567890"]
|
49
|
+
|
50
|
+
sms.mass_messages(telefonos, "Hola a todos")
|
51
|
+
```
|
52
|
+
|
53
|
+
Retorna un hash con la respuesta asociada a cada número telefónico
|
54
|
+
```ruby
|
55
|
+
{
|
56
|
+
:'04141234567' => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"},
|
57
|
+
:'04149876543' => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"},
|
58
|
+
:'04164567890' => {"transaccion"=>"exitosa", "mensaje_transaccion"=>"MENSAJE_ENVIADO"}
|
59
|
+
}
|
60
|
+
```
|
61
|
+
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/textveloper.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "textveloper/version"
|
2
|
+
|
3
|
+
module Textveloper
|
4
|
+
|
5
|
+
class Sdk
|
6
|
+
|
7
|
+
def initialize(account_token_number, subaccount_token_number)
|
8
|
+
@account_token_number = account_token_number
|
9
|
+
@subaccount_token_number = subaccount_token_number
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_actions
|
13
|
+
{
|
14
|
+
:enviar => 'enviar',
|
15
|
+
:puntos_cuenta => 'saldo-cuenta',
|
16
|
+
:puntos_subcuenta => 'saldo-subcuenta',
|
17
|
+
:compras => 'historial-compras',
|
18
|
+
:envios => 'historial-envios',
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def send_sms(number,message)
|
23
|
+
response = []
|
24
|
+
data = {
|
25
|
+
:cuenta_token => @account_token_number,
|
26
|
+
:subcuenta_token => @subaccount_token_number,
|
27
|
+
:telefono => number,
|
28
|
+
:mensaje => message
|
29
|
+
}
|
30
|
+
response << Curl.post(url + api_actions[:enviar] + '/', data ).body_str
|
31
|
+
show_format_response([number],response)
|
32
|
+
end
|
33
|
+
|
34
|
+
def subaccount_balance
|
35
|
+
data = {
|
36
|
+
:cuenta_token => @account_token_number,
|
37
|
+
:subcuenta_token => @subaccount_token_number
|
38
|
+
}
|
39
|
+
response = Curl.post(url + api_actions[:puntos_subcuenta] + '/', data).body_str
|
40
|
+
hash_contructor(response)
|
41
|
+
end
|
42
|
+
|
43
|
+
def mass_messages(numbers, message)
|
44
|
+
response = []
|
45
|
+
numbers.each do |number|
|
46
|
+
data = {
|
47
|
+
:cuenta_token => @account_token_number,
|
48
|
+
:subcuenta_token => @subaccount_token_number,
|
49
|
+
:telefono => number,
|
50
|
+
:mensaje => message
|
51
|
+
}
|
52
|
+
response << Curl.post(url + api_actions[:enviar] + '/', data ).body_str
|
53
|
+
end
|
54
|
+
show_format_response(numbers,response)
|
55
|
+
end
|
56
|
+
|
57
|
+
def show_format_response(numbers,response)
|
58
|
+
data = {}
|
59
|
+
hash_constructor_with_numbers(numbers,response, data)
|
60
|
+
end
|
61
|
+
|
62
|
+
def hash_contructor(response)
|
63
|
+
Hash[*response.split(/\W+/)[1..-1]]
|
64
|
+
end
|
65
|
+
|
66
|
+
def hash_constructor_with_numbers(numbers,response, data)
|
67
|
+
numbers.each_with_index do |number, index|
|
68
|
+
data[number.to_sym] = Hash[*response[index].split(/\W+/)[1..-1]]
|
69
|
+
end
|
70
|
+
data
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def url
|
76
|
+
'http://api.textveloper.com/'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Textveloper do
|
4
|
+
|
5
|
+
let(:account_token){"account_token"}
|
6
|
+
let(:subaccount_token){"subaccount_token"}
|
7
|
+
let(:notificator){Textveloper::Sdk.new(account_token,subaccount_token)}
|
8
|
+
let(:tel_numbers){["04147890123","04141234567","04161234567"]}
|
9
|
+
let(:mensaje){"Enviado desde textveloper plataform"}
|
10
|
+
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(:hash_response_points){{"transaccion"=>"exitosa", "puntos_enviados"=>"0", "total_puntos" => "0", "puntos_disponibles" => "0"}}
|
13
|
+
let(:url){'http://api.textveloper.com/'}
|
14
|
+
|
15
|
+
|
16
|
+
it "consulta de puntos" do
|
17
|
+
stub_request(:post, "http://api.textveloper.com/saldo-subcuenta/").
|
18
|
+
with(:body => "cuenta_token=account_token&subcuenta_token=subaccount_token").
|
19
|
+
to_return(:status => 200, :body => points, :headers => {})
|
20
|
+
notificator.subaccount_balance.should == hash_response_points
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it 'envio de mensaje simple' do
|
25
|
+
stub_request(:post, "http://api.textveloper.com/enviar/").
|
26
|
+
with(:body => "cuenta_token=account_token&subcuenta_token=subaccount_token&telefono=04121234567&mensaje=Enviado+desde+textveloper+plataform").
|
27
|
+
to_return(:status => 200, :body => "{\"transaccion\":\"exitosa\",\"mensaje_transaccion\":\"MENSAJE_ENVIADO\"}", :headers => {})
|
28
|
+
|
29
|
+
notificator.send_sms("04121234567",mensaje).should == {:"04121234567"=>hash_response}
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'envio masivo de mensajes' do
|
33
|
+
tel_numbers.each do |number|
|
34
|
+
stub_request(:post, "http://api.textveloper.com/enviar/").
|
35
|
+
with(:body => "cuenta_token=account_token&subcuenta_token=subaccount_token&telefono=#{number}&mensaje=Enviado+desde+textveloper+plataform").
|
36
|
+
to_return(:status => 200, :body => "{\"transaccion\":\"exitosa\",\"mensaje_transaccion\":\"MENSAJE_ENVIADO\"}", :headers => {})
|
37
|
+
end
|
38
|
+
notificator.mass_messages(tel_numbers,mensaje).should == {:"04147890123"=>hash_response, :"04141234567"=>hash_response, :"04161234567"=>hash_response}
|
39
|
+
end
|
40
|
+
|
41
|
+
context "asociación de numeros de telefono con data recibida" do
|
42
|
+
let(:data){Hash.new}
|
43
|
+
let(:numero){["04146578904"]}
|
44
|
+
let(:numeros){["04147890123","04141234567"]}
|
45
|
+
let(:response){"{\"transaccion\":\"exitosa\",\"mensaje_transaccion\":\"MENSAJE_ENVIADO\"}"}
|
46
|
+
|
47
|
+
it "un telefono" do
|
48
|
+
notificator.hash_constructor_with_numbers(numero,[response], data).should == {:"04146578904"=>hash_response}
|
49
|
+
end
|
50
|
+
|
51
|
+
it "varios numeros" do
|
52
|
+
notificator.hash_constructor_with_numbers(numeros,[response,response], data).should == {:"04147890123"=>hash_response,:"04141234567"=>hash_response}
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/textveloper.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'textveloper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "textveloper"
|
8
|
+
spec.version = Textveloper::VERSION
|
9
|
+
spec.authors = ["Gustavo Gimenez"]
|
10
|
+
spec.email = ["gimenezanderson@gmail.com"]
|
11
|
+
spec.description = %q{Envío de mensajes de texto en Venezuela a tráves del servicio de Textveloper}
|
12
|
+
spec.summary = %q{Gema para el envío de sms en Venezuela a tráves del servicio de Textveloper}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "curb"
|
25
|
+
spec.add_development_dependency "webmock"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: textveloper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gustavo Gimenez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: curb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Envío de mensajes de texto en Venezuela a tráves del servicio de Textveloper
|
84
|
+
email:
|
85
|
+
- gimenezanderson@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/textveloper.rb
|
97
|
+
- lib/textveloper/version.rb
|
98
|
+
- spec/lib/textveloper_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- textveloper.gemspec
|
101
|
+
homepage: ''
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.0.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Gema para el envío de sms en Venezuela a tráves del servicio de Textveloper
|
125
|
+
test_files:
|
126
|
+
- spec/lib/textveloper_spec.rb
|
127
|
+
- spec/spec_helper.rb
|