starkbank 2.0.0 → 2.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/boleto_holmes/boleto_holmes.rb +121 -0
- data/lib/boleto_holmes/log.rb +91 -0
- data/lib/event/event.rb +3 -1
- data/lib/utils/api.rb +6 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da63502c7b5223de6fb3dd146b38f1bbb812ea44db8be8ed224090ed47d730b
|
4
|
+
data.tar.gz: 5a13dfc89a11da6e3283534c63d4a7d168c3d433f6e0817f45cb30c883a6bd9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52b9461b3caca3b5185afa5818e240f02f2a0de5efe475fdce336f40120b1d46a6a9fec604ceb67bee7221d7f5af89a8b6ce2110aaaf092b903c56d460aa1464
|
7
|
+
data.tar.gz: 3d61fc51d7ddebd01bba544f2d43f8af70e34de78295b505f02e16f9c45832980304038e4397afb43b8c752ec622ccf7ddd1e815e83ae99602619a82a386cd8b
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # BoletoHolmes object
|
9
|
+
#
|
10
|
+
# When you initialize a BoletoHolmes, the entity will not be automatically
|
11
|
+
# created in the Stark Bank API. The 'create' function sends the objects
|
12
|
+
# to the Stark Bank API and returns the list of created objects.
|
13
|
+
#
|
14
|
+
# ## Parameters (required):
|
15
|
+
# - boleto_id [string]: investigated boleto entity ID. ex: '5656565656565656'
|
16
|
+
#
|
17
|
+
# ## Parameters (optional):
|
18
|
+
# - tags [list of strings]: list of strings for tagging
|
19
|
+
#
|
20
|
+
# ## Attributes (return-only):
|
21
|
+
# - id [string, default nil]: unique id returned when holmes is created. ex: '5656565656565656'
|
22
|
+
# - status [string, default nil]: current holmes status. ex: 'solving' or 'solved'
|
23
|
+
# - result [string, default nil]: result of boleto status investigation. ex: 'paid' or 'cancelled'
|
24
|
+
# - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
25
|
+
# - updated [DateTime, default nil]: latest update datetime for the holmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
|
+
class BoletoHolmes < StarkBank::Utils::Resource
|
27
|
+
attr_reader :boleto_id, :tags, :id, :status, :result, :created, :updated
|
28
|
+
def initialize(
|
29
|
+
boleto_id:, tags: nil, id: nil, status: nil, result: nil, created: nil, updated: nil
|
30
|
+
)
|
31
|
+
super(id)
|
32
|
+
@boleto_id = boleto_id
|
33
|
+
@tags = tags
|
34
|
+
@status = status
|
35
|
+
@result = result
|
36
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
37
|
+
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
38
|
+
end
|
39
|
+
|
40
|
+
# # Create BoletoHolmes
|
41
|
+
#
|
42
|
+
# Send a list of BoletoHolmes objects for creation in the Stark Bank API
|
43
|
+
#
|
44
|
+
# ## Parameters (required):
|
45
|
+
# - holmes [list of BoletoHolmes objects]: list of BoletoHolmes objects to be created in the API
|
46
|
+
#
|
47
|
+
# ## Parameters (optional):
|
48
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
49
|
+
#
|
50
|
+
# ## Return:
|
51
|
+
# - list of BoletoHolmes objects with updated attributes
|
52
|
+
def self.create(holmes, user: nil)
|
53
|
+
StarkBank::Utils::Rest.post(entities: holmes, user: user, **resource)
|
54
|
+
end
|
55
|
+
|
56
|
+
# # Retrieve a specific BoletoHolmes
|
57
|
+
#
|
58
|
+
# Receive a single BoletoHolmes object previously created by the Stark Bank API by passing its id
|
59
|
+
#
|
60
|
+
# ## Parameters (required):
|
61
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
62
|
+
#
|
63
|
+
# ## Parameters (optional):
|
64
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
65
|
+
#
|
66
|
+
# ## Return:
|
67
|
+
# - BoletoHolmes object with updated attributes
|
68
|
+
def self.get(id, user: nil)
|
69
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
70
|
+
end
|
71
|
+
|
72
|
+
# # Retrieve BoletoHolmes
|
73
|
+
#
|
74
|
+
# Receive a generator of BoletoHolmes objects previously created in the Stark Bank API
|
75
|
+
#
|
76
|
+
# ## Parameters (optional):
|
77
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
78
|
+
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
79
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
80
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'solved'
|
81
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
82
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
83
|
+
# - boleto_id [string, default nil]: filter for holmes that investigate a specific boleto by its ID. ex: '5656565656565656'
|
84
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
85
|
+
#
|
86
|
+
# ## Return:
|
87
|
+
# - generator of BoletoHolmes objects with updated attributes
|
88
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
|
89
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
90
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
91
|
+
StarkBank::Utils::Rest.get_list(
|
92
|
+
limit: limit,
|
93
|
+
after: after,
|
94
|
+
before: before,
|
95
|
+
status: status,
|
96
|
+
tags: tags,
|
97
|
+
ids: ids,
|
98
|
+
boleto_id: boleto_id,
|
99
|
+
user: user,
|
100
|
+
**resource
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.resource
|
105
|
+
{
|
106
|
+
resource_name: 'BoletoHolmes',
|
107
|
+
resource_maker: proc { |json|
|
108
|
+
BoletoHolmes.new(
|
109
|
+
boleto_id: json['boleto_id'],
|
110
|
+
tags: json['tags'],
|
111
|
+
id: json['id'],
|
112
|
+
status: json['status'],
|
113
|
+
result: json['result'],
|
114
|
+
created: json['created'],
|
115
|
+
updated: json['updated']
|
116
|
+
)
|
117
|
+
}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('boleto_holmes')
|
7
|
+
|
8
|
+
module StarkBank
|
9
|
+
class BoletoHolmes
|
10
|
+
# # BoletoHolmes::Log object
|
11
|
+
#
|
12
|
+
# Every time a BoletoHolmes entity is modified, a corresponding BoletoHolmes::Log
|
13
|
+
# is generated for the entity. This log is never generated by the
|
14
|
+
# user, but it can be retrieved to check additional information
|
15
|
+
# on the BoletoHolmes.
|
16
|
+
#
|
17
|
+
# ## Attributes:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
|
+
# - holmes [BoletoHolmes]: BoletoHolmes entity to which the log refers to.
|
20
|
+
# - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
|
21
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
|
+
class Log < StarkBank::Utils::Resource
|
23
|
+
attr_reader :id, :holmes, :type, :created
|
24
|
+
def initialize(id:, holmes:, type:, created:)
|
25
|
+
super(id)
|
26
|
+
@holmes = holmes
|
27
|
+
@type = type
|
28
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
29
|
+
end
|
30
|
+
|
31
|
+
# # Retrieve a specific Log
|
32
|
+
#
|
33
|
+
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
34
|
+
#
|
35
|
+
# ## Parameters (required):
|
36
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
37
|
+
#
|
38
|
+
# ## Parameters (optional):
|
39
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
40
|
+
#
|
41
|
+
# ## Return:
|
42
|
+
# - Log object with updated attributes
|
43
|
+
def self.get(id, user: nil)
|
44
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
45
|
+
end
|
46
|
+
|
47
|
+
# # Retrieve Logs
|
48
|
+
#
|
49
|
+
# Receive a generator of Log objects previously created in the Stark Bank API
|
50
|
+
#
|
51
|
+
# ## Parameters (optional):
|
52
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
53
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'registered'
|
56
|
+
# - holmes_ids [list of strings, default nil]: list of BoletoHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
57
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
58
|
+
#
|
59
|
+
# ## Return:
|
60
|
+
# - list of Log objects with updated attributes
|
61
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
|
62
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
63
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
64
|
+
StarkBank::Utils::Rest.get_list(
|
65
|
+
limit: limit,
|
66
|
+
after: after,
|
67
|
+
before: before,
|
68
|
+
types: types,
|
69
|
+
holmes_ids: holmes_ids,
|
70
|
+
user: user,
|
71
|
+
**resource
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.resource
|
76
|
+
holmes_maker = StarkBank::BoletoHolmes.resource[:resource_maker]
|
77
|
+
{
|
78
|
+
resource_name: 'BoletoHolmesLog',
|
79
|
+
resource_maker: proc { |json|
|
80
|
+
Log.new(
|
81
|
+
id: json['id'],
|
82
|
+
holmes: StarkBank::Utils::API.from_api_json(holmes_maker, json['holmes']),
|
83
|
+
type: json['type'],
|
84
|
+
created: json['created']
|
85
|
+
)
|
86
|
+
}
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/event/event.rb
CHANGED
@@ -8,6 +8,7 @@ require_relative('../utils/checks')
|
|
8
8
|
require_relative('../utils/cache')
|
9
9
|
require_relative('../error')
|
10
10
|
require_relative('../boleto/log')
|
11
|
+
require_relative('../boleto_holmes/log')
|
11
12
|
require_relative('../transfer/log')
|
12
13
|
require_relative('../boleto_payment/log')
|
13
14
|
require_relative('../utility_payment/log')
|
@@ -37,7 +38,8 @@ module StarkBank
|
|
37
38
|
'transfer': StarkBank::Transfer::Log.resource,
|
38
39
|
'boleto': StarkBank::Boleto::Log.resource,
|
39
40
|
'boleto-payment': StarkBank::BoletoPayment::Log.resource,
|
40
|
-
'utility-payment': StarkBank::UtilityPayment::Log.resource
|
41
|
+
'utility-payment': StarkBank::UtilityPayment::Log.resource,
|
42
|
+
'boleto-holmes': StarkBank::BoletoHolmes::Log.resource
|
41
43
|
}[subscription.to_sym]
|
42
44
|
|
43
45
|
@log = log
|
data/lib/utils/api.rb
CHANGED
@@ -60,7 +60,12 @@ module StarkBank
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.last_name_plural(resource_name)
|
63
|
-
|
63
|
+
base = last_name(resource_name)
|
64
|
+
|
65
|
+
return base if base[-1].eql?('s')
|
66
|
+
return "#{base[0...-1]}ies" if base[-1].eql?('y')
|
67
|
+
|
68
|
+
"#{base}s"
|
64
69
|
end
|
65
70
|
|
66
71
|
def self.last_name(resource_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkbank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: starkbank-ecdsa
|
@@ -75,6 +75,8 @@ files:
|
|
75
75
|
- lib/balance/balance.rb
|
76
76
|
- lib/boleto/boleto.rb
|
77
77
|
- lib/boleto/log.rb
|
78
|
+
- lib/boleto_holmes/boleto_holmes.rb
|
79
|
+
- lib/boleto_holmes/log.rb
|
78
80
|
- lib/boleto_payment/boleto_payment.rb
|
79
81
|
- lib/boleto_payment/log.rb
|
80
82
|
- lib/error.rb
|
@@ -99,7 +101,7 @@ files:
|
|
99
101
|
- lib/utils/rest.rb
|
100
102
|
- lib/utils/url.rb
|
101
103
|
- lib/webhook/webhook.rb
|
102
|
-
homepage: https://github.com/starkbank/sdk-ruby
|
104
|
+
homepage: https://github.com/starkbank/sdk-ruby/tree/feature/boleto-holmes
|
103
105
|
licenses:
|
104
106
|
- MIT
|
105
107
|
metadata: {}
|
@@ -114,9 +116,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
116
|
version: '2.3'
|
115
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
118
|
requirements:
|
117
|
-
- - "
|
119
|
+
- - ">"
|
118
120
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
121
|
+
version: 1.3.1
|
120
122
|
requirements: []
|
121
123
|
rubygems_version: 3.1.4
|
122
124
|
signing_key:
|