weft-sdk 0.9.1 → 0.14.1

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 (134) hide show
  1. checksums.yaml +4 -4
  2. data/docs/APIKeysApi.md +4 -0
  3. data/docs/AccountApi.md +1 -1
  4. data/docs/AccountBootstrapApproval.md +21 -0
  5. data/docs/AccountBootstrapCreated.md +29 -0
  6. data/docs/AccountBootstrapCreatedApproval.md +23 -0
  7. data/docs/AccountBootstrapCreatedResponse.md +17 -0
  8. data/docs/AccountBootstrapRequest.md +27 -0
  9. data/docs/AccountBootstrapStatus.md +25 -0
  10. data/docs/AccountBootstrapStatusResponse.md +17 -0
  11. data/docs/AgentBootstrapApi.md +209 -0
  12. data/docs/BalanceApi.md +1 -1
  13. data/docs/CuratedMarketplaceContract.md +31 -0
  14. data/docs/FetchApi.md +1 -1
  15. data/docs/FetchBalanceSnapshot.md +1 -1
  16. data/docs/FetchRequest.md +7 -1
  17. data/docs/RateLimitResponse.md +19 -0
  18. data/docs/SearchAccessMethod.md +37 -0
  19. data/docs/SearchApi.md +68 -1
  20. data/docs/SearchCuratedCallability.md +19 -0
  21. data/docs/SearchCuratedExecution.md +17 -0
  22. data/docs/SearchCuratedOperation.md +21 -0
  23. data/docs/SearchCuratedService.md +19 -0
  24. data/docs/SearchCuratedSource.md +21 -0
  25. data/docs/SearchEndpointHit.md +18 -0
  26. data/docs/SearchExecutionModeFilter.md +19 -0
  27. data/docs/SearchFilterSpec.md +11 -1
  28. data/docs/SearchMethodFilter.md +19 -0
  29. data/docs/SearchResponse.md +1 -3
  30. data/docs/SearchStringSetFilter.md +19 -0
  31. data/docs/SearchWeftFetchCompatibility.md +21 -0
  32. data/docs/Wallet.md +7 -3
  33. data/lib/weft/generated/api/account_api.rb +4 -4
  34. data/lib/weft/generated/api/agent_bootstrap_api.rb +224 -0
  35. data/lib/weft/generated/api/api_keys_api.rb +6 -2
  36. data/lib/weft/generated/api/auth_api.rb +2 -2
  37. data/lib/weft/generated/api/balance_api.rb +4 -4
  38. data/lib/weft/generated/api/default_api.rb +2 -2
  39. data/lib/weft/generated/api/fetch_api.rb +4 -4
  40. data/lib/weft/generated/api/payments_api.rb +2 -2
  41. data/lib/weft/generated/api/purchases_api.rb +2 -2
  42. data/lib/weft/generated/api/resources_api.rb +2 -2
  43. data/lib/weft/generated/api/search_api.rb +83 -4
  44. data/lib/weft/generated/api_client.rb +2 -2
  45. data/lib/weft/generated/api_error.rb +2 -2
  46. data/lib/weft/generated/api_model_base.rb +2 -2
  47. data/lib/weft/generated/configuration.rb +10 -10
  48. data/lib/weft/generated/models/account_bootstrap_approval.rb +259 -0
  49. data/lib/weft/generated/models/account_bootstrap_created.rb +349 -0
  50. data/lib/weft/generated/models/account_bootstrap_created_approval.rb +297 -0
  51. data/lib/weft/generated/models/account_bootstrap_created_response.rb +164 -0
  52. data/lib/weft/generated/models/account_bootstrap_request.rb +317 -0
  53. data/lib/weft/generated/models/account_bootstrap_status.rb +282 -0
  54. data/lib/weft/generated/models/account_bootstrap_status_response.rb +164 -0
  55. data/lib/weft/generated/models/account_details.rb +2 -2
  56. data/lib/weft/generated/models/api_key.rb +2 -2
  57. data/lib/weft/generated/models/api_key_created.rb +2 -2
  58. data/lib/weft/generated/models/api_key_created_response.rb +2 -2
  59. data/lib/weft/generated/models/api_key_list_response.rb +2 -2
  60. data/lib/weft/generated/models/auth_response.rb +2 -2
  61. data/lib/weft/generated/models/auth_response_data.rb +2 -2
  62. data/lib/weft/generated/models/balance_response.rb +2 -2
  63. data/lib/weft/generated/models/confirm_request.rb +2 -2
  64. data/lib/weft/generated/models/create_api_key_request.rb +2 -2
  65. data/lib/weft/generated/models/curated_marketplace_contract.rb +384 -0
  66. data/lib/weft/generated/models/enrolled_resource.rb +2 -2
  67. data/lib/weft/generated/models/error.rb +2 -2
  68. data/lib/weft/generated/models/error_response.rb +2 -2
  69. data/lib/weft/generated/models/fetch403_response.rb +2 -2
  70. data/lib/weft/generated/models/fetch_balance_snapshot.rb +3 -3
  71. data/lib/weft/generated/models/fetch_error_response.rb +4 -4
  72. data/lib/weft/generated/models/fetch_request.rb +36 -6
  73. data/lib/weft/generated/models/fetch_request_body.rb +2 -2
  74. data/lib/weft/generated/models/fetch_response.rb +2 -2
  75. data/lib/weft/generated/models/insufficient_scope_response.rb +2 -2
  76. data/lib/weft/generated/models/me_api_key.rb +2 -2
  77. data/lib/weft/generated/models/me_api_key_creator.rb +2 -2
  78. data/lib/weft/generated/models/me_response.rb +2 -2
  79. data/lib/weft/generated/models/me_response_data.rb +2 -2
  80. data/lib/weft/generated/models/merchant.rb +2 -2
  81. data/lib/weft/generated/models/message_response.rb +2 -2
  82. data/lib/weft/generated/models/message_response_data.rb +2 -2
  83. data/lib/weft/generated/models/pagination.rb +2 -2
  84. data/lib/weft/generated/models/password_reset_request.rb +2 -2
  85. data/lib/weft/generated/models/password_update_request.rb +2 -2
  86. data/lib/weft/generated/models/payment.rb +2 -2
  87. data/lib/weft/generated/models/payment_list_response.rb +2 -2
  88. data/lib/weft/generated/models/payment_response.rb +2 -2
  89. data/lib/weft/generated/models/principal_wallet.rb +2 -2
  90. data/lib/weft/generated/models/promo_balance.rb +2 -2
  91. data/lib/weft/generated/models/purchase.rb +2 -2
  92. data/lib/weft/generated/models/purchase_artifact.rb +2 -2
  93. data/lib/weft/generated/models/purchase_list_response.rb +2 -2
  94. data/lib/weft/generated/models/purchase_response.rb +2 -2
  95. data/lib/weft/generated/models/rate_limit_response.rb +214 -0
  96. data/lib/weft/generated/models/resend_confirmation_request.rb +2 -2
  97. data/lib/weft/generated/models/resource_enrollment_request.rb +2 -2
  98. data/lib/weft/generated/models/resource_enrollment_response.rb +2 -2
  99. data/lib/weft/generated/models/resource_stats.rb +2 -2
  100. data/lib/weft/generated/models/search_access_method.rb +341 -0
  101. data/lib/weft/generated/models/search_capability_ref.rb +2 -2
  102. data/lib/weft/generated/models/search_curated_callability.rb +216 -0
  103. data/lib/weft/generated/models/search_curated_execution.rb +181 -0
  104. data/lib/weft/generated/models/search_curated_operation.rb +199 -0
  105. data/lib/weft/generated/models/search_curated_service.rb +190 -0
  106. data/lib/weft/generated/models/search_curated_source.rb +240 -0
  107. data/lib/weft/generated/models/search_endpoint_call.rb +2 -2
  108. data/lib/weft/generated/models/search_endpoint_hit.rb +86 -3
  109. data/lib/weft/generated/models/search_endpoint_price.rb +2 -2
  110. data/lib/weft/generated/models/search_error_response.rb +2 -2
  111. data/lib/weft/generated/models/search_execution_mode_filter.rb +197 -0
  112. data/lib/weft/generated/models/search_filter_spec.rb +55 -6
  113. data/lib/weft/generated/models/search_method_filter.rb +197 -0
  114. data/lib/weft/generated/models/search_payment_offer.rb +2 -2
  115. data/lib/weft/generated/models/search_price_atomic_filter.rb +2 -2
  116. data/lib/weft/generated/models/search_price_usd_filter.rb +2 -2
  117. data/lib/weft/generated/models/search_protocol_filter.rb +2 -2
  118. data/lib/weft/generated/models/search_provider_ref.rb +2 -2
  119. data/lib/weft/generated/models/search_request.rb +2 -2
  120. data/lib/weft/generated/models/search_resource_type_filter.rb +2 -2
  121. data/lib/weft/generated/models/search_response.rb +7 -17
  122. data/lib/weft/generated/models/search_response_warnings_inner.rb +2 -2
  123. data/lib/weft/generated/models/search_result.rb +2 -2
  124. data/lib/weft/generated/models/search_string_set_filter.rb +177 -0
  125. data/lib/weft/generated/models/search_weft_fetch_compatibility.rb +240 -0
  126. data/lib/weft/generated/models/sign_in_request.rb +2 -2
  127. data/lib/weft/generated/models/sign_up_request.rb +2 -2
  128. data/lib/weft/generated/models/spending_policy.rb +2 -2
  129. data/lib/weft/generated/models/user.rb +2 -2
  130. data/lib/weft/generated/models/user_principal.rb +2 -2
  131. data/lib/weft/generated/models/wallet.rb +84 -6
  132. data/lib/weft/generated/version.rb +3 -3
  133. data/lib/weft/sdk.rb +1 -1
  134. metadata +42 -2
