starkinfra 0.2.0 → 0.4.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +12 -8
  3. data/lib/cardmethod/cardmethod.rb +1 -1
  4. data/lib/creditholmes/creditholmes.rb +160 -0
  5. data/lib/creditnote/creditnote.rb +19 -18
  6. data/lib/creditnote/invoice/discount.rb +1 -1
  7. data/lib/creditnote/invoice/invoice.rb +4 -3
  8. data/lib/creditnote/log.rb +16 -17
  9. data/lib/creditpreview/creditpreview.rb +2 -8
  10. data/lib/dynamicbrcode/dynamicbrcode.rb +3 -3
  11. data/lib/event/attempt.rb +1 -1
  12. data/lib/event/event.rb +1 -1
  13. data/lib/individualdocument/individualdocument.rb +165 -0
  14. data/lib/individualdocument/log.rb +125 -0
  15. data/lib/individualidentity/individualidentity.rb +193 -0
  16. data/lib/individualidentity/log.rb +124 -0
  17. data/lib/issuingcard/issuingcard.rb +11 -12
  18. data/lib/issuingcard/log.rb +19 -19
  19. data/lib/issuingdesign/issuingdesign.rb +138 -0
  20. data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
  21. data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
  22. data/lib/issuingembossingrequest/log.rb +128 -0
  23. data/lib/issuingholder/issuingholder.rb +8 -7
  24. data/lib/issuingholder/log.rb +17 -17
  25. data/lib/issuinginvoice/issuinginvoice.rb +6 -5
  26. data/lib/issuinginvoice/log.rb +16 -16
  27. data/lib/issuingproduct/issuingproduct.rb +2 -2
  28. data/lib/issuingpurchase/issuingpurchase.rb +22 -15
  29. data/lib/issuingpurchase/log.rb +15 -15
  30. data/lib/issuingrestock/issuingrestock.rb +162 -0
  31. data/lib/issuingrestock/log.rb +127 -0
  32. data/lib/issuingstock/issuingstock.rb +138 -0
  33. data/lib/issuingstock/log.rb +130 -0
  34. data/lib/issuingtransaction/issuingtransaction.rb +7 -6
  35. data/lib/issuingwithdrawal/issuingwithdrawal.rb +8 -11
  36. data/lib/pixchargeback/log.rb +12 -12
  37. data/lib/pixclaim/log.rb +13 -13
  38. data/lib/pixclaim/pixclaim.rb +4 -4
  39. data/lib/pixdomain/pixdomain.rb +1 -1
  40. data/lib/pixinfraction/log.rb +18 -18
  41. data/lib/pixinfraction/pixinfraction.rb +3 -3
  42. data/lib/pixkey/log.rb +18 -18
  43. data/lib/pixkey/pixkey.rb +4 -3
  44. data/lib/pixrequest/log.rb +22 -18
  45. data/lib/pixrequest/pixrequest.rb +3 -0
  46. data/lib/pixreversal/log.rb +1 -1
  47. data/lib/pixstatement/pixstatement.rb +1 -1
  48. data/lib/starkinfra.rb +13 -0
  49. data/lib/staticbrcode/staticbrcode.rb +8 -2
  50. data/lib/utils/bacenid.rb +1 -1
  51. data/lib/utils/request.rb +1 -1
  52. data/lib/webhook/webhook.rb +9 -9
  53. metadata +15 -2
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
+
7
+ module StarkInfra
8
+ # # IssuingRestock object
9
+ #
10
+ # The IssuingRestock object displays the information of the restock orders created in your Workspace.
11
+ # This resource place a restock order for a specific IssuingStock object.
12
+ #
13
+ # ## Parameters (required):
14
+ # - count [integer]: number of restocks to be restocked. ex: 100
15
+ # - stock_id [string]: IssuingStock unique id ex: "5136459887542272"
16
+ #
17
+ # ## Parameters (optional):
18
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ["card", "corporate"]
19
+ #
20
+ # ## Attributes (return-only):
21
+ # - id [string]: unique id returned when IssuingRestock is created. ex: '5656565656565656'
22
+ # - status [string]: current IssuingRestock status. ex: "created", "processing", "confirmed"
23
+ # - updated [DateTime]: latest update datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
24
+ # - created [DateTime]: creation datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
+ class IssuingRestock < StarkInfra::Utils::Resource
26
+ attr_reader :count, :stock_id, :tags, :id, :status, :updated, :created
27
+ def initialize(
28
+ count:, stock_id:, tags: nil, id: nil, status: nil, updated: nil, created: nil
29
+ )
30
+ super(id)
31
+ @count = count
32
+ @stock_id = stock_id
33
+ @tags = tags
34
+ @status = status
35
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
36
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
37
+ end
38
+
39
+ # # Create IssuingRestocks
40
+ #
41
+ # Send a list of IssuingRestock objects for creation in the Stark Infra API
42
+ #
43
+ # ## Parameters (required):
44
+ # - restocks [list of IssuingRestock objects]: list of IssuingRestock objects to be created in the API
45
+ #
46
+ # ## Parameters (optional):
47
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
48
+ #
49
+ # ## Return:
50
+ # - list of IssuingRestock objects with updated attributes
51
+ def self.create(restocks:, user: nil)
52
+ StarkInfra::Utils::Rest.post(entities: restocks, user: user, **resource)
53
+ end
54
+
55
+ # # Retrieve a specific IssuingRestock
56
+ #
57
+ # Receive a single IssuingRestock object previously created in the Stark Infra API by its id
58
+ #
59
+ # ## Parameters (required):
60
+ # - id [string]: object unique id. ex: '5656565656565656'
61
+ #
62
+ # ## Parameters (optional):
63
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
64
+ #
65
+ # ## Return:
66
+ # - IssuingRestock object with updated attributes
67
+ def self.get(id, user: nil)
68
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
69
+ end
70
+
71
+ # # Retrieve IssuingRestocks
72
+ #
73
+ # Receive a generator of IssuingRestock objects previously created in the Stark Infra API
74
+ #
75
+ # ## Parameters (optional):
76
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
77
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
78
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
79
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "processing", "confirmed"]
80
+ # - stock_ids [list of string, default nil]: list of stock_ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
81
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
82
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["card", "corporate"]
83
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
84
+ #
85
+ # ## Return:
86
+ # - generator of IssuingRestocks objects with updated attributes
87
+ def self.query(
88
+ limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil,
89
+ tags: nil, user: nil
90
+ )
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
+ stock_ids: stock_ids,
99
+ ids: ids,
100
+ tags: tags,
101
+ user: user,
102
+ **resource
103
+ )
104
+ end
105
+
106
+ # # Retrieve paged IssuingRestocks
107
+ #
108
+ # Receive a list of up to 100 IssuingRestock objects previously created in the Stark Infra API and the cursor to the next page.
109
+ # Use this function instead of query if you want to manually page your requests.
110
+ #
111
+ # ## Parameters (optional):
112
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
113
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
114
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
115
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
116
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "processing", "confirmed"]
117
+ # - stock_ids [list of string, default nil]: list of stock_ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
118
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
119
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["card", "corporate"]
120
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
121
+ #
122
+ # ## Return:
123
+ # - list of IssuingRestocks objects with updated attributes
124
+ # - cursor to retrieve the next page of IssuingRestocks objects
125
+ def self.page(
126
+ cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil,
127
+ ids: nil, tags: nil, user: nil
128
+ )
129
+ after = StarkInfra::Utils::Checks.check_date(after)
130
+ before = StarkInfra::Utils::Checks.check_date(before)
131
+ StarkInfra::Utils::Rest.get_page(
132
+ cursor: cursor,
133
+ limit: limit,
134
+ after: after,
135
+ before: before,
136
+ status: status,
137
+ stock_ids: stock_ids,
138
+ ids: ids,
139
+ tags: tags,
140
+ user: user,
141
+ **resource
142
+ )
143
+ end
144
+
145
+ def self.resource
146
+ {
147
+ resource_name: 'IssuingRestock',
148
+ resource_maker: proc { |json|
149
+ IssuingRestock.new(
150
+ count: json['count'],
151
+ stock_id: json['stock_id'],
152
+ tags: json['tags'],
153
+ id: json['id'],
154
+ status: json['status'],
155
+ updated: json['updated'],
156
+ created: json['created']
157
+ )
158
+ }
159
+ }
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('IssuingRestock')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ class IssuingRestock
10
+ # # IssuingRestock::Log object
11
+ #
12
+ # Every time an IssuingRestock entity is updated, a corresponding IssuingRestock::Log is generated for the entity. This log
13
+ # is never generated by the user, but it can be retrieved to check additional information on the IssuingRestock.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - restock [IssuingRestock]: IssuingRestock entity to which the log refers to.
18
+ # - type [string]: type of the IssuingRestock event which triggered the log creation. ex: "created", "processing", "confirmed"
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, :restock, :type, :created
22
+ def initialize(id: nil, restock: nil, type: nil, created: nil)
23
+ super(id)
24
+ @restock = restock
25
+ @type = type
26
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
27
+ end
28
+
29
+ # # Retrieve a specific IssuingRestock::Log
30
+ #
31
+ # Receive a single IssuingRestock::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
+ # - IssuingRestock::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 IssuingRestock::Logs
46
+ #
47
+ # Receive a generator of IssuingRestock::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. Unlimited if nil. ex: 35
51
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
52
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
53
+ # - types [list of strings, default nil]: filter for log event types. ex: ["created", "processing", "confirmed"]
54
+ # - restock_ids [list of strings, default nil]: list of IssuingRestock ids to filter logs. ex: ['5656565656565656', '4545454545454545']
55
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. 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 IssuingRestock::Log objects with updated attributes
60
+ def self.query(
61
+ limit: nil, after: nil, before: nil, types: nil, restock_ids: nil, ids: nil, user: nil
62
+ )
63
+ after = StarkInfra::Utils::Checks.check_date(after)
64
+ before = StarkInfra::Utils::Checks.check_date(before)
65
+ StarkInfra::Utils::Rest.get_stream(
66
+ limit: limit,
67
+ after: after,
68
+ before: before,
69
+ types: types,
70
+ restock_ids: restock_ids,
71
+ ids: ids,
72
+ user: user,
73
+ **resource
74
+ )
75
+ end
76
+
77
+ # # Retrieve paged IssuingRestock::Logs
78
+ #
79
+ # Receive a list of up to 100 IssuingRestock::Log objects previously created in the Stark Infra API and the cursor to the next page.
80
+ # Use this function instead of query if you want to manually page your logs.
81
+ #
82
+ # ## Parameters (optional):
83
+ # - cursor [string, default nil]: cursor returned on the previous page function call
84
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
85
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - types [list of strings, default nil]: filter for log event types. ex: ["created", "processing", "confirmed"]
88
+ # - restock_ids [list of strings, default nil]: list of IssuingRestock ids to filter logs. ex: ['5656565656565656', '4545454545454545']
89
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
90
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
91
+ #
92
+ # ## Return:
93
+ # - list of IssuingRestock::Log objects with updated attributes
94
+ # - Cursor to retrieve the next page of Log objects
95
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, restock_ids: nil, ids: nil, user: nil)
96
+ after = StarkInfra::Utils::Checks.check_date(after)
97
+ before = StarkInfra::Utils::Checks.check_date(before)
98
+ StarkInfra::Utils::Rest.get_page(
99
+ cursor: cursor,
100
+ limit: limit,
101
+ after: after,
102
+ before: before,
103
+ types: types,
104
+ restock_ids: restock_ids,
105
+ ids: ids,
106
+ user: user,
107
+ **resource
108
+ )
109
+ end
110
+
111
+ def self.resource
112
+ request_maker = StarkInfra::IssuingRestock.resource[:resource_maker]
113
+ {
114
+ resource_name: 'IssuingRestockLog',
115
+ resource_maker: proc { |json|
116
+ Log.new(
117
+ id: json['id'],
118
+ restock: StarkInfra::Utils::API.from_api_json(request_maker, json['restock']),
119
+ type: json['type'],
120
+ created: json['created']
121
+ )
122
+ }
123
+ }
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,138 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
+
7
+ module StarkInfra
8
+ # # IssuingStock object
9
+ #
10
+ # The IssuingStock object represents the current stock of a certain IssuingDesign linked to an Embosser available to your workspace.
11
+ #
12
+ # ## Attributes (return-only):
13
+ # - id [string]: unique id returned when IssuingStock is created. ex: "5656565656565656"
14
+ # - balance [integer]: [EXPANDABLE] current stock balance. ex: 1000
15
+ # - design_id [string]: IssuingDesign unique id. ex: "5656565656565656"
16
+ # - embosser_id [string]: Embosser unique id. ex: "5656565656565656"
17
+ # - updated [DateTime]: latest update datetime for the IssuingStock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
18
+ # - created [DateTime]: creation datetime for the IssuingStock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
+ class IssuingStock < StarkInfra::Utils::Resource
20
+ attr_reader :id, :balance, :design_id, :embosser_id, :updated, :created
21
+ def initialize(
22
+ id: nil, balance: nil, design_id: nil, embosser_id: nil, updated: nil, created: nil
23
+ )
24
+ super(id)
25
+ @balance = balance
26
+ @design_id = design_id
27
+ @embosser_id = embosser_id
28
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
29
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
30
+ end
31
+
32
+ # # Retrieve a specific IssuingStock
33
+ #
34
+ # Receive a single IssuingStock object previously created in the Stark Infra API by its id
35
+ #
36
+ # ## Parameters (required):
37
+ # - id [string]: object unique id. ex: '5656565656565656'
38
+ #
39
+ # ## Parameters (optional):
40
+ # - expand [list of strings, default nil]: fields to expand information. ex: ['balance']
41
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
42
+ #
43
+ # ## Return:
44
+ # - IssuingStock object with updated attributes
45
+ def self.get(id, expand: nil, user: nil)
46
+ StarkInfra::Utils::Rest.get_id(id: id, expand: expand, user: user, **resource)
47
+ end
48
+
49
+ # # Retrieve IssuingStocks
50
+ #
51
+ # Receive a generator of IssuingStocks objects previously created in the Stark Infra API
52
+ #
53
+ # ## Parameters (optional):
54
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
55
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
57
+ # - design_ids [list of strings, default nil]: IssuingDesign unique ids. ex: ["5656565656565656", "4545454545454545"]
58
+ # - embosser_ids [list of strings, default nil]: Embosser unique ids. ex: ["5656565656565656", "4545454545454545"]
59
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
60
+ # - expand [list of strings, default []]: fields to expand information. ex: ["balance"]
61
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
62
+ #
63
+ # ## Return:
64
+ # - generator of IssuingStocks objects with updated attributes
65
+ def self.query(
66
+ limit: nil, after: nil, before: nil, design_ids: nil, embosser_ids: nil, ids: nil, expand: nil, user: nil
67
+ )
68
+ after = StarkInfra::Utils::Checks.check_date(after)
69
+ before = StarkInfra::Utils::Checks.check_date(before)
70
+ StarkInfra::Utils::Rest.get_stream(
71
+ limit: limit,
72
+ after: after,
73
+ before: before,
74
+ design_ids: design_ids,
75
+ embosser_ids: embosser_ids,
76
+ ids: ids,
77
+ expand: expand,
78
+ user: user,
79
+ **resource
80
+ )
81
+ end
82
+
83
+ # # Retrieve paged IssuingStocks
84
+ #
85
+ # Receive a list of up to 100 IssuingStock objects previously created in the Stark Infra API and the cursor to the next page.
86
+ # Use this function instead of query if you want to manually page your requests.
87
+ #
88
+ # ## Parameters (optional):
89
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
90
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
91
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
92
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
93
+ # - design_ids [list of strings, default nil]: IssuingDesign unique ids. ex: ["5656565656565656", "4545454545454545"]
94
+ # - embosser_ids [list of strings, default nil]: Embosser unique ids. ex: ["5656565656565656", "4545454545454545"]
95
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
96
+ # - expand [list of strings, default []]: fields to expand information. ex: ["balance"]
97
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
98
+ #
99
+ # ## Return:
100
+ # - list of IssuingStocks objects with updated attributes
101
+ # - cursor to retrieve the next page of IssuingStocks objects
102
+ def self.page(
103
+ cursor: nil, limit: nil, after: nil, before: nil, design_ids: nil, embosser_ids: nil,
104
+ ids: nil, expand: nil, user: nil
105
+ )
106
+ after = StarkInfra::Utils::Checks.check_date(after)
107
+ before = StarkInfra::Utils::Checks.check_date(before)
108
+ StarkInfra::Utils::Rest.get_page(
109
+ cursor: cursor,
110
+ limit: limit,
111
+ after: after,
112
+ before: before,
113
+ design_ids: design_ids,
114
+ embosser_ids: embosser_ids,
115
+ ids: ids,
116
+ expand: expand,
117
+ user: user,
118
+ **resource
119
+ )
120
+ end
121
+
122
+ def self.resource
123
+ {
124
+ resource_name: 'IssuingStock',
125
+ resource_maker: proc { |json|
126
+ IssuingStock.new(
127
+ id: json['id'],
128
+ balance: json['balance'],
129
+ design_id: json['design_id'],
130
+ embosser_id: json['embosser_id'],
131
+ updated: json['updated'],
132
+ created: json['created']
133
+ )
134
+ }
135
+ }
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('IssuingStock')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ class IssuingStock
10
+ # # IssuingStock::Log object
11
+ #
12
+ # Every time an IssuingStock entity is updated, a corresponding IssuingStock::Log is generated for the entity. This log
13
+ # is never generated by the user, but it can be retrieved to check additional information on the IssuingStock.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - stock [IssuingStock]: IssuingStock entity to which the log refers to.
18
+ # - type [string]: type of the IssuingStock event which triggered the log creation. ex: "created", "spent", "restocked", "lost"
19
+ # - count [integer]: shift in stock balance. ex: 10
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, :stock, :type, :count, :created
23
+ def initialize(id: nil, stock: nil, type: nil, count: nil, created: nil)
24
+ super(id)
25
+ @stock = stock
26
+ @type = type
27
+ @count = count
28
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
29
+ end
30
+
31
+ # # Retrieve a specific IssuingStock::Log
32
+ #
33
+ # Receive a single IssuingStock::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
+ # - IssuingStock::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 IssuingStock::Logs
48
+ #
49
+ # Receive a generator of IssuingStock::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", "spent", "restocked", "lost"]
56
+ # - stock_ids [list of strings, default nil]: list of IssuingStock ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
58
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
59
+ #
60
+ # ## Return:
61
+ # - generator of IssuingStock::Log objects with updated attributes
62
+ def self.query(limit: nil, after: nil, before: nil, types: nil, stock_ids: nil, ids: nil, user: nil)
63
+ after = StarkInfra::Utils::Checks.check_date(after)
64
+ before = StarkInfra::Utils::Checks.check_date(before)
65
+ StarkInfra::Utils::Rest.get_stream(
66
+ limit: limit,
67
+ after: after,
68
+ before: before,
69
+ types: types,
70
+ stock_ids: stock_ids,
71
+ ids: ids,
72
+ user: user,
73
+ **resource
74
+ )
75
+ end
76
+
77
+ # # Retrieve paged IssuingStock::Logs
78
+ #
79
+ # Receive a list of up to 100 IssuingStock::Log objects previously created in the Stark Infra API and the cursor to the next page.
80
+ # Use this function instead of query if you want to manually page your logs.
81
+ #
82
+ # ## Parameters (optional):
83
+ # - cursor [string, default nil]: cursor returned on the previous page function call
84
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
85
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - types [list of strings, default nil]: filter for log event types. ex: ["created", "spent", "restocked", "lost"]
88
+ # - stock_ids [list of strings, default nil]: list of IssuingStock ids to filter logs. ex: ['5656565656565656', '4545454545454545']
89
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
90
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
91
+ #
92
+ # ## Return:
93
+ # - list of IssuingStock::Log objects with updated attributes
94
+ # - Cursor to retrieve the next page of Log objects
95
+ def self.page(
96
+ cursor: nil, limit: nil, after: nil, before: nil, types: nil, stock_ids: nil, ids: nil, user: nil
97
+ )
98
+ after = StarkInfra::Utils::Checks.check_date(after)
99
+ before = StarkInfra::Utils::Checks.check_date(before)
100
+ StarkInfra::Utils::Rest.get_page(
101
+ cursor: cursor,
102
+ limit: limit,
103
+ after: after,
104
+ before: before,
105
+ types: types,
106
+ stock_ids: stock_ids,
107
+ ids: ids,
108
+ user: user,
109
+ **resource
110
+ )
111
+ end
112
+
113
+ def self.resource
114
+ request_maker = StarkInfra::IssuingStock.resource[:resource_maker]
115
+ {
116
+ resource_name: 'IssuingStockLog',
117
+ resource_maker: proc { |json|
118
+ Log.new(
119
+ id: json['id'],
120
+ stock: StarkInfra::Utils::API.from_api_json(request_maker, json['stock']),
121
+ type: json['type'],
122
+ count: json['count'],
123
+ created: json['created']
124
+ )
125
+ }
126
+ }
127
+ end
128
+ end
129
+ end
130
+ end
@@ -53,8 +53,8 @@ module StarkInfra
53
53
  # ## Parameters (optional):
