Class: StarkBank::Transfer::Log
- Inherits:
-
Utils::Resource
- Object
- Utils::Resource
- StarkBank::Transfer::Log
- Defined in:
- lib/transfer/log.rb
Overview
# Transfer::Log object
Every time a Transfer entity is modified, a corresponding Transfer::Log is generated for the entity. This log is never generated by the user.
## Attributes:
-
id [string]: unique id returned when the log is created. ex: “5656565656565656”
-
transfer [Transfer]: Transfer entity to which the log refers to.
-
errors [list of strings]: list of errors linked to this BoletoPayment event.
-
type [string]: type of the Transfer event which triggered the log creation. ex: “processing” or “success”
-
created [DateTime]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#transfer ⇒ Object
readonly
Returns the value of attribute transfer.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific Log.
-
.query(limit: nil, after: nil, before: nil, types: nil, transfer_ids: nil, user: nil) ⇒ Object
# Retrieve Logs.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(id:, created:, type:, errors:, transfer:) ⇒ Log
constructor
A new instance of Log.
Methods inherited from Utils::Resource
Constructor Details
#initialize(id:, created:, type:, errors:, transfer:) ⇒ Log
Returns a new instance of Log.
24 25 26 27 28 29 30 |
# File 'lib/transfer/log.rb', line 24 def initialize(id:, created:, type:, errors:, transfer:) super(id) @type = type @errors = errors @transfer = transfer @created = StarkBank::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
23 24 25 |
# File 'lib/transfer/log.rb', line 23 def created @created end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
23 24 25 |
# File 'lib/transfer/log.rb', line 23 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/transfer/log.rb', line 23 def id @id end |
#transfer ⇒ Object (readonly)
Returns the value of attribute transfer.
23 24 25 |
# File 'lib/transfer/log.rb', line 23 def transfer @transfer end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/transfer/log.rb', line 23 def type @type end |
Class Method Details
.get(id, user: nil) ⇒ Object
# Retrieve a specific Log
Receive a single Log object previously created by the Stark Bank API by passing its id
## Parameters (required):
-
id [string]: object unique id. ex: “5656565656565656”
## Parameters (optional):
-
user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
Log object with updated attributes
44 45 46 |
# File 'lib/transfer/log.rb', line 44 def self.get(id, user: nil) StarkBank::Utils::Rest.get_id(id: id, user: user, **resource) end |
.query(limit: nil, after: nil, before: nil, types: nil, transfer_ids: nil, user: nil) ⇒ Object
# Retrieve Logs
Receive a generator of Log objects previously created in the Stark Bank API
## Parameters (optional):
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
-
after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
types [list of strings, default nil]: filter retrieved objects by types. ex: ‘success’ or ‘failed’
-
transfer_ids [list of strings, default nil]: list of Transfer ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
## Return:
-
list of Log objects with updated attributes
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/transfer/log.rb', line 62 def self.query(limit: nil, after: nil, before: nil, types: nil, transfer_ids: nil, user: nil) after = StarkBank::Utils::Checks.check_date(after) before = StarkBank::Utils::Checks.check_date(before) StarkBank::Utils::Rest.get_list( limit: limit, after: after, before: before, types: types, transfer_ids: transfer_ids, user: user, **resource ) end |
.resource ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/transfer/log.rb', line 76 def self.resource transfer_maker = StarkBank::Transfer.resource[:resource_maker] { resource_name: 'TransferLog', resource_maker: proc { |json| Log.new( id: json['id'], created: json['created'], type: json['type'], errors: json['errors'], transfer: StarkBank::Utils::API.from_api_json(transfer_maker, json['transfer']) ) } } end |