starkbank 2.1.0.beta2 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98835d3b25dff96530638da6c2da72f1c8acbe7cb3a5fdb45a25e5506f8cb153
4
- data.tar.gz: b298cf063b7b824658c247122c3135302096924332b311d638089573aea432cc
3
+ metadata.gz: dbed048429aad2e04ad3226ed8cd597d988bc14763c3e226e577772bd27818cf
4
+ data.tar.gz: 2045245ba00583edbf1db41f3b2714f1a8d82ccc1e71db8832e45d2265f092ec
5
5
  SHA512:
6
- metadata.gz: 778c03a3493122b36fc1f1cd521e96c9a45035f5ff4590fc8189c17da4d3be177e890f8de65978e1c16eda9f4d3362e97e018e3f032186a0fe99a011df45e6d8
7
- data.tar.gz: 8a992c980902e97809cded32d229f72b4ef8e4c1adc6d2d8e8f67c7eb8a0c7efc5bf7bbc6faec265ad5a741ae0219de1f5d2bb507f501cef9e5c55338e34e5e7
6
+ metadata.gz: d5bc2d1a572a759437fae2afb50b6a257212d1b8e65134ea431ee3fbc5a1fcac69871c26bf6e53e5beab2b8770ee93a153a790a76c08726242211c81aa4e48e8
7
+ data.tar.gz: dd18ce715eb83485f5dfadd56f03ad9f08b24d0c2ec27aa21416cfae3e924304cf8a2d7c52b3f40f6e55f0b7b14fab9ff53b91ec5f9083b5d50a43aa15e06285
@@ -31,7 +31,7 @@ module StarkBank
31
31
  # Receive the Balance object linked to your workspace in the Stark Bank API
32
32
  #
33
33
  # ## Parameters (optional):
34
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
34
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
35
35
  #
36
36
  # ## Return:
37
37
  # - Balance object with updated attributes
@@ -82,7 +82,7 @@ module StarkBank
82
82
  # - boletos [list of Boleto objects]: list of Boleto objects to be created in the API
83
83
  #
84
84
  # ## Parameters (optional):
85
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
85
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
86
86
  #
87
87
  # ## Return:
88
88
  # - list of Boleto objects with updated attributes
@@ -98,7 +98,7 @@ module StarkBank
98
98
  # - id [string]: object unique id. ex: '5656565656565656'
99
99
  #
100
100
  # ## Parameters (optional):
101
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
101
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
102
102
  #
103
103
  # ## Return:
104
104
  # - Boleto object with updated attributes
@@ -115,12 +115,13 @@ module StarkBank
115
115
  #
116
116
  # ## Parameters (optional):
117
117
  # - layout [string]: Layout specification. Available options are "default" and "booklet"
118
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
118
+ # - hidden_fields [list of strings, default nil]: List of string fields to be hidden in Boleto pdf. ex: ["customerAddress"]
119
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
119
120
  #
120
121
  # ## Return:
121
122
  # - Boleto pdf file
122
- def self.pdf(id, layout: nil, user: nil)
123
- StarkBank::Utils::Rest.get_pdf(id: id, layout: layout, user: user, **resource)
123
+ def self.pdf(id, layout: nil, hidden_fields: nil, user: nil)
124
+ StarkBank::Utils::Rest.get_pdf(id: id, layout: layout, hidden_fields: hidden_fields, user: user, **resource)
124
125
  end
125
126
 
126
127
  # # Retrieve Boletos
@@ -134,7 +135,7 @@ module StarkBank
134
135
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
135
136
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
136
137
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
137
- # - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
138
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
138
139
  #
139
140
  # ## Return:
140
141
  # - generator of Boleto objects with updated attributes
@@ -161,7 +162,7 @@ module StarkBank
161
162
  # - id [string]: Boleto unique id. ex: '5656565656565656'
162
163
  #
163
164
  # ## Parameters (optional):
164
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
165
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
165
166
  #
166
167
  # ## Return:
167
168
  # - deleted Boleto object
@@ -38,7 +38,7 @@ module StarkBank
38
38
  # - id [string]: object unique id. ex: '5656565656565656'
39
39
  #
40
40
  # ## Parameters (optional):
41
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
41
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
42
42
  #
43
43
  # ## Return:
44
44
  # - Log object with updated attributes
@@ -56,7 +56,7 @@ module StarkBank
56
56
  # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
57
57
  # - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'registered'
58
58
  # - boleto_ids [list of strings, default nil]: list of Boleto ids to filter logs. ex: ['5656565656565656', '4545454545454545']
