starkinfra 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +125 -0
  3. data/lib/cardmethod/cardmethod.rb +56 -0
  4. data/lib/creditholmes/creditholmes.rb +160 -0
  5. data/lib/creditnote/creditnote.rb +51 -355
  6. data/lib/creditnote/invoice/description.rb +51 -0
  7. data/lib/creditnote/invoice/discount.rb +49 -0
  8. data/lib/creditnote/invoice/invoice.rb +124 -0
  9. data/lib/creditnote/log.rb +18 -19
  10. data/lib/creditnote/transfer.rb +90 -0
  11. data/lib/creditpreview/creditnotepreview.rb +85 -0
  12. data/lib/creditpreview/creditpreview.rb +77 -0
  13. data/lib/creditsigner/creditsigner.rb +57 -0
  14. data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
  15. data/lib/event/attempt.rb +5 -4
  16. data/lib/event/event.rb +11 -11
  17. data/lib/individualdocument/individualdocument.rb +165 -0
  18. data/lib/individualdocument/log.rb +125 -0
  19. data/lib/individualidentity/individualidentity.rb +193 -0
  20. data/lib/individualidentity/log.rb +124 -0
  21. data/lib/issuingbalance/issuingbalance.rb +4 -4
  22. data/lib/issuingcard/issuingcard.rb +35 -33
  23. data/lib/issuingcard/log.rb +21 -21
  24. data/lib/issuingdesign/issuingdesign.rb +138 -0
  25. data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
  26. data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
  27. data/lib/issuingembossingrequest/log.rb +128 -0
  28. data/lib/issuingholder/issuingholder.rb +21 -15
  29. data/lib/issuingholder/log.rb +19 -19
  30. data/lib/issuinginvoice/issuinginvoice.rb +29 -14
  31. data/lib/issuinginvoice/log.rb +18 -18
  32. data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
  33. data/lib/issuingpurchase/issuingpurchase.rb +111 -31
  34. data/lib/issuingpurchase/log.rb +16 -16
  35. data/lib/issuingrestock/issuingrestock.rb +162 -0
  36. data/lib/issuingrestock/log.rb +127 -0
  37. data/lib/issuingrule/issuingrule.rb +64 -18
  38. data/lib/issuingstock/issuingstock.rb +138 -0
  39. data/lib/issuingstock/log.rb +130 -0
  40. data/lib/issuingtransaction/issuingtransaction.rb +12 -13
  41. data/lib/issuingwithdrawal/issuingwithdrawal.rb +12 -11
  42. data/lib/merchantcategory/merchantcategory.rb +63 -0
  43. data/lib/merchantcountry/merchantcountry.rb +59 -0
  44. data/lib/pixbalance/pixbalance.rb +5 -5
  45. data/lib/pixchargeback/log.rb +15 -15
  46. data/lib/pixchargeback/pixchargeback.rb +32 -20
  47. data/lib/pixclaim/log.rb +21 -24
  48. data/lib/pixclaim/pixclaim.rb +44 -34
  49. data/lib/pixdirector/pixdirector.rb +9 -11
  50. data/lib/pixdomain/certificate.rb +1 -1
  51. data/lib/pixdomain/pixdomain.rb +5 -5
  52. data/lib/pixinfraction/log.rb +20 -20
  53. data/lib/pixinfraction/pixinfraction.rb +23 -15
  54. data/lib/pixkey/log.rb +23 -23
  55. data/lib/pixkey/pixkey.rb +14 -12
  56. data/lib/pixrequest/log.rb +24 -20
  57. data/lib/pixrequest/pixrequest.rb +54 -21
  58. data/lib/pixreversal/log.rb +3 -3
  59. data/lib/pixreversal/pixreversal.rb +48 -21
  60. data/lib/pixstatement/pixstatement.rb +13 -8
  61. data/lib/starkinfra.rb +40 -15
  62. data/lib/staticbrcode/staticbrcode.rb +170 -0
  63. data/lib/user/project.rb +1 -1
  64. data/lib/utils/api.rb +1 -0
  65. data/lib/utils/bacenid.rb +1 -1
  66. data/lib/utils/parse.rb +7 -3
  67. data/lib/utils/request.rb +1 -1
  68. data/lib/utils/resource.rb +1 -1
  69. data/lib/utils/sub_resource.rb +21 -22
  70. data/lib/webhook/webhook.rb +11 -11
  71. metadata +29 -4
  72. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/checks')
