Class: Textveloper::Sdk
- Inherits:
-
Object
- Object
- Textveloper::Sdk
- Defined in:
- lib/textveloper.rb
Instance Method Summary collapse
- #account_balance ⇒ Object
- #account_data ⇒ Object
- #account_history ⇒ Object
- #api_actions ⇒ Object
- #buy_history ⇒ Object
- #core_operation(number, message) ⇒ Object
- #hash_constructor_with_numbers(numbers, response) ⇒ Object
-
#initialize(account_token_number, subaccount_token_number) ⇒ Sdk
constructor
A new instance of Sdk.
- #mass_messages(numbers, message) ⇒ Object
-
#send_sms(number, message) ⇒ Object
Servicio SMS.
-
#show_format_response(numbers, response) ⇒ Object
metodos de formato de data.
- #subaccount_balance ⇒ Object
-
#transactional_data ⇒ Object
Historial de Transacciones.
- #transfer_history ⇒ Object
Constructor Details
#initialize(account_token_number, subaccount_token_number) ⇒ Sdk
Returns a new instance of Sdk.
9 10 11 12 |
# File 'lib/textveloper.rb', line 9 def initialize(account_token_number, subaccount_token_number) @account_token_number = account_token_number @subaccount_token_number = subaccount_token_number end |
Instance Method Details
#account_balance ⇒ Object
81 82 83 |
# File 'lib/textveloper.rb', line 81 def account_balance hash_contructor(Curl.post(url + api_actions[:puntos_cuenta] + '/', account_data).body_str) end |
#account_data ⇒ Object
75 76 77 78 79 |
# File 'lib/textveloper.rb', line 75 def account_data { :cuenta_token => @account_token_number, } end |
#account_history ⇒ Object
93 94 95 |
# File 'lib/textveloper.rb', line 93 def account_history hash_contructor(Curl.post(url + api_actions[:envios] + '/',transactional_data).body_str) end |
#api_actions ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/textveloper.rb', line 14 def api_actions { :enviar => 'enviar', :puntos_cuenta => 'saldo-cuenta', :puntos_subcuenta => 'saldo-subcuenta', :compras => 'historial-compras', :envios => 'historial-envios', :transferencias => 'historial-transferencias' } end |
#buy_history ⇒ Object
85 86 87 |
# File 'lib/textveloper.rb', line 85 def buy_history hash_contructor(Curl.post(url + api_actions[:compras] + '/', account_data).body_str) end |
#core_operation(number, message) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/textveloper.rb', line 25 def core_operation(number, ) data = { :cuenta_token => @account_token_number, :subcuenta_token => @subaccount_token_number, :telefono => format_phone(number), :mensaje => } return Curl.post(url + api_actions[:enviar] + '/', data ).body_str end |
#hash_constructor_with_numbers(numbers, response) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/textveloper.rb', line 107 def hash_constructor_with_numbers(numbers,response) data = Hash.new numbers.each_with_index do |number, index| data[number.to_sym] = hash_contructor(response[index]) end data end |
#mass_messages(numbers, message) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/textveloper.rb', line 49 def (numbers, ) response = [] if .size <= 160 numbers.each do |number| response << core_operation(number, ) end else numbers.each do |number| ().each do |m| response << core_operation(number,m) end end end numbers.map!{ |n| format_phone(n)} show_format_response(numbers,response) end |
#send_sms(number, message) ⇒ Object
Servicio SMS
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/textveloper.rb', line 37 def send_sms(number,) response = [] if .size <= 160 response << core_operation(number,) else ().each do |m| response << core_operation(number, m) end end show_format_response([format_phone(number)],response) end |
#show_format_response(numbers, response) ⇒ Object
metodos de formato de data
103 104 105 |
# File 'lib/textveloper.rb', line 103 def show_format_response(numbers,response) hash_constructor_with_numbers(numbers,response) end |
#subaccount_balance ⇒ Object
89 90 91 |
# File 'lib/textveloper.rb', line 89 def subaccount_balance hash_contructor(Curl.post(url + api_actions[:puntos_subcuenta] + '/', transactional_data).body_str) end |
#transactional_data ⇒ Object
Historial de Transacciones
68 69 70 71 72 73 |
# File 'lib/textveloper.rb', line 68 def transactional_data { :cuenta_token => @account_token_number, :subcuenta_token => @subaccount_token_number } end |
#transfer_history ⇒ Object
97 98 99 |
# File 'lib/textveloper.rb', line 97 def transfer_history hash_contructor(Curl.post(url + api_actions[:transferencias] + '/',transactional_data).body_str) end |