weft-sdk 0.6.2 → 0.7.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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/docs/AccountDetails.md +8 -12
  3. data/docs/EnrolledResource.md +44 -0
  4. data/docs/Fetch403Response.md +49 -0
  5. data/docs/FetchBalanceSnapshot.md +5 -1
  6. data/docs/FetchResponse.md +1 -1
  7. data/docs/InsufficientScopeResponse.md +22 -0
  8. data/docs/MeApiKey.md +26 -0
  9. data/docs/MeApiKeyCreator.md +22 -0
  10. data/docs/ResourceEnrollmentRequest.md +24 -0
  11. data/docs/ResourceEnrollmentResponse.md +18 -0
  12. data/docs/ResourceStats.md +30 -0
  13. data/docs/ResourcesApi.md +72 -0
  14. data/docs/SearchFilters.md +1 -1
  15. data/docs/SearchResponse.md +1 -1
  16. data/docs/SearchResponseResultsInner.md +36 -0
  17. data/docs/Wallet.md +5 -1
  18. data/lib/weft/generated/api/account_api.rb +1 -1
  19. data/lib/weft/generated/api/api_keys_api.rb +1 -1
  20. data/lib/weft/generated/api/auth_api.rb +1 -1
  21. data/lib/weft/generated/api/balance_api.rb +1 -1
  22. data/lib/weft/generated/api/default_api.rb +1 -1
  23. data/lib/weft/generated/api/fetch_api.rb +1 -1
  24. data/lib/weft/generated/api/payments_api.rb +1 -1
  25. data/lib/weft/generated/api/resources_api.rb +90 -0
  26. data/lib/weft/generated/api/search_api.rb +1 -1
  27. data/lib/weft/generated/api_client.rb +1 -1
  28. data/lib/weft/generated/api_error.rb +1 -1
  29. data/lib/weft/generated/api_model_base.rb +1 -1
  30. data/lib/weft/generated/configuration.rb +1 -1
  31. data/lib/weft/generated/models/account_details.rb +65 -106
  32. data/lib/weft/generated/models/api_key.rb +1 -1
  33. data/lib/weft/generated/models/api_key_created.rb +1 -1
  34. data/lib/weft/generated/models/api_key_created_response.rb +1 -1
  35. data/lib/weft/generated/models/api_key_list_response.rb +1 -1
  36. data/lib/weft/generated/models/auth_response.rb +1 -1
  37. data/lib/weft/generated/models/auth_response_data.rb +1 -1
  38. data/lib/weft/generated/models/balance_response.rb +1 -1
  39. data/lib/weft/generated/models/confirm_request.rb +1 -1
  40. data/lib/weft/generated/models/create_api_key_request.rb +1 -1
  41. data/lib/weft/generated/models/enrolled_resource.rb +474 -0
  42. data/lib/weft/generated/models/error.rb +1 -1
  43. data/lib/weft/generated/models/error_response.rb +1 -1
  44. data/lib/weft/generated/models/fetch403_response.rb +104 -0
  45. data/lib/weft/generated/models/fetch_balance_snapshot.rb +58 -3
  46. data/lib/weft/generated/models/fetch_error_response.rb +4 -4
  47. data/lib/weft/generated/models/fetch_request.rb +1 -1
  48. data/lib/weft/generated/models/fetch_request_body.rb +1 -1
  49. data/lib/weft/generated/models/fetch_response.rb +3 -3
  50. data/lib/weft/generated/models/insufficient_scope_response.rb +242 -0
  51. data/lib/weft/generated/models/me_api_key.rb +217 -0
  52. data/lib/weft/generated/models/me_api_key_creator.rb +200 -0
  53. data/lib/weft/generated/models/me_response.rb +1 -1
  54. data/lib/weft/generated/models/merchant.rb +1 -1
  55. data/lib/weft/generated/models/message_response.rb +1 -1
  56. data/lib/weft/generated/models/message_response_data.rb +1 -1
  57. data/lib/weft/generated/models/pagination.rb +1 -1
  58. data/lib/weft/generated/models/password_reset_request.rb +1 -1
  59. data/lib/weft/generated/models/password_update_request.rb +1 -1
  60. data/lib/weft/generated/models/payment.rb +1 -1
  61. data/lib/weft/generated/models/payment_list_response.rb +1 -1
  62. data/lib/weft/generated/models/payment_response.rb +1 -1
  63. data/lib/weft/generated/models/promo_balance.rb +1 -1
  64. data/lib/weft/generated/models/resend_confirmation_request.rb +1 -1
  65. data/lib/weft/generated/models/resource_enrollment_request.rb +212 -0
  66. data/lib/weft/generated/models/resource_enrollment_response.rb +164 -0
  67. data/lib/weft/generated/models/resource_stats.rb +323 -0
  68. data/lib/weft/generated/models/search_agent_card.rb +1 -1
  69. data/lib/weft/generated/models/search_endpoints.rb +1 -1
  70. data/lib/weft/generated/models/search_error_response.rb +1 -1
  71. data/lib/weft/generated/models/search_filters.rb +4 -4
  72. data/lib/weft/generated/models/search_pricing.rb +1 -1
  73. data/lib/weft/generated/models/search_ranking.rb +1 -1
  74. data/lib/weft/generated/models/search_request.rb +1 -1
  75. data/lib/weft/generated/models/search_response.rb +3 -3
  76. data/lib/weft/generated/models/search_response_results_inner.rb +103 -0
  77. data/lib/weft/generated/models/search_result.rb +3 -3
  78. data/lib/weft/generated/models/search_skill.rb +1 -1
  79. data/lib/weft/generated/models/search_skill_endpoint.rb +1 -1
  80. data/lib/weft/generated/models/sign_in_request.rb +1 -1
  81. data/lib/weft/generated/models/sign_up_request.rb +1 -1
  82. data/lib/weft/generated/models/spending_policy.rb +1 -1
  83. data/lib/weft/generated/models/user.rb +1 -1
  84. data/lib/weft/generated/models/wallet.rb +57 -3
  85. data/lib/weft/generated/version.rb +2 -2
  86. data/lib/weft/sdk.rb +1 -1
  87. metadata +22 -2