5
+ require_relative('IndividualDocument')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ class IndividualDocument
10
+ # # IndividualDocument::Log object
11
+ #
12
+ # Every time an IndividualDocument entity is updated, a corresponding IndividualDocument::Log is generated for the entity.
13
+ # This Log is never generated by the user, but it can be retrieved to check additional information on the IndividualDocument.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - document [IndividualDocument]: IndividualDocument entity to which the log refers to.
18
+ # - errors [list of strings]: list of errors linked to this IndividualDocument event
19
+ # - type [string]: type of the IndividualDocument event which triggered the log creation. ex: 'approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided'.
20
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ class Log < StarkInfra::Utils::Resource
22
+ attr_reader :id, :document, :errors, :type, :created
23
+ def initialize(id: nil, document: nil, errors: nil, type: nil, created: nil)
24
+ super(id)
25
+ @document = document
26
+ @errors = errors
27
+ @type = type
28
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
29
+ end
30
+
31
+ # # Retrieve a specific IndividualDocument::Log
32
+ #
33
+ # Receive a single IndividualDocument::Log object previously created by the Stark Infra 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, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
+ #
41
+ # ## Return:
42
+ # - IndividualDocument::Log object with updated attributes
43
+ def self.get(id, user: nil)
44
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
45
+ end
46
+
47
+ # # Retrieve IndividualDocument::Logs
48
+ #
49
+ # Receive a generator of IndividualDocument::Log objects previously created in the Stark Infra 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 or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date 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: ['created', 'canceled', 'processing', 'failed', 'success']
56
+ # - document_ids [list of strings, default nil]: list of IndividualDocument ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of IndividualDocument::Log objects with updated attributes
61
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, document_ids: nil, user: nil)
62
+ after = StarkInfra::Utils::Checks.check_date(after)
63
+ before = StarkInfra::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ ids: ids,
66
+ limit: limit,
67
+ after: after,
68
+ before: before,
69
+ types: types,
70
+ document_ids: document_ids,
71
+ user: user,
72
+ **resource
73
+ )
74
+ end
75
+
76
+ # # Retrieve paged IndividualDocument::Logs
77
+ #
78
+ # Receive a list of up to 100 IndividualDocument::Log objects previously created in the Stark Infra API and the cursor to the next page.
79
+ # Use this function instead of query if you want to manually page your documents.
80
+ #
81
+ # ## Parameters (optional):
82
+ # - cursor [string, default nil]: cursor returned on the previous page function call
83
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
84
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
85
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
86
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'canceled', 'processing', 'failed', 'success']
87
+ # - document_ids [list of strings, default nil]: list of document ids to filter logs. ex: ['5656565656565656', '4545454545454545']
88
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
89
+ #
90
+ # ## Return:
91
+ # - list of IndividualDocument::Log objects with updated attributes
92
+ # - cursor to retrieve the next page of Log objects
93
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, document_ids: nil, user: nil)
94
+ after = StarkInfra::Utils::Checks.check_date(after)
95
+ before = StarkInfra::Utils::Checks.check_date(before)
96
+ StarkInfra::Utils::Rest.get_page(
97
+ cursor: cursor,
98
+ limit: limit,
99
+ after: after,
100
+ before: before,
101
+ types: types,
102
+ document_ids: document_ids,
103
+ user: user,
104
+ **resource
105
+ )
106
+ end
107
+
108
+ def self.resource
109
+ request_maker = StarkInfra::IndividualDocument.resource[:resource_maker]
110
+ {
111
+ resource_name: 'IndividualDocumentLog',
112
+ resource_maker: proc { |json|
113
+ Log.new(
114
+ id: json['id'],
115
+ document: StarkInfra::Utils::API.from_api_json(request_maker, json['document']),
116
+ errors: json['errors'],
117
+ type: json['type'],
118
+ created: json['created']
119
+ )
120
+ }
121
+ }
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,193 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/parse')
5
+ require_relative('../utils/checks')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ # # IndividualIdentity object
10
+ #
11
+ # An IndividualDocument represents an individual to be validated. It can have several individual documents attached
12
+ # to it, which are used to validate the identity of the individual. Once an individual identity is created, individual
13
+ # documents must be attached to it using the created method of the individual document resource. When all the required
14
+ # individual documents are attached to an individual identity it can be sent to validation by patching its status to
15
+ # processing.
16
+ #
17
+ # When you initialize a IndividualIdentity, the entity will not be automatically
18
+ # created in the Stark Infra API. The 'create' function sends the objects
19
+ # to the Stark Infra API and returns the list of created objects.
20
+ #
21
+ # ## Parameters (required):
22
+ # - name [string]: individual's full name. ex: "Edward Stark".
23
+ # - tax_id [string]: individual's tax ID (CPF). ex: "594.739.480-42"
24
+ #
25
+ # ## Parameters (optional):
26
+ # - tags [list of strings, default nil]: list of strings for reference when searching for IndividualIdentities. ex: ["employees", "monthly"]
27
+ #
28
+ # ## Attributes (return-only):
29
+ # - id [string]: unique id returned when the IndividualIdentity is created. ex: "5656565656565656"
30
+ # - status [string]: current status of the IndividualIdentity. Options: "created", "canceled", "processing", "failed", "success"
31
+ # - created [DateTime]: creation datetime for the IndividualIdentity. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
32
+ class IndividualIdentity < StarkInfra::Utils::Resource
33
+ attr_reader :name, :tax_id, :tags, :id, :status, :created
34
+ def initialize(name:, tax_id:, tags: nil, id: nil, status: nil, created: nil)
35
+ super(id)
36
+ @name = name
37
+ @tax_id = tax_id
38
+ @tags = tags
39
+ @status = status
40
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
41
+ end
42
+
43
+ # # Create IndividualIdentities
44
+ #
45
+ # Send a list of IndividualIdentity objects for creation at the Stark Infra API
46
+ #
47
+ # ## Parameters (required):
48
+ # - identities [list of IndividualIdentity objects]: list of IndividualIdentity objects to be created in the API.
49
+ #
50
+ # ## Parameters (optional):
51
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
52
+ #
53
+ # ## Return:
54
+ # - list of IndividualIdentity objects with updated attributes
55
+ def self.create(identities, user: nil)
56
+ StarkInfra::Utils::Rest.post(entities: identities, user: user, **resource)
57
+ end
58
+
59
+ # # Retrieve a specific IndividualIdentity
60
+ #
61
+ # Receive a single IndividualIdentity object previously created in the Stark Infra API by its id
62
+ #
63
+ # ## Parameters (required):
64
+ # - id [string]: object unique id. ex: "5656565656565656"
65
+ #
66
+ # ## Parameters (optional):
67
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
68
+ #
69
+ # ## Return:
70
+ # - IndividualIdentity object with updated attributes
71
+ def self.get(uuid, user: nil)
72
+ StarkInfra::Utils::Rest.get_id(id: uuid, user: user, **resource)
73
+ end
74
+
75
+ # # Retrieve IndividualIdentities
76
+ #
77
+ # Receive a generator of IndividualIdentity objects previously created in the Stark Infra API
78
+ #
79
+ # ## Parameters (optional):
80
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
81
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
82
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
83
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "canceled", "processing", "failed", "success"]
84
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
85
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
86
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
87
+ #
88
+ # ## Return:
89
+ # - generator of IndividualIdentity objects with updated attributes
90
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
91
+ after = StarkInfra::Utils::Checks.check_date(after)
92
+ before = StarkInfra::Utils::Checks.check_date(before)
93
+ StarkInfra::Utils::Rest.get_stream(
94
+ limit: limit,
95
+ after: after,
96
+ before: before,
97
+ status: status,
98
+ tags: tags,
99
+ ids: ids,
100
+ user: user,
101
+ **resource
102
+ )
103
+ end
104
+
105
+ # # Retrieve paged IndividualIdentities
106
+ #
107
+ # Receive a list of up to 100 IndividualIdentity objects previously created in the Stark Infra API and the cursor to the next page.
108
+ # Use this function instead of query if you want to manually page your requests.
109
+ #
110
+ # ## Parameters (optional):
111
+ # - cursor [string, default nil]: cursor returned on the previous page function call
112
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
113
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
114
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
115
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "canceled", "processing", "failed", "success"]
116
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
117
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
118
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
119
+ #
120
+ # ## Return:
121
+ # - list of IndividualIdentity objects with updated attributes
122
+ # - cursor to retrieve the next page of IndividualIdentity objects
123
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
124
+ after = StarkInfra::Utils::Checks.check_date(after)
125
+ before = StarkInfra::Utils::Checks.check_date(before)
126
+ StarkInfra::Utils::Rest.get_page(
127
+ cursor: cursor,
128
+ limit: limit,
129
+ after: after,
130
+ before: before,
131
+ status: status,
132
+ tags: tags,
133
+ ids: ids,
134
+ user: user,
135
+ **resource
136
+ )
137
+ end
138
+
139
+ # # Update IndividualIdentity entity
140
+ #
141
+ # Update an IndividualIdentity by passing id.
142
+ #
143
+ # ## Parameters (required):
144
+ # - id [string]: IndividualIdentity unique id. ex: '5656565656565656'
145
+ # - status [string]: You may send IndividualDocuments to validation by passing 'processing' in the status
146
+ #
147
+ # ## Parameters (optional):
148
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
149
+ #
150
+ # ## Return:
151
+ # - target IndividualIdentity with updated attributes
152
+ def self.update(id, status:, user: nil)
153
+ StarkInfra::Utils::Rest.patch_id(
154
+ id: id,
155
+ status: status,
156
+ user: user,
157
+ **resource
158
+ )
159
+ end
160
+
161
+ # # Cancel an IndividualIdentity entity
162
+ #
163
+ # Cancel an IndividualIdentity entity previously created in the Stark Infra API
164
+ #
165
+ # ## Parameters (required):
166
+ # - id [string]: IndividualIdentity unique id. ex: '5656565656565656'
167
+ #
168
+ # ## Parameters (optional):
169
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
170
+ #
171
+ # ## Return:
172
+ # - canceled IndividualIdentity object
173
+ def self.cancel(id, user: nil)
174
+ StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
175
+ end
176
+
177
+ def self.resource
178
+ {
179
+ resource_name: 'IndividualIdentity',
180
+ resource_maker: proc { |json|
181
+ IndividualIdentity.new(
182
+ name: json['name'],
183
+ tax_id: json['tax_id'],
184
+ tags: json['tags'],
185
+ id: json['id'],
186
+ status: json['status'],
187
+ created: json['created']
188
+ )
189
+ }
190
+ }
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/checks')
5
+ require_relative('IndividualIdentity')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ class IndividualIdentity
10
+ # # IndividualIdentity::Log object
11
+ #
12
+ # Every time an IndividualIdentity entity is updated, a corresponding IndividualIdentity::Log is generated for the entity.
13
+ # This Log is never generated by the user, but it can be retrieved to check additional information on the IndividualIdentity.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - identity [IndividualIdentity]: IndividualIdentity entity to which the log refers to.
18
+ # - errors [list of strings]: list of errors linked to this IndividualIdentity event
19
+ # - type [string]: type of the IndividualIdentity event which triggered the log creation. ex: "created", "canceled", "processing", "failed", "success"
20
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ class Log < StarkInfra::Utils::Resource
22
+ attr_reader :id, :identity, :errors, :type, :created
23
+ def initialize(id: nil, identity: nil, errors: nil, type: nil, created: nil)
24
+ super(id)
25
+ @identity = identity
26
+ @errors = errors
27
+ @type = type
28
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
29
+ end
30
+
31
+ # # Retrieve a specific IndividualIdentity::Log
32
+ #
33
+ # Receive a single IndividualIdentity::Log object previously created by the Stark Infra 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, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
+ #
41
+ # ## Return:
42
+ # - IndividualIdentity::Log object with updated attributes
43
+ def self.get(id, user: nil)
44
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
45
+ end
46
+
47
+ # # Retrieve IndividualIdentity::Logs
48
+ #
49
+ # Receive a generator of IndividualIdentity::Log objects previously created in the Stark Infra 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 or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date 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: "created", "canceled", "processing", "failed", "success"
56
+ # - identity_ids [list of strings, default nil]: list of identity ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of IndividualIdentity::Log objects with updated attributes
61
+ def self.query(limit: nil, after: nil, before: nil, types: nil, identity_ids: nil, user: nil)
62
+ after = StarkInfra::Utils::Checks.check_date(after)
63
+ before = StarkInfra::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ limit: limit,
66
+ after: after,
67
+ before: before,
68
+ types: types,
69
+ identity_ids: identity_ids,
70
+ user: user,
71
+ **resource
72
+ )
73
+ end
74
+
75
+ # # Retrieve paged IndividualIdentity::Logs
76
+ #
77
+ # Receive a list of up to 100 IndividualIdentity::Log objects previously created in the Stark Infra API and the cursor to the next page.
78
+ # Use this function instead of query if you want to manually page your identities.
79
+ #
80
+ # ## Parameters (optional):
81
+ # - cursor [string, default nil]: cursor returned on the previous page function call
82
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
83
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
84
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
85
+ # - types [list of strings, default nil]: filter for log event types. ex: "created", "canceled", "processing", "failed", "success"
86
+ # - identity_ids [list of strings, default nil]: list of identity ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
88
+ #
89
+ # ## Return:
90
+ # - list of IndividualIdentity::Log objects with updated attributes
91
+ # - cursor to retrieve the next page of Log objects
92
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, identity_ids: nil, user: nil)
93
+ after = StarkInfra::Utils::Checks.check_date(after)
94
+ before = StarkInfra::Utils::Checks.check_date(before)
95
+ StarkInfra::Utils::Rest.get_page(
96
+ cursor: cursor,
97
+ limit: limit,
98
+ after: after,
99
+ before: before,
100
+ types: types,
101
+ identity_ids: identity_ids,
102
+ user: user,
103
+ **resource
104
+ )
105
+ end
106
+
107
+ def self.resource
108
+ request_maker = StarkInfra::IndividualIdentity.resource[:resource_maker]
109
+ {
110
+ resource_name: 'IndividualIdentityLog',
111
+ resource_maker: proc { |json|
112
+ Log.new(
113
+ id: json['id'],
114
+ identity: StarkInfra::Utils::API.from_api_json(request_maker, json['identity']),
115
+ errors: json['errors'],
116
+ type: json['type'],
117
+ created: json['created']
118
+ )
119
+ }
120
+ }
121
+ end
122
+ end
123
+ end
124
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # IssuingBalance object
@@ -13,7 +13,7 @@ module StarkInfra
13
13
  #
