Class: Bs2Api::Entities::AsyncRequest
- Inherits:
-
Object
- Object
- Bs2Api::Entities::AsyncRequest
- Defined in:
- lib/bs2_api/entities/async_request.rb
Overview
Used by Bs2Api::Payment::Async. This class stores PIX key, user defined identificador for the key and the value to be transfered. Bs2Api::Payment::Async sends a bucket of AsyncRequest and in the response we get a list of passed payments. The identificador can be used to keep track of the transactino in the response.
Constant Summary collapse
- ALLOWED_PIX_KEY_TYPES =
%w[ CPF CNPJ EMAIL EVP ].freeze
Instance Attribute Summary collapse
-
#identificator ⇒ Object
Returns the value of attribute identificator.
-
#pix_key ⇒ Object
Returns the value of attribute pix_key.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ AsyncRequest
constructor
A new instance of AsyncRequest.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ AsyncRequest
Returns a new instance of AsyncRequest.
22 23 24 25 26 27 28 |
# File 'lib/bs2_api/entities/async_request.rb', line 22 def initialize(args = {}) @pix_key = args[:pix_key] raise Errors::InvalidPixKey unless ALLOWED_PIX_KEY_TYPES.include? @pix_key.type @identificator = args.fetch(:identificator) @value = args[:value] end |
Instance Attribute Details
#identificator ⇒ Object
Returns the value of attribute identificator.
13 14 15 |
# File 'lib/bs2_api/entities/async_request.rb', line 13 def identificator @identificator end |
#pix_key ⇒ Object
Returns the value of attribute pix_key.
13 14 15 |
# File 'lib/bs2_api/entities/async_request.rb', line 13 def pix_key @pix_key end |
#value ⇒ Object
Returns the value of attribute value.
13 14 15 |
# File 'lib/bs2_api/entities/async_request.rb', line 13 def value @value end |
Instance Method Details
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/bs2_api/entities/async_request.rb', line 30 def to_hash ActiveSupport::HashWithIndifferentAccess.new( { identificador: @identificator, chave: @pix_key.to_hash, valor: @value } ) end |
#to_json ⇒ Object
40 41 42 |
# File 'lib/bs2_api/entities/async_request.rb', line 40 def to_json(*) to_hash.to_json end |