Class: TextVeloper::AccountManager
- Inherits:
-
Object
- Object
- TextVeloper::AccountManager
- Includes:
- Singleton, TextVeloper
- Defined in:
- lib/text_veloper.rb
Constant Summary
Constants included from TextVeloper
Instance Attribute Summary collapse
-
#memorizing ⇒ Object
Returns the value of attribute memorizing.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#sub_accounts ⇒ Object
Returns the value of attribute sub_accounts.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #balance ⇒ Object
- #config_token_account(token_account, sub_account_record = true) ⇒ Object
-
#initialize ⇒ AccountManager
constructor
A new instance of AccountManager.
- #purchase_history ⇒ Object
- #sub_account_api(sub_token_param = nil) ⇒ Object
Methods included from TextVeloper
Constructor Details
#initialize ⇒ AccountManager
Returns a new instance of AccountManager.
71 72 73 74 75 |
# File 'lib/text_veloper.rb', line 71 def initialize @payload = {cuenta_token: ""} @memorizing = true @sub_accounts = {} end |
Instance Attribute Details
#memorizing ⇒ Object
Returns the value of attribute memorizing.
69 70 71 |
# File 'lib/text_veloper.rb', line 69 def memorizing @memorizing end |
#payload ⇒ Object
Returns the value of attribute payload.
69 70 71 |
# File 'lib/text_veloper.rb', line 69 def payload @payload end |
#sub_accounts ⇒ Object
Returns the value of attribute sub_accounts.
69 70 71 |
# File 'lib/text_veloper.rb', line 69 def sub_accounts @sub_accounts end |
#token ⇒ Object
Returns the value of attribute token.
69 70 71 |
# File 'lib/text_veloper.rb', line 69 def token @token end |
Instance Method Details
#balance ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/text_veloper.rb', line 92 def balance response = RestClient.post url_base_for('saldo-cuenta'), @payload rescue => e raise TextVeloperError.new "Problem with balance", e ensure return response end |
#config_token_account(token_account, sub_account_record = true) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/text_veloper.rb', line 77 def config_token_account token_account, sub_account_record = true @token = token_account @payload = {cuenta_token: @token} @memorizing = sub_account_record @sub_accounts = {} self end |
#purchase_history ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/text_veloper.rb', line 100 def purchase_history response = RestClient.post url_base_for('historial-compras'), @payload rescue => e raise TextVeloperError.new "Problem with purchase history", e ensure return response end |
#sub_account_api(sub_token_param = nil) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/text_veloper.rb', line 85 def sub_account_api sub_token_param = nil sub_token = sub_token_param.nil? ? TextVeloper::Api.instance.sub_token : sub_token_param return TextVeloper::Api.instance.config_tokens_account @token, sub_token unless @memorizing @sub_accounts[sub_token] = TextVeloper::Api.instance.config_tokens_account @token, sub_token unless @sub_accounts.keys.include? sub_token @sub_accounts[sub_token] end |