14
14
  # ## Attributes (return-only):
15
15
  # - id [string]: unique id returned when IssuingBalance is created. ex: '5656565656565656'
16
- # - amount [integer]: current balance amount of the Workspace in cents. ex: 200 (= R$ 2.00)
16
+ # - amount [integer]: current issuing balance amount of the Workspace in cents. ex: 200 (= R$ 2.00)
17
17
  # - currency [string]: currency of the current Workspace. Expect others to be added eventually. ex: 'BRL'
18
18
  # - updated [DateTime]: latest update datetime for the IssuingBalance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
19
  class IssuingBalance < StarkInfra::Utils::Resource
@@ -43,10 +43,10 @@ module StarkInfra
43
43
  resource_name: 'IssuingBalance',
44
44
  resource_maker: proc { |json|
45
45
  IssuingBalance.new(
46
+ id: json['id'],
46
47
  amount: json['amount'],
47
48
  currency: json['currency'],
48
- updated: json['updated'],
49
- id: json['id']
49
+ updated: json['updated']
50
50
  )
51
51
  }
52
52
  }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # IssuingCard object
@@ -17,9 +17,9 @@ module StarkInfra
17
17
  #
18
18
  # ## Parameters (optional):
19
19
  # - display_name [string, default nil]: card displayed name. ex: 'ANTHONY STARK'
20
- # - rules [list of IssuingRule objects, default []]: [EXPANDABLE] list of card spending rules.
21
- # - bin_id [string, default nil]: BIN ID to which the card is bound. ex: '53810200'
22
- # - tags [list of strings, default []]: list of strings for tagging. ex: ['travel', 'food']
20
+ # - rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of card spending rules.
21
+ # - product_id [string, default nil]: card product ID to which the card is bound. ex: '53810200'
22
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
23
23
  # - street_line_1 [string, default sub-issuer street line 1]: card holder main address. ex: 'Av. Paulista, 200'
24
24
  # - street_line_2 [string, default sub-issuer street line 2]: card holder address complement. ex: 'Apto. 123'
25
25
  # - district [string, default sub-issuer district]: card holder address district / neighbourhood. ex: 'Bela Vista'
@@ -38,32 +38,31 @@ module StarkInfra
38
38
  # - created [DateTime]: creation datetime for the IssuingCard. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
39
39
  # - updated [DateTime]: latest update datetime for the IssuingCard. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
40
40
  class IssuingCard < StarkInfra::Utils::Resource
41
- attr_reader :id, :holder_id, :holder_name, :holder_tax_id, :holder_external_id, :type, :display_name, :status,
42
- :rules, :bin_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :tags, :number,
43
- :security_code, :expiration, :created, :updated
41
+ attr_reader :id, :holder_name, :holder_tax_id, :holder_external_id, :display_name, :rules, :product_id, :tags,
42
+ :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :holder_id,
43
+ :type, :status, :number, :security_code, :expiration, :created, :updated
44
44
  def initialize(
45
- holder_name:, holder_tax_id:, holder_external_id:, id: nil, holder_id: nil, type: nil,
46
- display_name: nil, status: nil, rules: nil, bin_id: nil, street_line_1: nil, street_line_2: nil, district: nil,
47
- city: nil, state_code: nil, zip_code: nil, tags: nil, number: nil, security_code: nil, expiration: nil,
48
- created: nil, updated: nil
45
+ holder_name: , holder_tax_id: , holder_external_id: , display_name: nil, rules: nil, product_id: nil, tags: nil,
46
+ street_line_1: nil, street_line_2: nil, district: nil, city: nil, state_code: nil, zip_code: nil, id: nil,
47
+ holder_id: nil, type: nil, status: nil, number: nil, security_code: nil, expiration: nil, created: nil, updated: nil
49
48
  )