@@ -0,0 +1,474 @@
1
+ =begin
2
+ #Weft API
3
+
4
+ #The Weft API is the buyer-runtime surface that powers the `weft` CLI, the hosted MCP server (`weft.network/mcp`), and any third-party agent that wants to discover and pay for paid resources on Weft. v1 covers five buyer concerns: 1. Account onboarding (`/api/v1/auth/*`, `/api/v1/me`) 2. CLI authentication (`/api/v1/api_keys`) 3. Wallet visibility (`/api/v1/balance`) 4. Discovery (`/api/v1/search`) 5. Paid execution (`/api/v1/fetch`) 6. Purchase history (`/api/v1/payments`) Seller-side concerns (agent management, payout analytics, webhook delivery, the public storefront for `data_api` resources) live in the dashboard and are intentionally not documented here. They will be split out into a separate, dashboard-scoped spec when they need to be SDK-consumable. 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.7.0
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
+ # The `:created` view of a ghost resource. Adds `stats`, the single-use `claim_token`, and the `claim_url` to the base resource shape. The claim fields appear ONLY on this enrollment response — never in list or read views.
18
+ class EnrolledResource < ApiModelBase
19
+ attr_accessor :id
20
+
21
+ attr_accessor :name
22
+
23
+ attr_accessor :slug
24
+
25
+ attr_accessor :description
26
+
27
+ attr_accessor :kind
28
+
29
+ attr_accessor :visibility
30
+
31
+ # Declared wallet address, or `null` if none was provided.
32
+ attr_accessor :wallet_address
33
+
34
+ # Legacy v3 taxonomy field. Returns a string only for `agent`-kind resources that carry a `category` in their metadata; `null` for all other kinds and for agents without one. Always `null` on enrollment (category is a post-claim concern).
35
+ attr_accessor :category
36
+
37
+ attr_accessor :verified
38
+
39
+ # True once the resource has an owning provider. Always false at enrollment.
40
+ attr_accessor :claimed
41
+
42
+ attr_accessor :created_at
43
+
44
+ attr_accessor :stats
45
+
46
+ # Single-use token for the magic claim URL. Surfaced only on enrollment.
47
+ attr_accessor :claim_token
48
+
49
+ # Dashboard path the agent hands to its human to claim the resource.
50
+ attr_accessor :claim_url
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'id' => :'id',
56
+ :'name' => :'name',
57
+ :'slug' => :'slug',
58
+ :'description' => :'description',
59
+ :'kind' => :'kind',
60
+ :'visibility' => :'visibility',
61
+ :'wallet_address' => :'wallet_address',
62
+ :'category' => :'category',
63
+ :'verified' => :'verified',
64
+ :'claimed' => :'claimed',
65
+ :'created_at' => :'created_at',
66
+ :'stats' => :'stats',
67
+ :'claim_token' => :'claim_token',
68
+ :'claim_url' => :'claim_url'
69
+ }
70
+ end
71
+
72
+ # Returns attribute mapping this model knows about
73
+ def self.acceptable_attribute_map
74
+ attribute_map
75
+ end
76
+
77
+ # Returns all the JSON keys this model knows about
78
+ def self.acceptable_attributes
79
+ acceptable_attribute_map.values
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.openapi_types
84
+ {
85
+ :'id' => :'Integer',
86
+ :'name' => :'String',
87
+ :'slug' => :'String',
88
+ :'description' => :'String',
89
+ :'kind' => :'String',
90
+ :'visibility' => :'String',
91
+ :'wallet_address' => :'String',
92
+ :'category' => :'String',
93
+ :'verified' => :'Boolean',
94
+ :'claimed' => :'Boolean',
95
+ :'created_at' => :'Time',
96
+ :'stats' => :'ResourceStats',
97
+ :'claim_token' => :'String',
98
+ :'claim_url' => :'String'
99
+ }
100
+ end
101
+
102
+ # List of attributes with nullable: true
103
+ def self.openapi_nullable
104
+ Set.new([
105
+ ])
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::EnrolledResource` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ acceptable_attribute_map = self.class.acceptable_attribute_map
117
+ attributes = attributes.each_with_object({}) { |(k, v), h|
118
+ if (!acceptable_attribute_map.key?(k.to_sym))
119
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::EnrolledResource`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
120
+ end
121
+ h[k.to_sym] = v
122
+ }
123
+
124
+ if attributes.key?(:'id')
125
+ self.id = attributes[:'id']
126
+ else
127
+ self.id = nil
128
+ end
129
+
130
+ if attributes.key?(:'name')
131
+ self.name = attributes[:'name']
132
+ else
133
+ self.name = nil
134
+ end
135
+
136
+ if attributes.key?(:'slug')
137
+ self.slug = attributes[:'slug']
138
+ else
139
+ self.slug = nil
140
+ end
141
+
142
+ if attributes.key?(:'description')
143
+ self.description = attributes[:'description']
144
+ end
145
+
146
+ if attributes.key?(:'kind')
147
+ self.kind = attributes[:'kind']
148
+ else
149
+ self.kind = nil
150
+ end
151
+
152
+ if attributes.key?(:'visibility')
153
+ self.visibility = attributes[:'visibility']
154
+ else
155
+ self.visibility = nil
156
+ end
157
+
158
+ if attributes.key?(:'wallet_address')
159
+ self.wallet_address = attributes[:'wallet_address']
160
+ end
161
+
162
+ if attributes.key?(:'category')
163
+ self.category = attributes[:'category']
164
+ else
165
+ self.category = nil
166
+ end
167
+
168
+ if attributes.key?(:'verified')
169
+ self.verified = attributes[:'verified']
170
+ else
171
+ self.verified = nil
172
+ end
173
+
174
+ if attributes.key?(:'claimed')
175
+ self.claimed = attributes[:'claimed']
176
+ else
177
+ self.claimed = nil
178
+ end
179
+
180
+ if attributes.key?(:'created_at')
181
+ self.created_at = attributes[:'created_at']
182
+ else
183
+ self.created_at = nil
184
+ end
185
+
186
+ if attributes.key?(:'stats')
187
+ self.stats = attributes[:'stats']
188
+ else
189
+ self.stats = nil
190
+ end
191
+
192
+ if attributes.key?(:'claim_token')
193
+ self.claim_token = attributes[:'claim_token']
194
+ else
195
+ self.claim_token = nil
196
+ end
197
+
198
+ if attributes.key?(:'claim_url')
199
+ self.claim_url = attributes[:'claim_url']
200
+ else
201
+ self.claim_url = nil
202
+ end
203
+ end
204
+
205
+ # Show invalid properties with the reasons. Usually used together with valid?
206
+ # @return Array for valid properties with the reasons
207
+ def list_invalid_properties
208
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
209
+ invalid_properties = Array.new
210
+ if @id.nil?
211
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
212
+ end
213
+
214
+ if @name.nil?
215
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
216
+ end
217
+
218
+ if @slug.nil?
219
+ invalid_properties.push('invalid value for "slug", slug cannot be nil.')
220
+ end
221
+
222
+ if @kind.nil?
223
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
224
+ end
225
+
226
+ if @visibility.nil?
227
+ invalid_properties.push('invalid value for "visibility", visibility cannot be nil.')
228
+ end
229
+
230
+ if @category.nil?
231
+ invalid_properties.push('invalid value for "category", category cannot be nil.')
232
+ end
233
+
234
+ if @verified.nil?
235
+ invalid_properties.push('invalid value for "verified", verified cannot be nil.')
236
+ end
237
+
238
+ if @claimed.nil?
239
+ invalid_properties.push('invalid value for "claimed", claimed cannot be nil.')
240
+ end
241
+
242
+ if @created_at.nil?
243
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
244
+ end
245
+
246
+ if @stats.nil?
247
+ invalid_properties.push('invalid value for "stats", stats cannot be nil.')
248
+ end
249
+
250
+ if @claim_token.nil?
251
+ invalid_properties.push('invalid value for "claim_token", claim_token cannot be nil.')
252
+ end
253
+
254
+ if @claim_url.nil?
255
+ invalid_properties.push('invalid value for "claim_url", claim_url cannot be nil.')
256
+ end
257
+
258
+ invalid_properties
259
+ end
260
+
261
+ # Check to see if the all the properties in the model are valid
262
+ # @return true if the model is valid
263
+ def valid?
264
+ warn '[DEPRECATED] the `valid?` method is obsolete'
265
+ return false if @id.nil?
266
+ return false if @name.nil?
267
+ return false if @slug.nil?
268
+ return false if @kind.nil?
269
+ return false if @visibility.nil?
270
+ return false if @category.nil?
271
+ return false if @verified.nil?
272
+ return false if @claimed.nil?
273
+ return false if @created_at.nil?
274
+ return false if @stats.nil?
275
+ return false if @claim_token.nil?
276
+ return false if @claim_url.nil?
277
+ true
278
+ end
279
+
280
+ # Custom attribute writer method with validation
281
+ # @param [Object] id Value to be assigned
282
+ def id=(id)
283
+ if id.nil?
284
+ fail ArgumentError, 'id cannot be nil'
285
+ end
286
+
287
+ @id = id
288
+ end
289
+
290
+ # Custom attribute writer method with validation
291
+ # @param [Object] name Value to be assigned
292
+ def name=(name)
293
+ if name.nil?
294
+ fail ArgumentError, 'name cannot be nil'
295
+ end
296
+
297
+ @name = name
298
+ end
299
+
300
+ # Custom attribute writer method with validation
301
+ # @param [Object] slug Value to be assigned
302
+ def slug=(slug)
303
+ if slug.nil?
304
+ fail ArgumentError, 'slug cannot be nil'
305
+ end
306
+
307
+ @slug = slug
308
+ end
309
+
310
+ # Custom attribute writer method with validation
311
+ # @param [Object] kind Value to be assigned
312
+ def kind=(kind)
313
+ if kind.nil?
314
+ fail ArgumentError, 'kind cannot be nil'
315
+ end
316
+
317
+ @kind = kind
318
+ end
319
+
320
+ # Custom attribute writer method with validation
321
+ # @param [Object] visibility Value to be assigned
322
+ def visibility=(visibility)
323
+ if visibility.nil?
324
+ fail ArgumentError, 'visibility cannot be nil'
325
+ end
326
+
327
+ @visibility = visibility
328
+ end
329
+
330
+ # Custom attribute writer method with validation
331
+ # @param [Object] category Value to be assigned
332
+ def category=(category)
333
+ if category.nil?
334
+ fail ArgumentError, 'category cannot be nil'
335
+ end
336
+
337
+ @category = category
338
+ end
339
+
340
+ # Custom attribute writer method with validation
341
+ # @param [Object] verified Value to be assigned
342
+ def verified=(verified)
343
+ if verified.nil?
344
+ fail ArgumentError, 'verified cannot be nil'
345
+ end
346
+
347
+ @verified = verified
348
+ end
349
+
350
+ # Custom attribute writer method with validation
351
+ # @param [Object] claimed Value to be assigned
352
+ def claimed=(claimed)
353
+ if claimed.nil?
354
+ fail ArgumentError, 'claimed cannot be nil'
355
+ end
356
+
357
+ @claimed = claimed
358
+ end
359
+
360
+ # Custom attribute writer method with validation
361
+ # @param [Object] created_at Value to be assigned
362
+ def created_at=(created_at)
363
+ if created_at.nil?
364
+ fail ArgumentError, 'created_at cannot be nil'
365
+ end
366
+
367
+ @created_at = created_at
368
+ end
369
+
370
+ # Custom attribute writer method with validation
371
+ # @param [Object] stats Value to be assigned
372
+ def stats=(stats)
373
+ if stats.nil?
374
+ fail ArgumentError, 'stats cannot be nil'
375
+ end
376
+
377
+ @stats = stats
378
+ end
379
+
380
+ # Custom attribute writer method with validation
381
+ # @param [Object] claim_token Value to be assigned
382
+ def claim_token=(claim_token)
383
+ if claim_token.nil?
384
+ fail ArgumentError, 'claim_token cannot be nil'
385
+ end
386
+
387
+ @claim_token = claim_token
388
+ end
389
+
390
+ # Custom attribute writer method with validation
391
+ # @param [Object] claim_url Value to be assigned
392
+ def claim_url=(claim_url)
393
+ if claim_url.nil?
394
+ fail ArgumentError, 'claim_url cannot be nil'
395
+ end
396
+
397
+ @claim_url = claim_url
398
+ end
399
+
400
+ # Checks equality by comparing each attribute.
401
+ # @param [Object] Object to be compared
402
+ def ==(o)
403
+ return true if self.equal?(o)
404
+ self.class == o.class &&
405
+ id == o.id &&
406
+ name == o.name &&
407
+ slug == o.slug &&
408
+ description == o.description &&
409
+ kind == o.kind &&
410
+ visibility == o.visibility &&
411
+ wallet_address == o.wallet_address &&
412
+ category == o.category &&
413
+ verified == o.verified &&
414
+ claimed == o.claimed &&
415
+ created_at == o.created_at &&
416
+ stats == o.stats &&
417
+ claim_token == o.claim_token &&
418
+ claim_url == o.claim_url
419
+ end
420
+
421
+ # @see the `==` method
422
+ # @param [Object] Object to be compared
423
+ def eql?(o)
424
+ self == o
425
+ end
426
+
427
+ # Calculates hash code according to all attributes.
428
+ # @return [Integer] Hash code
429
+ def hash
430
+ [id, name, slug, description, kind, visibility, wallet_address, category, verified, claimed, created_at, stats, claim_token, claim_url].hash
431
+ end
432
+
433
+ # Builds the object from hash
434
+ # @param [Hash] attributes Model attributes in the form of hash
435
+ # @return [Object] Returns the model itself
436
+ def self.build_from_hash(attributes)
437
+ return nil unless attributes.is_a?(Hash)
438
+ attributes = attributes.transform_keys(&:to_sym)
439
+ transformed_hash = {}
440
+ openapi_types.each_pair do |key, type|
441
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
442
+ transformed_hash["#{key}"] = nil
443
+ elsif type =~ /\AArray<(.*)>/i
444
+ # check to ensure the input is an array given that the attribute
445
+ # is documented as an array but the input is not
446
+ if attributes[attribute_map[key]].is_a?(Array)
447
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
448
+ end
449
+ elsif !attributes[attribute_map[key]].nil?
450
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
451
+ end
452
+ end
453
+ new(transformed_hash)
454
+ end
455
+
456
+ # Returns the object in the form of hash
457
+ # @return [Hash] Returns the object in the form of hash
458
+ def to_hash
459
+ hash = {}
460
+ self.class.attribute_map.each_pair do |attr, param|
461
+ value = self.send(attr)
462
+ if value.nil?
463
+ is_nullable = self.class.openapi_nullable.include?(attr)
464
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
465
+ end
466
+
467
+ hash[param] = _to_hash(value)
468
+ end
469
+ hash
470
+ end
471
+
472
+ end
473
+
474
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  #The Weft API is the buyer-runtime surface that powers the `weft` CLI, the hosted MCP server (`weft.network/mcp`), and any third-party agent that wants to discover and pay for paid resources on Weft. v1 covers five buyer concerns: 1. Account onboarding (`/api/v1/auth/*`, `/api/v1/me`) 2. CLI authentication (`/api/v1/api_keys`) 3. Wallet visibility (`/api/v1/balance`) 4. Discovery (`/api/v1/search`) 5. Paid execution (`/api/v1/fetch`) 6. Purchase history (`/api/v1/payments`) Seller-side concerns (agent management, payout analytics, webhook delivery, the public storefront for `data_api` resources) live in the dashboard and are intentionally not documented here. They will be split out into a separate, dashboard-scoped spec when they need to be SDK-consumable. 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
5
 