59
- # - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
59
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
60
60
  #
61
61
  # ## Return:
62
62
  # - list of Log objects with updated attributes
@@ -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 [Organization/Project object]: Organization or 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 [Organization/Project object]: Organization or 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 [Organization/Project object]: Organization or 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 [Organization/Project object]: Organization or 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 [Organization/Project object]: Organization or 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
@@ -53,7 +53,7 @@ module StarkBank
53
53
  # - payments [list of BoletoPayment objects]: list of BoletoPayment objects to be created in the API
54
54
  #
55
55
  # ## Parameters (optional):
56
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
56
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
57
57
  #
58
58
  # ## Return:
59
59
  # - list of BoletoPayment objects with updated attributes
@@ -69,7 +69,7 @@ module StarkBank
69
69
  # - id [string]: object unique id. ex: '5656565656565656'
70
70
  #
71
71
  # ## Parameters (optional):
72
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
72
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
73
73
  #
74
74
  # ## Return:
75
75
  # - BoletoPayment object with updated attributes
@@ -86,7 +86,7 @@ module StarkBank
86
86
  # - id [string]: object unique id. ex: '5656565656565656'
87
87
  #
88
88
  # ## Parameters (optional):
89
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
89
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
90
90
  #
91
91
  # ## Return:
92
92
  # - BoletoPayment pdf file
@@ -105,7 +105,7 @@ module StarkBank
105
105
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
106
106
  # - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
107
107
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
108
- # - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
108
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
109
109
  #
110
110
  # ## Return:
111
111
  # - generator of BoletoPayment objects with updated attributes
@@ -131,7 +131,7 @@ module StarkBank
131
131
  # Parameters (required):
132
132
  # - id [string]: BoletoPayment unique id. ex: '5656565656565656'
133
133
  # Parameters (optional):
134
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
134
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
135
135
  # Return:
136
136
  # - deleted BoletoPayment object
137
137
  def self.delete(id, user: nil)
@@ -38,7 +38,7 @@ module StarkBank
38
38
  # - id [string]: object unique id. ex: '5656565656565656'
39
39
  #
40
40
  # ## Parameters (optional):
41
- # - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
41
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
42
42
  #
43
43
  # ## Return:
44
44
  # - Log object with updated attributes
@@ -54,9 +54,9 @@ module StarkBank
54
54
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
55
55
  # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
56
  # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
57
- # - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'paid' or 'registered'
57
+ # - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'success' or 'failed'
58
58
  # - payment_ids [list of strings, default nil]: list of BoletoPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
59
- # - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
59
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
60
60
  #
61
61
  # ## Return:
62
62
  # - list of Log objects with updated attributes
@@ -0,0 +1,167 @@
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
+ # # BrcodePayment object
9
+ #
10
+ # When you initialize a BrcodePayment, 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
+ # - brcode [string]: String loaded directly from the QRCode or copied from the invoice. ex: "00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A"
16
+ # - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
17
+ # - description [string]: Text to be displayed in your statement (min. 10 characters). ex: "payment ABC"
18
+ #
19
+ # ## Parameters (conditionally required):
20
+ # - amount [int, default nil]: If the BRCode does not provide an amount, this parameter is mandatory, else it is optional. ex: 23456 (= R$ 234.56)
21
+ #
22
+ # ## Parameters (optional):
23
+ # - scheduled [datetime.date, datetime.datetime or string, default now]: payment scheduled date or datetime. ex: datetime.datetime(2020, 3, 10, 15, 17, 3)
24
+ # - tags [list of strings, default nil]: list of strings for tagging
25
+ #
26
+ # ## Attributes (return-only):
27
+ # - id [string, default nil]: unique id returned when payment is created. ex: "5656565656565656"
28
+ # - status [string, default nil]: current payment status. ex: "success" or "failed"
29
+ # - type [string, default nil]: brcode type. ex: "static" or "dynamic"
30
+ # - fee [integer, default nil]: fee charged when the brcode payment is created. ex: 200 (= R$ 2.00)
31
+ # - updated [datetime.datetime, default nil]: latest update datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
32
+ # - created [datetime.datetime, default nil]: creation datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
33
+ class BrcodePayment < StarkBank::Utils::Resource
34
+ attr_reader :brcode, :tax_id, :description, :amount, :scheduled, :tags, :id, :status, :type, :fee, :updated, :created
35
+ def initialize(brcode:, tax_id:, description:, amount: nil, scheduled: nil, tags: nil, id: nil, status: nil, type: nil, fee: nil, updated: nil, created: nil)
36
+ super(id)
37
+ @brcode = brcode
38
+ @tax_id = tax_id
39
+ @description = description
40
+ @amount = amount
41
+ @scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
42
+ @tags = tags
43
+ @status = status
44
+ @type = type
45
+ @fee = fee
46
+ @updated = StarkBank::Utils::Checks.check_datetime(updated)
47
+ @created = StarkBank::Utils::Checks.check_datetime(created)
48
+ end
49
+
50
+ # # Create BrcodePayments
51
+ #
52
+ # Send a list of BrcodePayment objects for creation in the Stark Bank API
53
+ #
54
+ # ## Parameters (required):
55
+ # - payments [list of BrcodePayment objects]: list of BrcodePayment objects to be created in the API
56
+ #
57
+ # ## Parameters (optional):
58
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
59
+ #
60
+ # ## Return:
61
+ # - list of BrcodePayment objects with updated attributes
62
+ def self.create(payments, user: nil)
63
+ StarkBank::Utils::Rest.post(entities: payments, user: user, **resource)
64
+ end
65
+
66
+ # # Retrieve a specific BrcodePayment
67
+ #
68
+ # Receive a single BrcodePayment object previously created by the Stark Bank API by passing its id
69
+ #
70
+ # ## Parameters (required):
71
+ # - id [string]: object unique id. ex: '5656565656565656'
72
+ #
73
+ # ## Parameters (optional):
74
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
75
+ #
76
+ # ## Return:
77
+ # - BrcodePayment object with updated attributes
78
+ def self.get(id, user: nil)
79
+ StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
80
+ end
81
+
82
+ # # Retrieve a specific BrcodePayment pdf file
83
+ #
84
+ # Receive a single BrcodePayment pdf file generated in the Stark Bank API by passing its id.
85
+ #
86
+ # ## Parameters (required):
87
+ # - id [string]: object unique id. ex: '5656565656565656'
88
+ #
89
+ # ## Parameters (optional):
90
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
91
+ #
92
+ # ## Return:
93
+ # - BrcodePayment pdf file
94
+ def self.pdf(id, user: nil)
95
+ StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
96
+ end
97
+
98
+ # # Update a BrcodePayment entity
99
+ #
100
+ # Update a BrcodePayment entity previously created in the Stark Bank API
101
+ #
102
+ # ## Parameters (required):
103
+ # - id [string]: BrcodePayment unique id. ex: '5656565656565656'
104
+ # - status [string, nil]: You may cancel the payment by passing 'canceled' in the status
105
+ #
106
+ # ## Parameters (optional):
107
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
108
+ #
109
+ # ## Return:
110
+ # - updated BrcodePayment object
111
+ def self.update(id, status: nil, user: nil)
112
+ StarkBank::Utils::Rest.patch_id(id: id, status: status, user: user, **resource)
113
+ end
114
+
115
+ # # Retrieve BrcodePayments
116
+ #
117
+ # Receive a generator of BrcodePayment objects previously created in the Stark Bank API
118
+ #
119
+ # ## Parameters (optional):
120
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
121
+ # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
122
+ # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
123
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
124
+ # - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
125
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
126
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
127
+ #
128
+ # ## Return:
129
+ # - generator of BrcodePayment objects with updated attributes
130
+ def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
131
+ after = StarkBank::Utils::Checks.check_date(after)
132
+ before = StarkBank::Utils::Checks.check_date(before)
133
+ StarkBank::Utils::Rest.get_list(
134
+ user: user,
135
+ limit: limit,
136
+ after: after,
137
+ before: before,
138
+ tags: tags,
139
+ ids: ids,
140
+ status: status,
141
+ **resource
142
+ )
143
+ end
144
+
145
+ def self.resource
146
+ {
147
+ resource_name: 'BrcodePayment',
148
+ resource_maker: proc { |json|
149
+ BrcodePayment.new(
150
+ brcode: json['brcode'],
151
+ tax_id: json['tax_id'],
152
+ description: json['description'],
153
+ amount: json['amount'],
154
+ scheduled: json['scheduled'],
155
+ tags: json['tags'],
156
+ id: json['id'],
157
+ status: json['status'],
158
+ type: json['type'],
159
+ fee: json['fee'],
160
+ updated: json['updated'],
161
+ created: json['created']
162
+ )
163
+ }
164
+ }
165
+ end
166
+ end
167
+ end