50
49
  super(id)
51
50
  @holder_name = holder_name
52
51
  @holder_tax_id = holder_tax_id
53
52
  @holder_external_id = holder_external_id
54
- @holder_id = holder_id
55
- @type = type
56
53
  @display_name = display_name
57
- @status = status
58
54
  @rules = StarkInfra::IssuingRule.parse_rules(rules)
59
- @bin_id = bin_id
55
+ @product_id = product_id
56
+ @tags = tags
60
57
  @street_line_1 = street_line_1
61
58
  @street_line_2 = street_line_2
62
59
  @district = district
63
60
  @city = city
64
61
  @state_code = state_code
65
62
  @zip_code = zip_code
66
- @tags = tags
63
+ @holder_id = holder_id
64
+ @type = type
65
+ @status = status
67
66
  @number = number
68
67
  @security_code = security_code
69
68
  expiration = nil if !expiration.nil? && expiration.include?('*')
@@ -111,14 +110,14 @@ module StarkInfra
111
110
  #
112
111
  # ## Parameters (optional):
113
112
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
114
- # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
115
- # - after [DateTime or string, default nil] date filter for objects created only after specified date. ex: DateTime.new(2020, 3, 10)
116
- # - before [DateTime or string, default nil] date filter for objects created only before specified date. ex: DateTime.new(2020, 3, 10)
113
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
114
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
117
115
  # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'blocked', 'canceled', 'expired']
118
116
  # - types [list of strings, default nil]: card type. ex: ['virtual']
119
- # - holder_ids [list of strings]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
117
+ # - holder_ids [list of strings, default nil]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
120
118
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
121
- # - expand [list of strings, default []]: fields to expand information. ex: ['rules', 'security_code', 'number', 'expiration']
119
+ # - expand [list of strings, default nil]: fields to expand information. ex: ['rules', 'security_code', 'number', 'expiration']
120
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
122
121
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
123
122
  #
124
123
  # ## Return:
@@ -144,23 +143,24 @@ module StarkInfra
144
143
 
145
144
  # # Retrieve paged IssuingCards
146
145
  #
147
- # Receive a list of IssuingCards objects previously created in the Stark Infra API and the cursor to the next page.
146
+ # Receive a list of up to 100 IssuingCard objects previously created in the Stark Infra API and the cursor to the next page.
147
+ # Use this function instead of query if you want to manually page your identities.
148
148
  #
149
149
  # ## Parameters (optional):
150
150
  # - cursor [string, default nil]: cursor returned on the previous page function call.
151
151
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
152
152
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
153
- # - after [DateTime or string, default nil] date filter for objects created only after specified date. ex: DateTime.new(2020, 3, 10)
154
- # - before [DateTime or string, default nil] date filter for objects created only before specified date. ex: DateTime.new(2020, 3, 10)
153
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
154
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
155
155
  # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'blocked', 'canceled', 'expired']