54
54
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
55
55
  # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
56
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
57
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
56
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
57
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
58
58
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
59
59
  # - ids [list of strings, default nil]: purchase IDs
60
60
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
@@ -80,17 +80,18 @@ module StarkInfra
80
80
 
81
81
  # # Retrieve paged IssuingTransactions
82
82
  #
83
- # Receive a list of IssuingTransaction objects previously created in the Stark Infra API and the cursor to the next page.
83
+ # Receive a list of up to 100 IssuingTransaction objects previously created in the Stark Infra API and the cursor to the next page.
84
+ # Use this function instead of query if you want to manually page your requests.
84
85
  #
85
86
  # ## Parameters (optional):
86
87
  # - cursor [string, default nil]: cursor returned on the previous page function call.
88
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
89
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
90
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
91
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
88
92
  # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
89
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
90
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
91
93
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
92
94
  # - ids [list of strings, default nil]: purchase IDs
93
- # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
94
95
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
95
96
  #
96
97
  # ## Return:
@@ -9,10 +9,6 @@ module StarkInfra
9
9
  #
10
10
  # The IssuingWithdrawal objects created in your Workspace return cash from your Issuing balance to your Banking balance.
11
11
  #
12
- # When you initialize a IssuingWithdrawal, the entity will not be automatically
13
- # created in the Stark Infra API. The 'create' function sends the objects
14
- # to the Stark Infra API and returns the created object.
15
- #
16
12
  # ## Parameters (required):
17
13
  # - amount [integer]: IssuingWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
18
14
  # - external_id [string] IssuingWithdrawal external ID. ex: '12345'
@@ -82,10 +78,10 @@ module StarkInfra
82
78
  #
83
79
  # ## Parameters (optional):
84
80
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
85
- # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
86
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
87
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
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)
88
83
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
84
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
89
85
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
90
86
  #
91
87
  # ## Return:
@@ -106,15 +102,16 @@ module StarkInfra
106
102
 
107
103
  # # Retrieve paged IssuingWithdrawals
108
104
  #
109
- # Receive a list of IssuingWithdrawals objects previously created in the Stark Infra API and the cursor to the next page.
105
+ # Receive a list of up to 100 IssuingWithdrawal objects previously created in the Stark Infra API and the cursor to the next page.
106
+ # Use this function instead of query if you want to manually page your requests.
110
107
  #
111
108
  # ## Parameters (optional):
112
109
  # - cursor [string, default nil]: cursor returned on the previous page function call.
113
110
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
114
- # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
115
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
116
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
111
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
112
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
117
113
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
114
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
118
115
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
119
116
  #
120
117
  # ## Return: