Class: StarkInfra::PixInfraction
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkInfra::PixInfraction
- Defined in:
- lib/pixinfraction/pixinfraction.rb,
lib/pixinfraction/log.rb
Overview
# PixInfraction object
PixInfractions are used to report transactions that are suspected of fraud, to request a refund or to reverse a refund. When you initialize a PixInfraction, the entity will not be automatically created in the Stark Infra API. The ‘create’ function sends the objects to the Stark Infra API and returns the created object.
## Parameters (required):
-
reference_id [string]: end_to_end_id or return_id of the transaction being reported. ex: ‘E20018183202201201450u34sDGd19lz’
-
type [string]: type of infraction report. Options: ‘fraud’, ‘reversal’, ‘reversalChargeback’
## Parameters (optional):
-
description [string, default nil]: description for any details that can help with the infraction investigation.
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘travel’, ‘food’]
## Attributes (return-only):
-
id [string]: unique id returned when the PixInfraction is created. ex: ‘5656565656565656’
-
credited_bank_code [string]: bank_code of the credited Pix participant in the reported transaction. ex: ‘20018183’
-
debited_bank_code [string]: bank_code of the debited Pix participant in the reported transaction. ex: ‘20018183’
-
flow [string]: direction of the PixInfraction flow. Options: ‘out’ if you created the PixInfraction, ‘in’ if you received the PixInfraction.
-
analysis [string]: analysis that led to the result.
-
reported_by [string]: agent that reported the PixInfraction. Options: ‘debited’, ‘credited’.
-
result [string]: result after the analysis of the PixInfraction by the receiving party. Options: ‘agreed’, ‘disagreed’
-
status [string]: current PixInfraction status. Options: ‘created’, ‘failed’, ‘delivered’, ‘closed’, ‘canceled’.
-
created [DateTime]: creation datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
updated [DateTime]: latest update datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
Instance Attribute Summary collapse
-
#analysis ⇒ Object
readonly
Returns the value of attribute analysis.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#credited_bank_code ⇒ Object
readonly
Returns the value of attribute credited_bank_code.
-
#debited_bank_code ⇒ Object
readonly
Returns the value of attribute debited_bank_code.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#flow ⇒ Object
readonly
Returns the value of attribute flow.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#reference_id ⇒ Object
readonly
Returns the value of attribute reference_id.
-
#reported_by ⇒ Object
readonly
Returns the value of attribute reported_by.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.cancel(id, user: nil) ⇒ Object
# Cancel a PixInfraction entity.
-
.create(infractions, user: nil) ⇒ Object
# Create PixInfractions.
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific PixInfraction.
-
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, type: nil, user: nil) ⇒ Object
# Retrieve paged PixInfractions.
-
.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, flow: nil, tags: nil, user: nil) ⇒ Object
# Retrieve PixInfractions.
- .resource ⇒ Object
-
.update(id, result:, analysis: nil, user: nil) ⇒ Object
# Update a PixInfraction entity.
Instance Method Summary collapse
-
#initialize(reference_id:, type:, description: nil, id: nil, tags: nil, credited_bank_code: nil, debited_bank_code: nil, flow: nil, analysis: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil) ⇒ PixInfraction
constructor
A new instance of PixInfraction.
Constructor Details
#initialize(reference_id:, type:, description: nil, id: nil, tags: nil, credited_bank_code: nil, debited_bank_code: nil, flow: nil, analysis: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil) ⇒ PixInfraction
Returns a new instance of PixInfraction.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pixinfraction/pixinfraction.rb', line 37 def initialize( reference_id:, type:, description: nil, id: nil, tags: nil, credited_bank_code: nil, debited_bank_code: nil, flow: nil, analysis: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil ) super(id) @reference_id = reference_id @type = type @description = description @tags = @credited_bank_code = credited_bank_code @debited_bank_code = debited_bank_code @flow = flow @analysis = analysis @reported_by = reported_by @result = result @status = status @created = StarkCore::Utils::Checks.check_datetime(created) @updated = StarkCore::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#analysis ⇒ Object (readonly)
Returns the value of attribute analysis.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def analysis @analysis end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def created @created end |
#credited_bank_code ⇒ Object (readonly)
Returns the value of attribute credited_bank_code.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def credited_bank_code @credited_bank_code end |
#debited_bank_code ⇒ Object (readonly)
Returns the value of attribute debited_bank_code.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def debited_bank_code @debited_bank_code end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def description @description end |
#flow ⇒ Object (readonly)
Returns the value of attribute flow.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def flow @flow end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def id @id end |
#reference_id ⇒ Object (readonly)
Returns the value of attribute reference_id.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def reference_id @reference_id end |
#reported_by ⇒ Object (readonly)
Returns the value of attribute reported_by.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def reported_by @reported_by end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def type @type end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
35 36 37 |
# File 'lib/pixinfraction/pixinfraction.rb', line 35 def updated @updated end |
Class Method Details
.cancel(id, user: nil) ⇒ Object
# Cancel a PixInfraction entity
Cancel a PixInfraction entity previously created in the Stark Infra API
## Parameters (required):
-
id [string]: PixInfraction 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:
-
canceled PixInfraction object
191 192 193 |
# File 'lib/pixinfraction/pixinfraction.rb', line 191 def self.cancel(id, user: nil) StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource) end |
.create(infractions, user: nil) ⇒ Object
# Create PixInfractions
Send a list of PixInfraction objects for creation in the Stark Infra API
## Parameters (required):
-
infractions [list of PixInfraction objects]: list of PixInfraction objects to be created in the API. ex: [PixInfraction.new()]
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of PixInfraction objects with updated attributes
69 70 71 |
# File 'lib/pixinfraction/pixinfraction.rb', line 69 def self.create(infractions, user: nil) StarkInfra::Utils::Rest.post(entities: infractions, user: user, **resource) end |
.get(id, user: nil) ⇒ Object
# Retrieve a specific PixInfraction
Receive a single PixInfraction object previously created in 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:
-
PixInfraction object with updated attributes
85 86 87 |
# File 'lib/pixinfraction/pixinfraction.rb', line 85 def self.get(id, user: nil) StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, type: nil, user: nil) ⇒ Object
# Retrieve paged PixInfractions
Receive a list of up to 100 PixInfraction 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 infractions.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call
-
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 or updated only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘success’ or ‘failed’
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
type [string, default nil]: filter for the type of retrieved PixInfractions. Options: ‘fraud’, ‘reversal’, ‘reversalChargeback’
-
flow [string, default nil]: direction of the PixInfraction flow. Options: ‘out’ if you created the PixInfraction, ‘in’ if you received the PixInfraction.
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘travel’, ‘food’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of PixInfraction objects with updated attributes
-
cursor to retrieve the next page of PixInfraction objects
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/pixinfraction/pixinfraction.rb', line 143 def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, type: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, limit: limit, after: after, before: before, status: status, ids: ids, flow: flow, tags: , type: type, user: user, **resource ) end |
.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, flow: nil, tags: nil, user: nil) ⇒ Object
# Retrieve PixInfractions
Receive a generator of PixInfraction objects previously created in the Stark Infra API
## Parameters (optional):
-
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 or updated only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
-
status [string, default nil]: filter for status of retrieved objects. ex: ‘success’ or ‘failed’
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
type [string]: filter for the type of retrieved PixInfractions. Options: ‘fraud’, ‘reversal’, ‘reversalChargeback’
-
flow [string, default nil]: direction of the PixInfraction flow. Options: ‘out’ if you created the PixInfraction, ‘in’ if you received the PixInfraction.
-
tags [list of strings, default nil]: list of strings for tagging. ex: [‘travel’, ‘food’]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
generator of PixInfraction objects with updated attributes
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/pixinfraction/pixinfraction.rb', line 106 def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, flow: nil, tags: nil, user: nil) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( limit: limit, after: after, before: before, status: status, ids: ids, type: type, flow: flow, tags: , user: user, **resource ) end |
.resource ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/pixinfraction/pixinfraction.rb', line 195 def self.resource { resource_name: 'PixInfraction', resource_maker: proc { |json| PixInfraction.new( id: json['id'], reference_id: json['reference_id'], type: json['type'], description: json['description'], tags: json['tags'], credited_bank_code: json['credited_bank_code'], debited_bank_code: json['debited_bank_code'], flow: json['flow'], analysis: json['analysis'], reported_by: json['reported_by'], result: json['result'], status: json['status'], created: json['created'], updated: json['updated'] ) } } end |
.update(id, result:, analysis: nil, user: nil) ⇒ Object
# Update a PixInfraction entity
Respond to a received PixInfraction.
## Parameters (required):
-
id [string]: PixInfraction unique id. ex: ‘5656565656565656’
-
result [string]: result after the analysis of the PixInfraction. Options: ‘agreed’, ‘disagreed’
## Parameters (optional):
-
analysis [string, nil]: analysis that led to the result.
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
PixInfraction object with updated attributes
175 176 177 |
# File 'lib/pixinfraction/pixinfraction.rb', line 175 def self.update(id, result:, analysis: nil, user: nil) StarkInfra::Utils::Rest.patch_id(id: id, result: result, analysis: analysis, user: user, **resource) end |