@@ -0,0 +1,349 @@
1
+ =begin
2
+ #Weft API
3
+
4
+ #The Weft API powers the `weft` CLI, the hosted MCP server (`weft.network/mcp`), and third-party applications that discover and pay for resources on Weft. The buyer runtime covers six concerns: 1. Account creation and recovery (`/api/v1/auth/*`) 2. Credential identity (`/api/v1/me`) 3. Wallet visibility (`/api/v1/balance`) 4. Discovery (`/api/v1/search`) 5. Paid execution (`/api/v1/fetch`) 6. Purchase history (`/api/v1/purchases`) Buyer runtime calls require a dashboard-created `wk_*` account key, an OAuth access token with the relevant scope, or a claimed `wbt_*` bearer on its fixed allowlist. The organization-scoped API key and payment operations in this document are seller administration surfaces and require an `ax_live_*` resource key. These credential types are not interchangeable. Before claim, a `wbt_*` bearer is temporary and permits only search plus its own status/cancel operations for 30 minutes. Human approval binds it to the User and promotes the same secret to durable identity, search, balance, fetch, purchase-history, status, and revocation capabilities. It remains valid until revoked. Seller, organization, API-key administration, dashboard-session, transfer, withdrawal, and MCP surfaces always refuse it. Bootstrap lifecycle successes follow the API-standard `{ \"data\": ... }` envelope. All errors share the envelope defined by `ErrorResponse`, except the buyer-runtime endpoints (`/search`, `/fetch`) which use bespoke envelopes carrying additional context — see `SearchErrorResponse` and `FetchErrorResponse`.
5
+
6
+ The version of the OpenAPI document: 0.14.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.19.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Weft
17
+ class AccountBootstrapCreated < ApiModelBase
18
+ attr_accessor :id
19
+
20
+ attr_accessor :status
21
+
22
+ attr_accessor :capabilities
23
+
24
+ # Claim-window expiry. Null after the credential is promoted.
25
+ attr_accessor :expires_at
26
+
27
+ attr_accessor :approval
28
+
29
+ # Returned once. Store as a secret; it cannot be recovered.
30
+ attr_accessor :temporary_api_key
31
+
32
+ # Transitional response field for older CLI releases that use OAuth device exchange.
33
+ attr_accessor :device_code
34
+
35
+ class EnumAttributeValidator
36
+ attr_reader :datatype
37
+ attr_reader :allowable_values
38
+
39
+ def initialize(datatype, allowable_values)
40
+ @allowable_values = allowable_values.map do |value|
41
+ case datatype.to_s
42
+ when /Integer/i
43
+ value.to_i
44
+ when /Float/i
45
+ value.to_f
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
51
+
52
+ def valid?(value)
53
+ !value || allowable_values.include?(value)
54
+ end
55
+ end
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'id' => :'id',
61
+ :'status' => :'status',
62
+ :'capabilities' => :'capabilities',
63
+ :'expires_at' => :'expires_at',
64
+ :'approval' => :'approval',
65
+ :'temporary_api_key' => :'temporary_api_key',
66
+ :'device_code' => :'device_code'
67
+ }
68
+ end
69
+
70
+ # Returns attribute mapping this model knows about
71
+ def self.acceptable_attribute_map
72
+ attribute_map
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ acceptable_attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.openapi_types
82
+ {
83
+ :'id' => :'String',
84
+ :'status' => :'String',
85
+ :'capabilities' => :'Array<String>',
86
+ :'expires_at' => :'Time',
87
+ :'approval' => :'AccountBootstrapCreatedApproval',
88
+ :'temporary_api_key' => :'String',
89
+ :'device_code' => :'String'
90
+ }
91
+ end
92
+
93
+ # List of attributes with nullable: true
94
+ def self.openapi_nullable
95
+ Set.new([
96
+ :'expires_at',
97
+ ])
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ if (!attributes.is_a?(Hash))
104
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::AccountBootstrapCreated` initialize method"
105
+ end
106
+
107
+ # check to see if the attribute exists and convert string to symbol for hash key
108
+ acceptable_attribute_map = self.class.acceptable_attribute_map
109
+ attributes = attributes.each_with_object({}) { |(k, v), h|
110
+ if (!acceptable_attribute_map.key?(k.to_sym))
111
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::AccountBootstrapCreated`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
112
+ end
113
+ h[k.to_sym] = v
114
+ }
115
+
116
+ if attributes.key?(:'id')
117
+ self.id = attributes[:'id']
118
+ else
119
+ self.id = nil
120
+ end
121
+
122
+ if attributes.key?(:'status')
123
+ self.status = attributes[:'status']
124
+ else
125
+ self.status = nil
126
+ end
127
+
128
+ if attributes.key?(:'capabilities')
129
+ if (value = attributes[:'capabilities']).is_a?(Array)
130
+ self.capabilities = value
131
+ end
132
+ else
133
+ self.capabilities = nil
134
+ end
135
+
136
+ if attributes.key?(:'expires_at')
137
+ self.expires_at = attributes[:'expires_at']
138
+ else
139
+ self.expires_at = nil
140
+ end
141
+
142
+ if attributes.key?(:'approval')
143
+ self.approval = attributes[:'approval']
144
+ else
145
+ self.approval = nil
146
+ end
147
+
148
+ if attributes.key?(:'temporary_api_key')
149
+ self.temporary_api_key = attributes[:'temporary_api_key']
150
+ else
151
+ self.temporary_api_key = nil
152
+ end
153
+
154
+ if attributes.key?(:'device_code')
155
+ self.device_code = attributes[:'device_code']
156
+ end
157
+ end
158
+
159
+ # Show invalid properties with the reasons. Usually used together with valid?
160
+ # @return Array for valid properties with the reasons
161
+ def list_invalid_properties
162
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
163
+ invalid_properties = Array.new
164
+ if @id.nil?
165
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
166
+ end
167
+
168
+ pattern = Regexp.new(/^boot_[A-Za-z0-9_-]+$/)
169
+ if @id !~ pattern
170
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
171
+ end
172
+
173
+ if @status.nil?
174
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
175
+ end
176
+
177
+ if @capabilities.nil?
178
+ invalid_properties.push('invalid value for "capabilities", capabilities cannot be nil.')
179
+ end
180
+
181
+ if @approval.nil?
182
+ invalid_properties.push('invalid value for "approval", approval cannot be nil.')
183
+ end
184
+
185
+ if @temporary_api_key.nil?
186
+ invalid_properties.push('invalid value for "temporary_api_key", temporary_api_key cannot be nil.')
187
+ end
188
+
189
+ pattern = Regexp.new(/^wbt_[A-Za-z0-9_-]+$/)
190
+ if @temporary_api_key !~ pattern
191
+ invalid_properties.push("invalid value for \"temporary_api_key\", must conform to the pattern #{pattern}.")
192
+ end
193
+
194
+ if !@device_code.nil? && @device_code.to_s.length < 32
195
+ invalid_properties.push('invalid value for "device_code", the character length must be greater than or equal to 32.')
196
+ end
197
+
198
+ invalid_properties
199
+ end
200
+
201
+ # Check to see if the all the properties in the model are valid
202
+ # @return true if the model is valid
203
+ def valid?
204
+ warn '[DEPRECATED] the `valid?` method is obsolete'
205
+ return false if @id.nil?
206
+ return false if @id !~ Regexp.new(/^boot_[A-Za-z0-9_-]+$/)
207
+ return false if @status.nil?
208
+ status_validator = EnumAttributeValidator.new('String', ["pending", "claimed", "rejected", "expired", "consumed", "revoked"])
209
+ return false unless status_validator.valid?(@status)
210
+ return false if @capabilities.nil?
211
+ return false if @approval.nil?
212
+ return false if @temporary_api_key.nil?
213
+ return false if @temporary_api_key !~ Regexp.new(/^wbt_[A-Za-z0-9_-]+$/)
214
+ return false if !@device_code.nil? && @device_code.to_s.length < 32
215
+ true
216
+ end
217
+
218
+ # Custom attribute writer method with validation
219
+ # @param [Object] id Value to be assigned
220
+ def id=(id)
221
+ if id.nil?
222
+ fail ArgumentError, 'id cannot be nil'
223
+ end
224
+
225
+ pattern = Regexp.new(/^boot_[A-Za-z0-9_-]+$/)
226
+ if id !~ pattern
227
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
228
+ end
229
+
230
+ @id = id
231
+ end
232
+
233
+ # Custom attribute writer method checking allowed values (enum).
234
+ # @param [Object] status Object to be assigned
235
+ def status=(status)
236
+ validator = EnumAttributeValidator.new('String', ["pending", "claimed", "rejected", "expired", "consumed", "revoked"])
237
+ unless validator.valid?(status)
238
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
239
+ end
240
+ @status = status
241
+ end
242
+
243
+ # Custom attribute writer method with validation
244
+ # @param [Object] approval Value to be assigned
245
+ def approval=(approval)
246
+ if approval.nil?
247
+ fail ArgumentError, 'approval cannot be nil'
248
+ end
249
+
250
+ @approval = approval
251
+ end
252
+
253
+ # Custom attribute writer method with validation
254
+ # @param [Object] temporary_api_key Value to be assigned
255
+ def temporary_api_key=(temporary_api_key)
256
+ if temporary_api_key.nil?
257
+ fail ArgumentError, 'temporary_api_key cannot be nil'
258
+ end
259
+
260
+ pattern = Regexp.new(/^wbt_[A-Za-z0-9_-]+$/)
261
+ if temporary_api_key !~ pattern
262
+ fail ArgumentError, "invalid value for \"temporary_api_key\", must conform to the pattern #{pattern}."
263
+ end
264
+
265
+ @temporary_api_key = temporary_api_key
266
+ end
267
+
268
+ # Custom attribute writer method with validation
269
+ # @param [Object] device_code Value to be assigned
270
+ def device_code=(device_code)
271
+ if device_code.nil?
272
+ fail ArgumentError, 'device_code cannot be nil'
273
+ end
274
+
275
+ if device_code.to_s.length < 32
276
+ fail ArgumentError, 'invalid value for "device_code", the character length must be greater than or equal to 32.'
277
+ end
278
+
279
+ @device_code = device_code
280
+ end
281
+
282
+ # Checks equality by comparing each attribute.
283
+ # @param [Object] Object to be compared
284
+ def ==(o)
285
+ return true if self.equal?(o)
286
+ self.class == o.class &&
287
+ id == o.id &&
288
+ status == o.status &&
289
+ capabilities == o.capabilities &&
290
+ expires_at == o.expires_at &&
291
+ approval == o.approval &&
292
+ temporary_api_key == o.temporary_api_key &&
293
+ device_code == o.device_code
294
+ end
295
+
296
+ # @see the `==` method
297
+ # @param [Object] Object to be compared
298
+ def eql?(o)
299
+ self == o
300
+ end
301
+
302
+ # Calculates hash code according to all attributes.
303
+ # @return [Integer] Hash code
304
+ def hash
305
+ [id, status, capabilities, expires_at, approval, temporary_api_key, device_code].hash
306
+ end
307
+
308
+ # Builds the object from hash
309
+ # @param [Hash] attributes Model attributes in the form of hash
310
+ # @return [Object] Returns the model itself
311
+ def self.build_from_hash(attributes)
312
+ return nil unless attributes.is_a?(Hash)
313
+ attributes = attributes.transform_keys(&:to_sym)
314
+ transformed_hash = {}
315
+ openapi_types.each_pair do |key, type|
316
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
317
+ transformed_hash["#{key}"] = nil
318
+ elsif type =~ /\AArray<(.*)>/i
319
+ # check to ensure the input is an array given that the attribute
320
+ # is documented as an array but the input is not
321
+ if attributes[attribute_map[key]].is_a?(Array)
322
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
323
+ end
324
+ elsif !attributes[attribute_map[key]].nil?
325
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
326
+ end
327
+ end
328
+ new(transformed_hash)
329
+ end
330
+
331
+ # Returns the object in the form of hash
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_hash
334
+ hash = {}
335
+ self.class.attribute_map.each_pair do |attr, param|
336
+ value = self.send(attr)
337
+ if value.nil?
338
+ is_nullable = self.class.openapi_nullable.include?(attr)
339
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
340
+ end
341
+
342
+ hash[param] = _to_hash(value)
343
+ end
344
+ hash
345
+ end
346
+
347
+ end
348
+
349
+ end
@@ -0,0 +1,297 @@
1
+ =begin
2
+ #Weft API
3
+
4
+ #The Weft API powers the `weft` CLI, the hosted MCP server (`weft.network/mcp`), and third-party applications that discover and pay for resources on Weft. The buyer runtime covers six concerns: 1. Account creation and recovery (`/api/v1/auth/*`) 2. Credential identity (`/api/v1/me`) 3. Wallet visibility (`/api/v1/balance`) 4. Discovery (`/api/v1/search`) 5. Paid execution (`/api/v1/fetch`) 6. Purchase history (`/api/v1/purchases`) Buyer runtime calls require a dashboard-created `wk_*` account key, an OAuth access token with the relevant scope, or a claimed `wbt_*` bearer on its fixed allowlist. The organization-scoped API key and payment operations in this document are seller administration surfaces and require an `ax_live_*` resource key. These credential types are not interchangeable. Before claim, a `wbt_*` bearer is temporary and permits only search plus its own status/cancel operations for 30 minutes. Human approval binds it to the User and promotes the same secret to durable identity, search, balance, fetch, purchase-history, status, and revocation capabilities. It remains valid until revoked. Seller, organization, API-key administration, dashboard-session, transfer, withdrawal, and MCP surfaces always refuse it. Bootstrap lifecycle successes follow the API-standard `{ \"data\": ... }` envelope. All errors share the envelope defined by `ErrorResponse`, except the buyer-runtime endpoints (`/search`, `/fetch`) which use bespoke envelopes carrying additional context — see `SearchErrorResponse` and `FetchErrorResponse`.
5
+
6
+ The version of the OpenAPI document: 0.14.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.19.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Weft
17
+ class AccountBootstrapCreatedApproval < ApiModelBase
18
+ attr_accessor :method
19
+
20
+ attr_accessor :expires_in
21
+
22
+ # Minimum status polling interval in seconds.
23
+ attr_accessor :interval
24
+
25
+ # Show this code to the human; approval requires a matching normalized code.
26
+ attr_accessor :user_code
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'method' => :'method',
54
+ :'expires_in' => :'expires_in',
55
+ :'interval' => :'interval',
56
+ :'user_code' => :'user_code'
57
+ }
58
+ end
59
+
60
+ # Returns attribute mapping this model knows about
61
+ def self.acceptable_attribute_map
62
+ attribute_map
63
+ end
64
+
65
+ # Returns all the JSON keys this model knows about
66
+ def self.acceptable_attributes
67
+ acceptable_attribute_map.values
68
+ end
69
+
70
+ # Attribute type mapping.
71
+ def self.openapi_types
72
+ {
73
+ :'method' => :'String',
74
+ :'expires_in' => :'Integer',
75
+ :'interval' => :'Integer',
76
+ :'user_code' => :'String'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::AccountBootstrapCreatedApproval` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ acceptable_attribute_map = self.class.acceptable_attribute_map
95
+ attributes = attributes.each_with_object({}) { |(k, v), h|
96
+ if (!acceptable_attribute_map.key?(k.to_sym))
97
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::AccountBootstrapCreatedApproval`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
98
+ end
99
+ h[k.to_sym] = v
100
+ }
101
+
102
+ if attributes.key?(:'method')
103
+ self.method = attributes[:'method']
104
+ else
105
+ self.method = nil
106
+ end
107
+
108
+ if attributes.key?(:'expires_in')
109
+ self.expires_in = attributes[:'expires_in']
110
+ else
111
+ self.expires_in = nil
112
+ end
113
+
114
+ if attributes.key?(:'interval')
115
+ self.interval = attributes[:'interval']
116
+ else
117
+ self.interval = nil
118
+ end
119
+
120
+ if attributes.key?(:'user_code')
121
+ self.user_code = attributes[:'user_code']
122
+ else
123
+ self.user_code = nil
124
+ end
125
+ end
126
+
127
+ # Show invalid properties with the reasons. Usually used together with valid?
128
+ # @return Array for valid properties with the reasons
129
+ def list_invalid_properties
130
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
131
+ invalid_properties = Array.new
132
+ if @method.nil?
133
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
134
+ end
135
+
136
+ if @expires_in.nil?
137
+ invalid_properties.push('invalid value for "expires_in", expires_in cannot be nil.')
138
+ end
139
+
140
+ if @expires_in < 0
141
+ invalid_properties.push('invalid value for "expires_in", must be greater than or equal to 0.')
142
+ end
143
+
144
+ if @interval.nil?
145
+ invalid_properties.push('invalid value for "interval", interval cannot be nil.')
146
+ end
147
+
148
+ if @interval < 1
149
+ invalid_properties.push('invalid value for "interval", must be greater than or equal to 1.')
150
+ end
151
+
152
+ if @user_code.nil?
153
+ invalid_properties.push('invalid value for "user_code", user_code cannot be nil.')
154
+ end
155
+
156
+ pattern = Regexp.new(/^[A-Z0-9]{4}-[A-Z0-9]{4}$/)
157
+ if @user_code !~ pattern
158
+ invalid_properties.push("invalid value for \"user_code\", must conform to the pattern #{pattern}.")
159
+ end
160
+
161
+ invalid_properties
162
+ end
163
+
164
+ # Check to see if the all the properties in the model are valid
165
+ # @return true if the model is valid
166
+ def valid?
167
+ warn '[DEPRECATED] the `valid?` method is obsolete'
168
+ return false if @method.nil?
169
+ method_validator = EnumAttributeValidator.new('String', ["email_link"])
170
+ return false unless method_validator.valid?(@method)
171
+ return false if @expires_in.nil?
172
+ return false if @expires_in < 0
173
+ return false if @interval.nil?
174
+ return false if @interval < 1
175
+ return false if @user_code.nil?
176
+ return false if @user_code !~ Regexp.new(/^[A-Z0-9]{4}-[A-Z0-9]{4}$/)
177
+ true
178
+ end
179
+
180
+ # Custom attribute writer method checking allowed values (enum).
181
+ # @param [Object] method Object to be assigned
182
+ def method=(method)
183
+ validator = EnumAttributeValidator.new('String', ["email_link"])
184
+ unless validator.valid?(method)
185
+ fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}."
186
+ end
187
+ @method = method
188
+ end
189
+
190
+ # Custom attribute writer method with validation
191
+ # @param [Object] expires_in Value to be assigned
192
+ def expires_in=(expires_in)
193
+ if expires_in.nil?
194
+ fail ArgumentError, 'expires_in cannot be nil'
195
+ end
196
+
197
+ if expires_in < 0
198
+ fail ArgumentError, 'invalid value for "expires_in", must be greater than or equal to 0.'
199
+ end
200
+
201
+ @expires_in = expires_in
202
+ end
203
+
204
+ # Custom attribute writer method with validation
205
+ # @param [Object] interval Value to be assigned
206
+ def interval=(interval)
207
+ if interval.nil?
208
+ fail ArgumentError, 'interval cannot be nil'
209
+ end
210
+
211
+ if interval < 1
212
+ fail ArgumentError, 'invalid value for "interval", must be greater than or equal to 1.'
213
+ end
214
+
215
+ @interval = interval
216
+ end
217
+
218
+ # Custom attribute writer method with validation
219
+ # @param [Object] user_code Value to be assigned
220
+ def user_code=(user_code)
221
+ if user_code.nil?
222
+ fail ArgumentError, 'user_code cannot be nil'
223
+ end
224
+
225
+ pattern = Regexp.new(/^[A-Z0-9]{4}-[A-Z0-9]{4}$/)
226
+ if user_code !~ pattern
227
+ fail ArgumentError, "invalid value for \"user_code\", must conform to the pattern #{pattern}."
228
+ end
229
+
230
+ @user_code = user_code
231
+ end
232
+
233
+ # Checks equality by comparing each attribute.
234
+ # @param [Object] Object to be compared
235
+ def ==(o)
236
+ return true if self.equal?(o)
237
+ self.class == o.class &&
238
+ method == o.method &&
239
+ expires_in == o.expires_in &&
240
+ interval == o.interval &&
241
+ user_code == o.user_code
242
+ end
243
+
244
+ # @see the `==` method
245
+ # @param [Object] Object to be compared
246
+ def eql?(o)
247
+ self == o
248
+ end
249
+
250
+ # Calculates hash code according to all attributes.
251
+ # @return [Integer] Hash code
252
+ def hash
253
+ [method, expires_in, interval, user_code].hash
254
+ end
255
+
256
+ # Builds the object from hash
257
+ # @param [Hash] attributes Model attributes in the form of hash
258
+ # @return [Object] Returns the model itself
259
+ def self.build_from_hash(attributes)
260
+ return nil unless attributes.is_a?(Hash)
261
+ attributes = attributes.transform_keys(&:to_sym)
262
+ transformed_hash = {}
263
+ openapi_types.each_pair do |key, type|
264
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
265
+ transformed_hash["#{key}"] = nil
266
+ elsif type =~ /\AArray<(.*)>/i
267
+ # check to ensure the input is an array given that the attribute
268
+ # is documented as an array but the input is not
269
+ if attributes[attribute_map[key]].is_a?(Array)
270
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
271
+ end
272
+ elsif !attributes[attribute_map[key]].nil?
273
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
274
+ end
275
+ end
276
+ new(transformed_hash)
277
+ end
278
+
279
+ # Returns the object in the form of hash
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_hash
282
+ hash = {}
283
+ self.class.attribute_map.each_pair do |attr, param|
284
+ value = self.send(attr)
285
+ if value.nil?
286
+ is_nullable = self.class.openapi_nullable.include?(attr)
287
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
288
+ end
289
+
290
+ hash[param] = _to_hash(value)
291
+ end
292
+ hash
293
+ end
294
+
295
+ end
296
+
297
+ end