starkinfra 0.0.2 → 0.0.3

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/creditnote/creditnote.rb +561 -0
  3. data/lib/creditnote/log.rb +126 -0
  4. data/lib/event/attempt.rb +126 -0
  5. data/lib/event/event.rb +125 -7
  6. data/lib/issuingauthorization/issuingauthorization.rb +141 -0
  7. data/lib/issuingbalance/issuingbalance.rb +55 -0
  8. data/lib/issuingbin/issuingbin.rb +89 -0
  9. data/lib/issuingcard/issuingcard.rb +260 -0
  10. data/lib/issuingcard/log.rb +123 -0
  11. data/lib/issuingholder/issuingholder.rb +206 -0
  12. data/lib/issuingholder/log.rb +123 -0
  13. data/lib/issuinginvoice/issuinginvoice.rb +152 -0
  14. data/lib/issuinginvoice/log.rb +120 -0
  15. data/lib/issuingpurchase/issuingpurchase.rb +209 -0
  16. data/lib/issuingpurchase/log.rb +131 -0
  17. data/lib/issuingrule/issuingrule.rb +81 -0
  18. data/lib/issuingtransaction/issuingtransaction.rb +136 -0
  19. data/lib/issuingwithdrawal/issuingwithdrawal.rb +153 -0
  20. data/lib/pixbalance/pixbalance.rb +13 -13
  21. data/lib/pixchargeback/log.rb +129 -0
  22. data/lib/pixchargeback/pixchargeback.rb +225 -0
  23. data/lib/pixclaim/log.rb +135 -0
  24. data/lib/pixclaim/pixclaim.rb +225 -0
  25. data/lib/pixdirector/pixdirector.rb +76 -0
  26. data/lib/pixdomain/certificate.rb +30 -0
  27. data/lib/pixdomain/pixdomain.rb +58 -0
  28. data/lib/pixinfraction/log.rb +129 -0
  29. data/lib/pixinfraction/pixinfraction.rb +212 -0
  30. data/lib/pixkey/log.rb +128 -0
  31. data/lib/pixkey/pixkey.rb +239 -0
  32. data/lib/pixrequest/log.rb +16 -16
  33. data/lib/pixrequest/pixrequest.rb +66 -67
  34. data/lib/pixreversal/log.rb +13 -12
  35. data/lib/pixreversal/pixreversal.rb +72 -71
  36. data/lib/pixstatement/pixstatement.rb +22 -23
  37. data/lib/starkinfra.rb +32 -2
  38. data/lib/user/organization.rb +54 -0
  39. data/lib/user/project.rb +37 -0
  40. data/lib/user/user.rb +20 -0
  41. data/lib/utils/api.rb +10 -2
  42. data/lib/utils/bacenid.rb +19 -0
  43. data/lib/utils/checks.rb +2 -3
  44. data/lib/utils/endtoendid.rb +11 -0
  45. data/lib/utils/parse.rb +13 -13
  46. data/lib/utils/request.rb +1 -1
  47. data/lib/utils/rest.rb +7 -5
  48. data/lib/utils/returnid.rb +11 -0
  49. data/lib/webhook/webhook.rb +124 -0
  50. metadata +45 -24
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+ require_relative('issuingholder')
7
+
8
+ module StarkInfra
9
+ class IssuingHolder
10
+ # # IssuingHolder::Log object
11
+ #
12
+ # Every time an IssuingHolder entity is updated, a corresponding IssuingHolder.Log is generated for the entity. This
13
+ # log is never generated by the user, but it can be retrieved to check additional information on the IssuingHolder.
14
+ #
15
+ # ## Attributes:
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - holder [IssuingHolder]: IssuingHolder entity to which the log refers to.
18
+ # - type [string]: type of the IssuingHolder event which triggered the log creation. ex: 'blocked', 'canceled', 'created', 'unblocked', 'updated'
19
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class Log < StarkInfra::Utils::Resource
21
+ attr_reader :id, :created, :type, :holder
22
+ def initialize(id:, created:, type:, holder:)
23
+ super(id)
24
+ @type = type
25
+ @holder = holder
26
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
27
+ end
28
+
29
+ # # Retrieve a specific Log
30
+ #
31
+ # Receive a single Log object previously created by the Stark Infra API by passing its id
32
+ #
33
+ # ## Parameters (required):
34
+ # - id [string]: object unique id. ex: '5656565656565656'
35
+ #
36
+ # ## Parameters (optional):
37
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
38
+ #
39
+ # ## Return:
40
+ # - Log object with updated attributes
41
+ def self.get(id, user: nil)
42
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
43
+ end
44
+
45
+ # # Retrieve Logs
46
+ #
47
+ # Receive a generator of Log objects previously created in the Stark Infra API
48
+ #
49
+ # ## Parameters (optional):
50
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Max = 100. ex: 35
51
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
52
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
53
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
54
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'blocked']
55
+ # - holder_ids [list of strings, default nil]: list of IssuingHolder ids to filter logs. ex: ['5656565656565656', '4545454545454545']
56
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
57
+ #
58
+ # ## Return:
59
+ # - generator of Log objects with updated attributes
60
+ def self.query(limit: nil, after: nil, before: nil, types: nil, holder_ids: nil, user: nil)
61
+ after = StarkInfra::Utils::Checks.check_date(after)
62
+ before = StarkInfra::Utils::Checks.check_date(before)
63
+ StarkInfra::Utils::Rest.get_stream(
64
+ limit: limit,
65
+ after: after,
66
+ before: before,
67
+ types: types,
68
+ holder_ids: holder_ids,
69
+ user: user,
70
+ **resource
71
+ )
72
+ end
73
+
74
+ # # Retrieve paged Logs
75
+ #
76
+ # Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
77
+ # Use this function instead of query if you want to manually page your holders.
78
+ #
79
+ # ## Parameters (optional):
80
+ # - cursor [string, default nil]: cursor returned on the previous page function call
81
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Max = 100. ex: 35
82
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
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', 'blocked']
86
+ # - holder_ids [list of strings, default nil]: list of IssuingHolder 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 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, holder_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
+ holder_ids: holder_ids,
102
+ user: user,
103
+ **resource
104
+ )
105
+ end
106
+
107
+ def self.resource
108
+ request_maker = StarkInfra::IssuingHolder.resource[:resource_maker]
109
+ {
110
+ resource_name: 'IssuingHolderLog',
111
+ resource_maker: proc { |json|
112
+ Log.new(
113
+ id: json['id'],
114
+ created: json['created'],
115
+ type: json['type'],
116
+ holder: StarkInfra::Utils::API.from_api_json(request_maker, json['holder'])
117
+ )
118
+ }
119
+ }
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,152 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+
7
+ module StarkInfra
8
+ # # IssuingInvoice object
9
+ #
10
+ # The IssuingInvoice objects created in your Workspace load your Issuing balance when paid.
11
+ #
12
+ # ## Parameters (required):
13
+ # - amount [integer]: IssuingInvoice value in cents. ex: 1234 (= R$ 12.34)
14
+ #
15
+ # ## Parameters (optional):
16
+ # - tax_id [string, default sub-issuer tax ID]: payer tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
17
+ # - name [string, default sub-issuer name]: payer name. ex: 'Iron Bank S.A.'
18
+ # - tags [list of strings, default []]: list of strings for tagging. ex: ['travel', 'food']
19
+ #
20
+ # ## Attributes (return-only):
21
+ # - id [string]: unique id returned when IssuingInvoice is created. ex: '5656565656565656'
22
+ # - status [string]: current IssuingInvoice status. ex: 'created', 'expired', 'overdue', 'paid'
23
+ # - issuing_transaction_id [string]: ledger transaction ids linked to this IssuingInvoice. ex: 'issuing-invoice/5656565656565656'
24
+ # - updated [DateTime]: latest update datetime for the IssuingInvoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
+ # - created [DateTime]: creation datetime for the IssuingInvoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
26
+ class IssuingInvoice < StarkInfra::Utils::Resource
27
+ attr_reader :amount, :id, :name, :tax_id, :status, :issuing_transaction_id, :tags, :updated, :created
28
+ def initialize(
29
+ amount:, id: nil, name: nil, tax_id: nil, status: nil, issuing_transaction_id: nil, tags: nil, updated: nil, created: nil
30
+ )
31
+ super(id)
32
+ @amount = amount
33
+ @name = name
34
+ @tax_id = tax_id
35
+ @status = status
36
+ @issuing_transaction_id = issuing_transaction_id
37
+ @tags = tags
38
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
39
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
40
+ end
41
+
42
+ # # Create an IssuingInvoice
43
+ #
44
+ # Send a single IssuingInvoice object for creation in the Stark Infra API
45
+ #
46
+ # ## Parameters (required):
47
+ # - invoice [IssuingInvoice object]: IssuingInvoice object to be created in the API.
48
+ #
49
+ # ## Parameters (optional):
50
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
51
+ #
52
+ # ## Return:
53
+ # - IssuingInvoice object with updated attributes
54
+ def self.create(invoice, user: nil)
55
+ StarkInfra::Utils::Rest.post_single(entity: invoice, user: user, **resource)
56
+ end
57
+
58
+ # # Retrieve a specific IssuingInvoice
59
+ #
60
+ # Receive a single IssuingInvoice object previously created in the Stark Infra API by its id
61
+ #
62
+ # ## Parameters (required):
63
+ # - id [string]: object unique id. ex: '5656565656565656'
64
+ #
65
+ # ## Parameters (optional):
66
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
67
+ #
68
+ # ## Return:
69
+ # - IssuingInvoice object with updated attributes
70
+ def self.get(id, user: nil)
71
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
72
+ end
73
+
74
+ # # Retrieve IssuingInvoices
75
+ #
76
+ # Receive a generator of IssuingInvoices objects previously created in the Stark Infra API
77
+ #
78
+ # ## Parameters (optional):
79
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
80
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
81
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
82
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'expired', 'overdue', 'paid']
83
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
84
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
85
+ #
86
+ # ## Return:
87
+ # - generator of IssuingInvoices objects with updated attributes
88
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil)
89
+ after = StarkInfra::Utils::Checks.check_date(after)
90
+ before = StarkInfra::Utils::Checks.check_date(before)
91
+ StarkInfra::Utils::Rest.get_stream(
92
+ limit: limit,
93
+ after: after,
94
+ before: before,
95
+ status: status,
96
+ tags: tags,
97
+ user: user,
98
+ **resource
99
+ )
100
+ end
101
+
102
+ # # Retrieve paged IssuingInvoices
103
+ #
104
+ # Receive a list of IssuingInvoices objects previously created in the Stark Infra API and the cursor to the next page.
105
+ #
106
+ # ## Parameters (optional):
107
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
108
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
109
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
110
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
111
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'expired', 'overdue', 'paid']
112
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
113
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
114
+ #
115
+ # ## Return:
116
+ # - list of IssuingInvoice objects with updated attributes
117
+ # - cursor to retrieve the next page of IssuingInvoice objects
118
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, user: nil)
119
+ after = StarkInfra::Utils::Checks.check_date(after)
120
+ before = StarkInfra::Utils::Checks.check_date(before)
121
+ StarkInfra::Utils::Rest.get_page(
122
+ cursor: cursor,
123
+ limit: limit,
124
+ after: after,
125
+ before: before,
126
+ status: status,
127
+ tags: tags,
128
+ user: user,
129
+ **resource
130
+ )
131
+ end
132
+
133
+ def self.resource
134
+ {
135
+ resource_name: 'IssuingInvoice',
136
+ resource_maker: proc { |json|
137
+ IssuingInvoice.new(
138
+ id: json['id'],
139
+ amount: json['amount'],
140
+ name: json['name'],
141
+ tax_id: json['tax_id'],
142
+ status: json['status'],
143
+ issuing_transaction_id: json['issuing_transaction_id'],
144
+ tags: json['tags'],
145
+ updated: json['updated'],
146
+ created: json['created']
147
+ )
148
+ }
149
+ }
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+ require_relative('issuinginvoice')
7
+
8
+ module StarkInfra
9
+ class IssuingInvoice
10
+ # # IssuingInvoice::Log object
11
+ #
12
+ # Every time an IssuingInvoice entity is updated, a corresponding IssuingInvoice::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
14
+ # IssuingInvoice.
15
+ #
16
+ # ## Attributes:
17
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
18
+ # - invoice [IssuingInvoice]: IssuingInvoice entity to which the log refers to.
19
+ # - type [string]: type of the IssuingInvoice event which triggered the log creation. ex: 'created', 'credited', 'expired', 'overdue', 'paid'.
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, :created, :type, :invoice
23
+ def initialize(id:, created:, type:, invoice:)
24
+ super(id)
25
+ @type = type
26
+ @invoice = invoice
27
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
28
+ end
29
+
30
+ # # Retrieve a specific Log
31
+ #
32
+ # Receive a single Log object previously created by the Stark Infra API by its id
33
+ #
34
+ # ## Parameters (required):
35
+ # - id [string]: object unique id. ex: '5656565656565656'
36
+ #
37
+ # ## Parameters (optional):
38
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
39
+ #
40
+ # ## Return:
41
+ # - Log object with updated attributes
42
+ def self.get(id, user: nil)
43
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
44
+ end
45
+
46
+ # # Retrieve Logs
47
+ #
48
+ # Receive a generator of Log objects previously created in the Stark Infra API
49
+ #
50
+ # ## Parameters (optional):
51
+ # - ids [list of strings, default nil]: list of IssuingInvoice ids to filter logs. ex: ['5656565656565656', '4545454545454545']
52
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Max = 100. 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', 'credited', 'expired', 'overdue', 'paid']
56
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
57
+ #
58
+ # ## Return:
59
+ # - generator of Log objects with updated attributes
60
+ def self.query(limit: nil, after: nil, before: nil, types: nil, user: nil)
61
+ after = StarkInfra::Utils::Checks.check_date(after)
62
+ before = StarkInfra::Utils::Checks.check_date(before)
63
+ StarkInfra::Utils::Rest.get_stream(
64
+ limit: limit,
65
+ after: after,
66
+ before: before,
67
+ types: types,
68
+ user: user,
69
+ **resource
70
+ )
71
+ end
72
+
73
+ # # Retrieve paged Logs
74
+ #
75
+ # Receive a list of up to 100 issuinginvoice.Log objects previously created in the Stark Infra API and the cursor
76
+ # to the next page. Use this function instead of query if you want to manually page your invoices.
77
+ #
78
+ # ## Parameters (optional):
79
+ # - cursor [string, default nil]: cursor returned on the previous page function call
80
+ # - ids [list of strings, default nil]: list of IssuingInvoice ids to filter logs. ex: ['5656565656565656', '4545454545454545']
81
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Max = 100. ex: 35
82
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
83
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
84
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'credited', 'expired', 'overdue', 'paid']
85
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
86
+ #
87
+ # ## Return:
88
+ # - list of Log objects with updated attributes
89
+ # - cursor to retrieve the next page of Log objects
90
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, user: nil)
91
+ after = StarkInfra::Utils::Checks.check_date(after)
92
+ before = StarkInfra::Utils::Checks.check_date(before)
93
+ StarkInfra::Utils::Rest.get_page(
94
+ cursor: cursor,
95
+ limit: limit,
96
+ after: after,
97
+ before: before,
98
+ types: types,
99
+ user: user,
100
+ **resource
101
+ )
102
+ end
103
+
104
+ def self.resource
105
+ request_maker = StarkInfra::IssuingInvoice.resource[:resource_maker]
106
+ {
107
+ resource_name: 'IssuingInvoiceLog',
108
+ resource_maker: proc { |json|
109
+ Log.new(
110
+ id: json['id'],
111
+ created: json['created'],
112
+ type: json['type'],
113
+ invoice: StarkInfra::Utils::API.from_api_json(request_maker, json['invoice'])
114
+ )
115
+ }
116
+ }
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,209 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+
7
+ module StarkInfra
8
+ # # IssuingPurchase object
9
+ #
10
+ # Displays the IssuingPurchase objects created in your Workspace.
11
+ #
12
+ # ## Attributes (return-only):
13
+ # - id [string]: unique id returned when IssuingPurchase is created. ex: '5656565656565656'
14
+ # - holder_name [string]: card holder name. ex: 'Tony Stark'
15
+ # - card_id [string]: unique id returned when IssuingCard is created. ex: '5656565656565656'
16
+ # - card_ending [string]: last 4 digits of the card number. ex: '1234'
17
+ # - amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34)
18
+ # - tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34)
19
+ # - issuer_amount [integer]: issuer amount. ex: 1234 (= R$ 12.34)
20
+ # - issuer_currency_code [string]: issuer currency code. ex: 'USD'
21
+ # - issuer_currency_symbol [string]: issuer currency symbol. ex: '$'
22
+ # - merchant_amount [integer]: merchant amount. ex: 1234 (= R$ 12.34)
23
+ # - merchant_currency_code [string]: merchant currency code. ex: 'USD'
24
+ # - merchant_currency_symbol [string]: merchant currency symbol. ex: '$'
25
+ # - merchant_category_code [string]: merchant category code. ex: 'fastFoodRestaurants'
26
+ # - merchant_country_code [string]: merchant country code. ex: 'USA'
27
+ # - acquirer_id [string]: acquirer ID. ex: '5656565656565656'
28
+ # - merchant_id [string]: merchant ID. ex: '5656565656565656'
29
+ # - merchant_name [string]: merchant name. ex: 'Google Cloud Platform'
30
+ # - merchant_fee [integer]: fee charged by the merchant to cover specific costs, such as ATM withdrawal logistics, etc. ex: 200 (= R$ 2.00)
31
+ # - wallet_id [string]: virtual wallet ID. ex: '5656565656565656'
32
+ # - method_code [string]: method code. ex: 'chip', 'token', 'server', 'manual', 'magstripe' or 'contactless'
33
+ # - score [float]: internal score calculated for the authenticity of the purchase. nil in case of insufficient data. ex: 7.6
34
+ # - issuing_transaction_ids [string]: ledger transaction ids linked to this Purchase
35
+ # - end_to_end_id [string]: Unique id used to identify the transaction through all of its life cycle, even before the purchase is denied or accepted and gets its usual id. Example: endToEndId='679cd385-642b-49d0-96b7-89491e1249a5'
36
+ # - status [string]: current IssuingCard status. ex: 'approved', 'canceled', 'denied', 'confirmed', 'voided'
37
+ # - tags [string]: list of strings for tagging returned by the sub-issuer during the authorization. ex: ['travel', 'food']
38
+ # - created [DateTime]: creation datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
39
+ # - updated [DateTime]: latest update datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
40
+ class IssuingPurchase < StarkInfra::Utils::Resource
41
+ attr_reader :id, :holder_name, :card_id, :card_ending, :amount, :tax, :issuer_amount, :issuer_currency_code,
42
+ :issuer_currency_symbol, :merchant_amount, :merchant_currency_code, :merchant_currency_symbol,
43
+ :merchant_category_code, :merchant_country_code, :acquirer_id, :merchant_id, :merchant_name,
44
+ :merchant_fee, :wallet_id, :method_code, :score, :issuing_transaction_ids, :end_to_end_id, :status,
45
+ :tags, :updated, :created
46
+
47
+ def initialize(
48
+ id: nil, holder_name: nil, card_id: nil, card_ending: nil, amount: nil, tax: nil, issuer_amount: nil,
49
+ issuer_currency_code: nil, issuer_currency_symbol: nil, merchant_amount: nil, merchant_currency_code: nil,
50
+ merchant_currency_symbol: nil, merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil,
51
+ merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil,
52
+ issuing_transaction_ids: nil, end_to_end_id: nil, status: nil, tags: nil, updated: nil, created: nil
53
+ )
54
+ super(id)
55
+ @holder_name = holder_name
56
+ @card_id = card_id
57
+ @card_ending = card_ending
58
+ @amount = amount
59
+ @tax = tax
60
+ @issuer_amount = issuer_amount
61
+ @issuer_currency_code = issuer_currency_code
62
+ @issuer_currency_symbol = issuer_currency_symbol
63
+ @merchant_amount = merchant_amount
64
+ @merchant_currency_code = merchant_currency_code
65
+ @merchant_currency_symbol = merchant_currency_symbol
66
+ @merchant_category_code = merchant_category_code
67
+ @merchant_country_code = merchant_country_code
68
+ @acquirer_id = acquirer_id
69
+ @merchant_id = merchant_id
70
+ @merchant_name = merchant_name
71
+ @merchant_fee = merchant_fee
72
+ @wallet_id = wallet_id
73
+ @method_code = method_code
74
+ @score = score
75
+ @issuing_transaction_ids = issuing_transaction_ids
76
+ @end_to_end_id = end_to_end_id
77
+ @status = status
78
+ @tags = tags
79
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
80
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
81
+ end
82
+
83
+ # # Retrieve a specific IssuingPurchase
84
+ #
85
+ # Receive a single IssuingPurchase object previously created in the Stark Infra API by its id
86
+ #
87
+ # ## Parameters (required):
88
+ # - id [string]: object unique id. ex: '5656565656565656'
89
+ #
90
+ # ## Parameters (optional):
91
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
92
+ #
93
+ # ## Return:
94
+ # - IssuingPurchase object with updated attributes
95
+ def self.get(id, user: nil)
96
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
97
+ end
98
+
99
+ # # Retrieve IssuingPurchase
100
+ #
101
+ # Receive a generator of IssuingPurchases objects previously created in the Stark Infra API
102
+ #
103
+ # ## Parameters (optional):
104
+ # - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
105
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
106
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 09)
107
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
108
+ # - end_to_end_ids [list of strings, default []]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
109
+ # - holder_ids [list of strings, default []]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
110
+ # - card_ids [list of strings, default []]: card IDs. ex: ['5656565656565656', '4545454545454545']
111
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['approved', 'canceled', 'denied', 'confirmed', 'voided']
112
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
113
+ #
114
+ # ## Return:
115
+ # - generator of IssuingPurchases objects with updated attributes
116
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, end_to_end_ids: nil, holder_ids: nil, card_ids: nil,
117
+ status: nil, user: nil)
118
+ after = StarkInfra::Utils::Checks.check_date(after)
119
+ before = StarkInfra::Utils::Checks.check_date(before)
120
+ StarkInfra::Utils::Rest.get_stream(
121
+ ids: ids,
122
+ limit: limit,
123
+ after: after,
124
+ before: before,
125
+ end_to_end_ids: end_to_end_ids,
126
+ holder_ids: holder_ids,
127
+ card_ids: card_ids,
128
+ status: status,
129
+ user: user,
130
+ **resource
131
+ )
132
+ end
133
+
134
+ # # Retrieve paged IssuingPurchases
135
+ #
136
+ # Receive a list of IssuingPurchase objects previously created in the Stark Infra API and the cursor to the next page.
137
+ #
138
+ # ## Parameters (optional):
139
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
140
+ # - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
141
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Max = 100. ex: 35
142
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
143
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
144
+ # - end_to_end_ids [list of strings, default []]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
145
+ # - holder_ids [list of strings, default []]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
146
+ # - card_ids [list of strings, default []]: card IDs. ex: ['5656565656565656', '4545454545454545']
147
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['approved', 'canceled', 'denied', 'confirmed', 'voided']
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
+ # - list of IssuingPurchases objects with updated attributes
152
+ # - cursor to retrieve the next page of IssuingPurchases objects
153
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, end_to_end_ids: nil, holder_ids: nil,
154
+ card_ids: nil, status: nil, user: nil)
155
+ after = StarkInfra::Utils::Checks.check_date(after)
156
+ before = StarkInfra::Utils::Checks.check_date(before)
157
+ StarkInfra::Utils::Rest.get_page(
158
+ cursor: cursor,
159
+ ids: ids,
160
+ limit: limit,
161
+ after: after,
162
+ before: before,
163
+ end_to_end_ids: end_to_end_ids,
164
+ holder_ids: holder_ids,
165
+ card_ids: card_ids,
166
+ status: status,
167
+ user: user,
168
+ **resource
169
+ )
170
+ end
171
+
172
+ def self.resource
173
+ {
174
+ resource_name: 'IssuingPurchase',
175
+ resource_maker: proc { |json|
176
+ IssuingPurchase.new(
177
+ id: json['id'],
178
+ holder_name: json['holder_name'],
179
+ card_id: json['card_id'],
180
+ card_ending: json['card_ending'],
181
+ amount: json['amount'],
182
+ tax: json['tax'],
183
+ issuer_amount: json['issuer_amount'],
184
+ issuer_currency_code: json['issuer_currency_code'],
185
+ issuer_currency_symbol: json['issuer_currency_symbol'],
186
+ merchant_amount: json['merchant_amount'],
187
+ merchant_currency_code: json['merchant_currency_code'],
188
+ merchant_currency_symbol: json['merchant_currency_symbol'],
189
+ merchant_category_code: json['merchant_category_code'],
190
+ merchant_country_code: json['merchant_country_code'],
191
+ acquirer_id: json['acquirer_id'],
192
+ merchant_id: json['merchant_id'],
193
+ merchant_name: json['merchant_name'],
194
+ merchant_fee: json['merchant_fee'],
195
+ wallet_id: json['wallet_id'],
196
+ method_code: json['method_code'],
197
+ score: json['score'],
198
+ issuing_transaction_ids: json['issuing_transaction_ids'],
199
+ end_to_end_id: json['end_to_end_id'],
200
+ status: json['status'],
201
+ tags: json['tags'],
202
+ updated: json['updated'],
203
+ created: json['created']
204
+ )
205
+ }
206
+ }
207
+ end
208
+ end
209
+ end