Class: StarkInfra::IssuingPurchase::Log
- Inherits:
-
Utils::Resource
- Object
- Utils::SubResource
- Utils::Resource
- StarkInfra::IssuingPurchase::Log
- Defined in:
- lib/issuingpurchase/log.rb
Overview
# IssuingPurchase::Log object
Every time an IssuingPurchase entity is updated, a corresponding IssuingInvoice::Log is generated for the entity. This Log is never generated by the user, but it can be retrieved to check additional information on the IssuingPurchase.
## Attributes:
-
id [string]: unique id returned when the log is created. ex: ‘5656565656565656’
-
purchase [IssuingPurchase]: IssuingPurchase entity to which the log refers to.
-
issuing_transaction_id [string]: transaction ID related to the IssuingCard.
-
errors [list of strings]: list of errors linked to this IssuingPurchase event
-
type [string]: type of the IssuingPurchase event which triggered the log creation. ex: ‘approved’, ‘canceled’, ‘confirmed’, ‘denied’, ‘reversed’, ‘voided’.
-
created [DateTime]: creation datetime for the log. 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.
-
#issuing_transaction_id ⇒ Object
readonly
Returns the value of attribute issuing_transaction_id.
-
#purchase ⇒ Object
readonly
Returns the value of attribute purchase.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific Log.
-
.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil) ⇒ Object
# Retrieve paged Logs.
-
.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil) ⇒ Object
# Retrieve Logs.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(id: nil, purchase: nil, issuing_transaction_id: nil, errors: nil, type: nil, created: nil) ⇒ Log
constructor
A new instance of Log.
Methods inherited from Utils::SubResource
Constructor Details
#initialize(id: nil, purchase: nil, issuing_transaction_id: nil, errors: nil, type: nil, created: nil) ⇒ Log
Returns a new instance of Log.
24 25 26 27 28 29 30 31 |
# File 'lib/issuingpurchase/log.rb', line 24 def initialize(id: nil, purchase: nil, issuing_transaction_id: nil, errors: nil, type: nil, created: nil) super(id) @purchase = purchase @issuing_transaction_id = issuing_transaction_id @errors = errors @type = type @created = StarkInfra::Utils::Checks.check_datetime(created) end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
23 24 25 |
# File 'lib/issuingpurchase/log.rb', line 23 def created @created end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
23 24 25 |
# File 'lib/issuingpurchase/log.rb', line 23 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/issuingpurchase/log.rb', line 23 def id @id end |
#issuing_transaction_id ⇒ Object (readonly)
Returns the value of attribute issuing_transaction_id.
23 24 25 |
# File 'lib/issuingpurchase/log.rb', line 23 def issuing_transaction_id @issuing_transaction_id end |
#purchase ⇒ Object (readonly)
Returns the value of attribute purchase.
23 24 25 |
# File 'lib/issuingpurchase/log.rb', line 23 def purchase @purchase end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/issuingpurchase/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 Infra API by passing its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
Log object with updated attributes
45 46 47 |
# File 'lib/issuingpurchase/log.rb', line 45 def self.get(id, user: nil) StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil) ⇒ Object
# Retrieve paged Logs
Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your purchases.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call
-
ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
-
after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date 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 for log event types. ex: [‘approved’, ‘canceled’, ‘confirmed’, ‘denied’, ‘reversed’, ‘voided’]
-
purchase_ids [list of strings, default nil]: list of Purchase ids to filter logs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
list of Log objects with updated attributes
-
cursor to retrieve the next page of Log objects
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/issuingpurchase/log.rb', line 97 def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil) after = StarkInfra::Utils::Checks.check_date(after) before = StarkInfra::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, ids: ids, limit: limit, after: after, before: before, types: types, purchase_ids: purchase_ids, user: user, **resource ) end |
.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil) ⇒ Object
# Retrieve Logs
Receive a generator of Log objects previously created in the Stark Infra API
## Parameters (optional):
-
ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
-
after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date 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 for log event types. ex: [‘approved’, ‘canceled’, ‘confirmed’, ‘denied’, ‘reversed’, ‘voided’]
-
purchase_ids [list of strings, default nil]: list of Purchase ids to filter logs. ex: [‘5656565656565656’, ‘4545454545454545’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
## Return:
-
generator of Log objects with updated attributes
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/issuingpurchase/log.rb', line 64 def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil) after = StarkInfra::Utils::Checks.check_date(after) before = StarkInfra::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( ids: ids, limit: limit, after: after, before: before, types: types, purchase_ids: purchase_ids, user: user, **resource ) end |
.resource ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/issuingpurchase/log.rb', line 113 def self.resource request_maker = StarkInfra::IssuingPurchase.resource[:resource_maker] { resource_name: 'IssuingPurchaseLog', resource_maker: proc { |json| Log.new( id: json['id'], purchase: StarkInfra::Utils::API.from_api_json(request_maker, json['purchase']), issuing_transaction_id: json['issuing_transaction_id'], errors: json['errors'], type: json['type'], created: json['created'] ) } } end |