class TextVeloper::Api

Attributes

sub_token[RW]
token_account[RW]

Public Class Methods

new() click to toggle source
# File lib/text_veloper.rb, line 14
def initialize
  @base_request_data = {
      cuenta_token: "",
      subcuenta_token: ""
  }
end

Public Instance Methods

config_tokens_account(token_account, sub_token) click to toggle source
# File lib/text_veloper.rb, line 21
def config_tokens_account token_account, sub_token
  @base_request_data[:cuenta_token] = token_account
  @base_request_data[:subcuenta_token] = sub_token
  self
end
messages_records() click to toggle source
# File lib/text_veloper.rb, line 48
def messages_records
  response = RestClient.post url_base_for('historial-envios'), @base_request_data
rescue => e
  raise TextVeloperError.new "Problem with message records", e
ensure
  return response
end
points_query() click to toggle source
# File lib/text_veloper.rb, line 40
def points_query
  response = RestClient.post url_base_for('historial-transferencias'), @base_request_data
rescue => e
  raise TextVeloperError.new "Problem with points query", e
ensure
  return response
end
send_message(message, phones = []) click to toggle source
# File lib/text_veloper.rb, line 27
def send_message(message, phones = [])
  response = {}
  phones_arg = phones
  phones = phones_arg.is_a?(Array) ? phones_arg : [phones_arg]
  phones.each do |phone|
    response = RestClient.post url_base_for('enviar'), @base_request_data.merge({telefono: phone, mensaje: message})
  end
rescue => e
  raise TextVeloperError.new "Problem with send message", e
ensure
  return response
end
setup() { |self| ... } click to toggle source
# File lib/text_veloper.rb, line 56
def setup
  yield self
  @base_request_data = {cuenta_token: @token_account, subcuenta_token: @sub_token}
  TextVeloper::ApiSelector.account_manager.token = @token_account
  TextVeloper::ApiSelector.account_manager.payload = {cuenta_token: @token_account}
end