Class: TextVeloper::Api
- Inherits:
-
Object
- Object
- TextVeloper::Api
- Includes:
- Singleton, TextVeloper
- Defined in:
- lib/text_veloper.rb
Constant Summary
Constants included from TextVeloper
Instance Attribute Summary collapse
-
#sub_token ⇒ Object
Returns the value of attribute sub_token.
-
#token_account ⇒ Object
Returns the value of attribute token_account.
Instance Method Summary collapse
- #config_tokens_account(token_account, sub_token) ⇒ Object
-
#initialize ⇒ Api
constructor
A new instance of Api.
- #messages_records ⇒ Object
- #points_query ⇒ Object
- #send_message(message, phones = []) ⇒ Object
- #setup {|_self| ... } ⇒ Object
Methods included from TextVeloper
Constructor Details
#initialize ⇒ Api
Returns a new instance of Api.
14 15 16 17 18 19 |
# File 'lib/text_veloper.rb', line 14 def initialize @base_request_data = { cuenta_token: "", subcuenta_token: "" } end |
Instance Attribute Details
#sub_token ⇒ Object
Returns the value of attribute sub_token.
12 13 14 |
# File 'lib/text_veloper.rb', line 12 def sub_token @sub_token end |
#token_account ⇒ Object
Returns the value of attribute token_account.
12 13 14 |
# File 'lib/text_veloper.rb', line 12 def token_account @token_account end |
Instance Method Details
#config_tokens_account(token_account, sub_token) ⇒ Object
21 22 23 24 25 |
# 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 ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/text_veloper.rb', line 48 def 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 ⇒ Object
40 41 42 43 44 45 46 |
# 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 = []) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/text_veloper.rb', line 27 def (, 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: }) end rescue => e raise TextVeloperError.new "Problem with send message", e ensure return response end |
#setup {|_self| ... } ⇒ Object
56 57 58 59 60 61 |
# 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 |