156
156
  # - types [list of strings, default nil]: card type. ex: ['virtual']
157
- # - holder_ids [list of strings]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
157
+ # - holder_ids [list of strings, default nil]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
158
158
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
159
- # - expand [list of strings, default []]: fields to expand information. ex: ['rules', 'security_code', 'number', 'expiration']
159
+ # - expand [list of strings, default nil]: fields to expand information. ex: ['rules', 'security_code', 'number', 'expiration']
160
160
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
161
161
  #
162
162
  # ## Return:
163
- # - list of IssuingCards objects with updated attributes
163
+ # - list of IssuingCard objects with updated attributes
164
164
  # - cursor to retrieve the next page of IssuingCards objects
165
165
  def self.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil,
166
166
  tags: nil, expand: nil, user: nil)
@@ -191,6 +191,7 @@ module StarkInfra
191
191
  #
192
192
  # ## Parameters (optional):
193
193
  # - status [string, default nil]: You may block the IssuingCard by passing 'blocked' or activate by passing 'active' in the status
194
+ # - pin [string, default nil]: You may unlock your physical card by passing its PIN. This is also the PIN you use to authorize a purhcase.
194
195
  # - display_name [string, default nil]: card displayed name
195
196
  # - rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of card spending rules.
196
197
  # - tags [list of strings, default nil]: list of strings for tagging
@@ -198,10 +199,11 @@ module StarkInfra
198
199
  #
199
200
  # ## Return:
200
201
  # - target IssuingCard with updated attributes
201
- def self.update(id, status: nil, display_name: nil, rules: nil, tags: nil, user: nil)
202
+ def self.update(id, status: nil, display_name: nil, pin: nil, rules: nil, tags: nil, user: nil)
202
203
  StarkInfra::Utils::Rest.patch_id(
203
204
  id: id,
204
205
  status: status,
206
+ pin: pin,
205
207
  display_name: display_name,
206
208
  rules: rules,
207
209
  tags: tags,
@@ -232,22 +234,22 @@ module StarkInfra
232
234
  resource_maker: proc { |json|
233
235
  IssuingCard.new(
234
236
  id: json['id'],
235
- holder_id: json['holder_id'],
236
237
  holder_name: json['holder_name'],
237
238
  holder_tax_id: json['holder_tax_id'],
238
239
  holder_external_id: json['holder_external_id'],
239
- type: json['type'],
240
240
  display_name: json['display_name'],
241
- status: json['status'],
242
241
  rules: json['rules'],
243
- bin_id: json['bin_id'],
242
+ product_id: json['product_id'],
243
+ tags: json['tags'],
244
244
  street_line_1: json['street_line_1'],
245
245
  street_line_2: json['street_line_2'],
246
246
  district: json['district'],
247
247
  city: json['city'],
248
248
  state_code: json['state_code'],
249
249
  zip_code: json['zip_code'],
250
- tags: json['tags'],
250
+ holder_id: json['holder_id'],
251
+ type: json['type'],
252
+ status: json['status'],
251
253
  number: json['number'],
252
254
  security_code: json['security_code'],
253
255
  expiration: json['expiration'],