6
- The version of the OpenAPI document: 0.6.2
6
+ The version of the OpenAPI document: 0.7.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.19.0
@@ -3,7 +3,7 @@
3
3
 
4
4
  #The Weft API is the buyer-runtime surface that powers the `weft` CLI, the hosted MCP server (`weft.network/mcp`), and any third-party agent that wants to discover and pay for paid resources on Weft. v1 covers five buyer concerns: 1. Account onboarding (`/api/v1/auth/*`, `/api/v1/me`) 2. CLI authentication (`/api/v1/api_keys`) 3. Wallet visibility (`/api/v1/balance`) 4. Discovery (`/api/v1/search`) 5. Paid execution (`/api/v1/fetch`) 6. Purchase history (`/api/v1/payments`) Seller-side concerns (agent management, payout analytics, webhook delivery, the public storefront for `data_api` resources) live in the dashboard and are intentionally not documented here. They will be split out into a separate, dashboard-scoped spec when they need to be SDK-consumable. 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
5
 
6
- The version of the OpenAPI document: 0.6.2
6
+ The version of the OpenAPI document: 0.7.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.19.0
@@ -0,0 +1,104 @@
1
+ =begin
2
+ #Weft API
3
+
4
+ #The Weft API is the buyer-runtime surface that powers the `weft` CLI, the hosted MCP server (`weft.network/mcp`), and any third-party agent that wants to discover and pay for paid resources on Weft. v1 covers five buyer concerns: 1. Account onboarding (`/api/v1/auth/*`, `/api/v1/me`) 2. CLI authentication (`/api/v1/api_keys`) 3. Wallet visibility (`/api/v1/balance`) 4. Discovery (`/api/v1/search`) 5. Paid execution (`/api/v1/fetch`) 6. Purchase history (`/api/v1/payments`) Seller-side concerns (agent management, payout analytics, webhook delivery, the public storefront for `data_api` resources) live in the dashboard and are intentionally not documented here. They will be split out into a separate, dashboard-scoped spec when they need to be SDK-consumable. 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.7.0
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
+ module Fetch403Response
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'FetchErrorResponse',
23
+ :'InsufficientScopeResponse'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ return find_and_cast_into_type(klass, data)
42
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
43
+ end
44
+ end
45
+
46
+ openapi_one_of.include?(:AnyType) ? data : nil
47
+ end
48
+
49
+ private
50
+
51
+ SchemaMismatchError = Class.new(StandardError)
52
+
53
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
54
+ def find_and_cast_into_type(klass, data)
55
+ return if data.nil?
56
+
57
+ case klass.to_s
58
+ when 'Boolean'
59
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
60
+ when 'Float'
61
+ return data if data.instance_of?(Float)
62
+ when 'Integer'
63
+ return data if data.instance_of?(Integer)
64
+ when 'Time'
65
+ return Time.parse(data)
66
+ when 'Date'
67
+ return Date.iso8601(data)
68
+ when 'String'
69
+ return data if data.instance_of?(String)
70
+ when 'Object' # "type: object"
71
+ return data if data.instance_of?(Hash)
72
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
73
+ if data.instance_of?(Array)
74
+ sub_type = Regexp.last_match[:sub_type]
75
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
76
+ end
77
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
78
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
+ sub_type = Regexp.last_match[:sub_type]
80
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
+ end
82
+ else # model
83
+ const = Weft.const_get(klass)
84
+ if const
85
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
86
+ model = const.build(data)
87
+ return model if model
88
+ else
89
+ # raise if data contains keys that are not known to the model
90
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
91
+ model = const.build_from_hash(data)
92
+ return model if model
93
+ end
94
+ end
95
+ end
96
+
97
+ raise # if no match by now, raise
98
+ rescue
99
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
100
+ end
101
+ end
102
+ end
103
+
104
+ end