weft-sdk 0.6.2 → 0.9.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 (168) hide show
  1. checksums.yaml +4 -4
  2. data/docs/APIKeysApi.md +1 -2
  3. data/docs/AccountApi.md +6 -5
  4. data/docs/AccountDetails.md +10 -13
  5. data/docs/ApiKey.md +0 -1
  6. data/docs/ApiKeyCreated.md +0 -1
  7. data/docs/ApiKeyCreatedResponse.md +0 -1
  8. data/docs/ApiKeyListResponse.md +0 -1
  9. data/docs/AuthApi.md +6 -7
  10. data/docs/AuthResponse.md +0 -1
  11. data/docs/AuthResponseData.md +0 -1
  12. data/docs/BalanceApi.md +1 -2
  13. data/docs/BalanceResponse.md +3 -4
  14. data/docs/ConfirmRequest.md +0 -1
  15. data/docs/CreateApiKeyRequest.md +0 -1
  16. data/docs/DefaultApi.md +0 -1
  17. data/docs/EnrolledResource.md +43 -0
  18. data/docs/Error.md +0 -1
  19. data/docs/ErrorResponse.md +0 -1
  20. data/docs/Fetch403Response.md +48 -0
  21. data/docs/FetchApi.md +10 -7
  22. data/docs/FetchBalanceSnapshot.md +5 -2
  23. data/docs/FetchErrorResponse.md +0 -1
  24. data/docs/FetchRequest.md +0 -1
  25. data/docs/FetchRequestBody.md +0 -1
  26. data/docs/FetchResponse.md +6 -3
  27. data/docs/InsufficientScopeResponse.md +21 -0
  28. data/docs/MeApiKey.md +25 -0
  29. data/docs/MeApiKeyCreator.md +21 -0
  30. data/docs/MeResponse.md +1 -2
  31. data/docs/MeResponseData.md +78 -0
  32. data/docs/Merchant.md +0 -1
  33. data/docs/MessageResponse.md +0 -1
  34. data/docs/MessageResponseData.md +0 -1
  35. data/docs/Pagination.md +0 -1
  36. data/docs/PasswordResetRequest.md +0 -1
  37. data/docs/PasswordUpdateRequest.md +0 -1
  38. data/docs/Payment.md +0 -3
  39. data/docs/PaymentListResponse.md +0 -1
  40. data/docs/PaymentResponse.md +0 -1
  41. data/docs/PaymentsApi.md +0 -1
  42. data/docs/PrincipalWallet.md +19 -0
  43. data/docs/PromoBalance.md +0 -1
  44. data/docs/Purchase.md +43 -0
  45. data/docs/PurchaseArtifact.md +23 -0
  46. data/docs/PurchaseListResponse.md +19 -0
  47. data/docs/PurchaseResponse.md +17 -0
  48. data/docs/PurchasesApi.md +148 -0
  49. data/docs/ResendConfirmationRequest.md +0 -1
  50. data/docs/ResourceEnrollmentRequest.md +23 -0
  51. data/docs/ResourceEnrollmentResponse.md +17 -0
  52. data/docs/ResourceStats.md +29 -0
  53. data/docs/ResourcesApi.md +71 -0
  54. data/docs/SearchApi.md +2 -3
  55. data/docs/SearchCapabilityRef.md +19 -0
  56. data/docs/SearchEndpointCall.md +23 -0
  57. data/docs/SearchEndpointHit.md +41 -0
  58. data/docs/SearchEndpointPrice.md +25 -0
  59. data/docs/SearchErrorResponse.md +0 -1
  60. data/docs/SearchFilterSpec.md +23 -0
  61. data/docs/SearchPaymentOffer.md +31 -0
  62. data/docs/SearchPriceAtomicFilter.md +25 -0
  63. data/docs/SearchPriceUsdFilter.md +25 -0
  64. data/docs/SearchProtocolFilter.md +19 -0
  65. data/docs/SearchProviderRef.md +21 -0
  66. data/docs/SearchRequest.md +3 -4
  67. data/docs/SearchResourceTypeFilter.md +19 -0
  68. data/docs/SearchResponse.md +35 -8
  69. data/docs/SearchResponseWarningsInner.md +23 -0
  70. data/docs/SearchResult.md +8 -21
  71. data/docs/SignInRequest.md +0 -1
  72. data/docs/SignUpRequest.md +0 -1
  73. data/docs/SpendingPolicy.md +0 -1
  74. data/docs/User.md +0 -1
  75. data/docs/UserPrincipal.md +33 -0
  76. data/docs/Wallet.md +5 -2
  77. data/lib/weft/generated/api/account_api.rb +6 -4
  78. data/lib/weft/generated/api/api_keys_api.rb +4 -4
  79. data/lib/weft/generated/api/auth_api.rb +14 -14
  80. data/lib/weft/generated/api/balance_api.rb +4 -4
  81. data/lib/weft/generated/api/default_api.rb +2 -2
  82. data/lib/weft/generated/api/fetch_api.rb +22 -6
  83. data/lib/weft/generated/api/payments_api.rb +2 -2
  84. data/lib/weft/generated/api/purchases_api.rb +150 -0
  85. data/lib/weft/generated/api/resources_api.rb +90 -0
  86. data/lib/weft/generated/api/search_api.rb +6 -6
  87. data/lib/weft/generated/api_client.rb +2 -2
  88. data/lib/weft/generated/api_error.rb +2 -2
  89. data/lib/weft/generated/api_model_base.rb +2 -2
  90. data/lib/weft/generated/configuration.rb +2 -2
  91. data/lib/weft/generated/models/account_details.rb +94 -85
  92. data/lib/weft/generated/models/api_key.rb +2 -2
  93. data/lib/weft/generated/models/api_key_created.rb +2 -2
  94. data/lib/weft/generated/models/api_key_created_response.rb +2 -2
  95. data/lib/weft/generated/models/api_key_list_response.rb +2 -2
  96. data/lib/weft/generated/models/auth_response.rb +2 -2
  97. data/lib/weft/generated/models/auth_response_data.rb +2 -2
  98. data/lib/weft/generated/models/balance_response.rb +5 -5
  99. data/lib/weft/generated/models/confirm_request.rb +2 -2
  100. data/lib/weft/generated/models/create_api_key_request.rb +2 -2
  101. data/lib/weft/generated/models/enrolled_resource.rb +474 -0
  102. data/lib/weft/generated/models/error.rb +3 -3
  103. data/lib/weft/generated/models/error_response.rb +3 -3
  104. data/lib/weft/generated/models/fetch403_response.rb +104 -0
  105. data/lib/weft/generated/models/fetch_balance_snapshot.rb +59 -4
  106. data/lib/weft/generated/models/fetch_error_response.rb +5 -5
  107. data/lib/weft/generated/models/fetch_request.rb +5 -5
  108. data/lib/weft/generated/models/fetch_request_body.rb +2 -2
  109. data/lib/weft/generated/models/fetch_response.rb +85 -7
  110. data/lib/weft/generated/models/insufficient_scope_response.rb +242 -0
  111. data/lib/weft/generated/models/{search_skill.rb → me_api_key.rb} +50 -92
  112. data/lib/weft/generated/models/me_api_key_creator.rb +200 -0
  113. data/lib/weft/generated/models/me_response.rb +3 -3
  114. data/lib/weft/generated/models/me_response_data.rb +55 -0
  115. data/lib/weft/generated/models/merchant.rb +2 -2
  116. data/lib/weft/generated/models/message_response.rb +2 -2
  117. data/lib/weft/generated/models/message_response_data.rb +2 -2
  118. data/lib/weft/generated/models/pagination.rb +2 -2
  119. data/lib/weft/generated/models/password_reset_request.rb +2 -2
  120. data/lib/weft/generated/models/password_update_request.rb +2 -2
  121. data/lib/weft/generated/models/payment.rb +3 -12
  122. data/lib/weft/generated/models/payment_list_response.rb +2 -2
  123. data/lib/weft/generated/models/payment_response.rb +2 -2
  124. data/lib/weft/generated/models/principal_wallet.rb +190 -0
  125. data/lib/weft/generated/models/promo_balance.rb +3 -3
  126. data/lib/weft/generated/models/purchase.rb +427 -0
  127. data/lib/weft/generated/models/purchase_artifact.rb +237 -0
  128. data/lib/weft/generated/models/purchase_list_response.rb +192 -0
  129. data/lib/weft/generated/models/purchase_response.rb +164 -0
  130. data/lib/weft/generated/models/resend_confirmation_request.rb +2 -2
  131. data/lib/weft/generated/models/{search_agent_card.rb → resource_enrollment_request.rb} +59 -75
  132. data/lib/weft/generated/models/resource_enrollment_response.rb +164 -0
  133. data/lib/weft/generated/models/resource_stats.rb +323 -0
  134. data/lib/weft/generated/models/{search_skill_endpoint.rb → search_capability_ref.rb} +18 -19
  135. data/lib/weft/generated/models/search_endpoint_call.rb +179 -0
  136. data/lib/weft/generated/models/search_endpoint_hit.rb +296 -0
  137. data/lib/weft/generated/models/search_endpoint_price.rb +223 -0
  138. data/lib/weft/generated/models/search_error_response.rb +5 -5
  139. data/lib/weft/generated/models/search_filter_spec.rb +175 -0
  140. data/lib/weft/generated/models/{search_pricing.rb → search_payment_offer.rb} +64 -67
  141. data/lib/weft/generated/models/search_price_atomic_filter.rb +284 -0
  142. data/lib/weft/generated/models/search_price_usd_filter.rb +294 -0
  143. data/lib/weft/generated/models/search_protocol_filter.rb +200 -0
  144. data/lib/weft/generated/models/{search_endpoints.rb → search_provider_ref.rb} +26 -36
  145. data/lib/weft/generated/models/search_request.rb +36 -27
  146. data/lib/weft/generated/models/search_resource_type_filter.rb +200 -0
  147. data/lib/weft/generated/models/search_response.rb +366 -30
  148. data/lib/weft/generated/models/search_response_warnings_inner.rb +210 -0
  149. data/lib/weft/generated/models/search_result.rb +68 -220
  150. data/lib/weft/generated/models/sign_in_request.rb +2 -2
  151. data/lib/weft/generated/models/sign_up_request.rb +2 -2
  152. data/lib/weft/generated/models/spending_policy.rb +2 -2
  153. data/lib/weft/generated/models/user.rb +2 -2
  154. data/lib/weft/generated/models/user_principal.rb +370 -0
  155. data/lib/weft/generated/models/wallet.rb +58 -4
  156. data/lib/weft/generated/version.rb +3 -3
  157. data/lib/weft/generated.rb +10 -4
  158. data/lib/weft/sdk.rb +1 -1
  159. metadata +75 -17
  160. data/docs/SearchAgentCard.md +0 -34
  161. data/docs/SearchEndpoints.md +0 -24
  162. data/docs/SearchFilters.md +0 -26
  163. data/docs/SearchPricing.md +0 -24
  164. data/docs/SearchRanking.md +0 -26
  165. data/docs/SearchSkill.md +0 -36
  166. data/docs/SearchSkillEndpoint.md +0 -20
  167. data/lib/weft/generated/models/search_filters.rb +0 -277
  168. data/lib/weft/generated/models/search_ranking.rb +0 -277
@@ -0,0 +1,427 @@
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/purchases`) 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.9.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
+ class Purchase < ApiModelBase
18
+ attr_accessor :id
19
+
20
+ attr_accessor :status
21
+
22
+ # Exact decimal USD amount with up to six fractional digits.
23
+ attr_accessor :amount_usd
24
+
25
+ attr_accessor :recipient_address
26
+
27
+ attr_accessor :network
28
+
29
+ attr_accessor :protocol
30
+
31
+ attr_accessor :context
32
+
33
+ attr_accessor :tx_hash
34
+
35
+ attr_accessor :reject_reason
36
+
37
+ attr_accessor :failure_reason
38
+
39
+ attr_accessor :idempotency_key
40
+
41
+ attr_accessor :signed_at
42
+
43
+ attr_accessor :settled_at
44
+
45
+ attr_accessor :artifact
46
+
47
+ class EnumAttributeValidator
48
+ attr_reader :datatype
49
+ attr_reader :allowable_values
50
+
51
+ def initialize(datatype, allowable_values)
52
+ @allowable_values = allowable_values.map do |value|
53
+ case datatype.to_s
54
+ when /Integer/i
55
+ value.to_i
56
+ when /Float/i
57
+ value.to_f
58
+ else
59
+ value
60
+ end
61
+ end
62
+ end
63
+
64
+ def valid?(value)
65
+ !value || allowable_values.include?(value)
66
+ end
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'id' => :'id',
73
+ :'status' => :'status',
74
+ :'amount_usd' => :'amount_usd',
75
+ :'recipient_address' => :'recipient_address',
76
+ :'network' => :'network',
77
+ :'protocol' => :'protocol',
78
+ :'context' => :'context',
79
+ :'tx_hash' => :'tx_hash',
80
+ :'reject_reason' => :'reject_reason',
81
+ :'failure_reason' => :'failure_reason',
82
+ :'idempotency_key' => :'idempotency_key',
83
+ :'signed_at' => :'signed_at',
84
+ :'settled_at' => :'settled_at',
85
+ :'artifact' => :'artifact'
86
+ }
87
+ end
88
+
89
+ # Returns attribute mapping this model knows about
90
+ def self.acceptable_attribute_map
91
+ attribute_map
92
+ end
93
+
94
+ # Returns all the JSON keys this model knows about
95
+ def self.acceptable_attributes
96
+ acceptable_attribute_map.values
97
+ end
98
+
99
+ # Attribute type mapping.
100
+ def self.openapi_types
101
+ {
102
+ :'id' => :'Integer',
103
+ :'status' => :'String',
104
+ :'amount_usd' => :'String',
105
+ :'recipient_address' => :'String',
106
+ :'network' => :'String',
107
+ :'protocol' => :'String',
108
+ :'context' => :'String',
109
+ :'tx_hash' => :'String',
110
+ :'reject_reason' => :'String',
111
+ :'failure_reason' => :'String',
112
+ :'idempotency_key' => :'String',
113
+ :'signed_at' => :'Time',
114
+ :'settled_at' => :'Time',
115
+ :'artifact' => :'PurchaseArtifact'
116
+ }
117
+ end
118
+
119
+ # List of attributes with nullable: true
120
+ def self.openapi_nullable
121
+ Set.new([
122
+ :'protocol',
123
+ :'context',
124
+ :'tx_hash',
125
+ :'reject_reason',
126
+ :'failure_reason',
127
+ :'idempotency_key',
128
+ :'settled_at',
129
+ :'artifact'
130
+ ])
131
+ end
132
+
133
+ # Initializes the object
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ def initialize(attributes = {})
136
+ if (!attributes.is_a?(Hash))
137
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::Purchase` initialize method"
138
+ end
139
+
140
+ # check to see if the attribute exists and convert string to symbol for hash key
141
+ acceptable_attribute_map = self.class.acceptable_attribute_map
142
+ attributes = attributes.each_with_object({}) { |(k, v), h|
143
+ if (!acceptable_attribute_map.key?(k.to_sym))
144
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::Purchase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
145
+ end
146
+ h[k.to_sym] = v
147
+ }
148
+
149
+ if attributes.key?(:'id')
150
+ self.id = attributes[:'id']
151
+ else
152
+ self.id = nil
153
+ end
154
+
155
+ if attributes.key?(:'status')
156
+ self.status = attributes[:'status']
157
+ else
158
+ self.status = nil
159
+ end
160
+
161
+ if attributes.key?(:'amount_usd')
162
+ self.amount_usd = attributes[:'amount_usd']
163
+ else
164
+ self.amount_usd = nil
165
+ end
166
+
167
+ if attributes.key?(:'recipient_address')
168
+ self.recipient_address = attributes[:'recipient_address']
169
+ else
170
+ self.recipient_address = nil
171
+ end
172
+
173
+ if attributes.key?(:'network')
174
+ self.network = attributes[:'network']
175
+ else
176
+ self.network = nil
177
+ end
178
+
179
+ if attributes.key?(:'protocol')
180
+ self.protocol = attributes[:'protocol']
181
+ else
182
+ self.protocol = nil
183
+ end
184
+
185
+ if attributes.key?(:'context')
186
+ self.context = attributes[:'context']
187
+ else
188
+ self.context = nil
189
+ end
190
+
191
+ if attributes.key?(:'tx_hash')
192
+ self.tx_hash = attributes[:'tx_hash']
193
+ else
194
+ self.tx_hash = nil
195
+ end
196
+
197
+ if attributes.key?(:'reject_reason')
198
+ self.reject_reason = attributes[:'reject_reason']
199
+ else
200
+ self.reject_reason = nil
201
+ end
202
+
203
+ if attributes.key?(:'failure_reason')
204
+ self.failure_reason = attributes[:'failure_reason']
205
+ else
206
+ self.failure_reason = nil
207
+ end
208
+
209
+ if attributes.key?(:'idempotency_key')
210
+ self.idempotency_key = attributes[:'idempotency_key']
211
+ else
212
+ self.idempotency_key = nil
213
+ end
214
+
215
+ if attributes.key?(:'signed_at')
216
+ self.signed_at = attributes[:'signed_at']
217
+ else
218
+ self.signed_at = nil
219
+ end
220
+
221
+ if attributes.key?(:'settled_at')
222
+ self.settled_at = attributes[:'settled_at']
223
+ else
224
+ self.settled_at = nil
225
+ end
226
+
227
+ if attributes.key?(:'artifact')
228
+ self.artifact = attributes[:'artifact']
229
+ else
230
+ self.artifact = nil
231
+ end
232
+ end
233
+
234
+ # Show invalid properties with the reasons. Usually used together with valid?
235
+ # @return Array for valid properties with the reasons
236
+ def list_invalid_properties
237
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
238
+ invalid_properties = Array.new
239
+ if @id.nil?
240
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
241
+ end
242
+
243
+ if @status.nil?
244
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
245
+ end
246
+
247
+ if @amount_usd.nil?
248
+ invalid_properties.push('invalid value for "amount_usd", amount_usd cannot be nil.')
249
+ end
250
+
251
+ if @recipient_address.nil?
252
+ invalid_properties.push('invalid value for "recipient_address", recipient_address cannot be nil.')
253
+ end
254
+
255
+ if @network.nil?
256
+ invalid_properties.push('invalid value for "network", network cannot be nil.')
257
+ end
258
+
259
+ if @signed_at.nil?
260
+ invalid_properties.push('invalid value for "signed_at", signed_at cannot be nil.')
261
+ end
262
+
263
+ invalid_properties
264
+ end
265
+
266
+ # Check to see if the all the properties in the model are valid
267
+ # @return true if the model is valid
268
+ def valid?
269
+ warn '[DEPRECATED] the `valid?` method is obsolete'
270
+ return false if @id.nil?
271
+ return false if @status.nil?
272
+ status_validator = EnumAttributeValidator.new('String', ["signed", "settled", "locked", "rejected", "declined", "expired", "reverted"])
273
+ return false unless status_validator.valid?(@status)
274
+ return false if @amount_usd.nil?
275
+ return false if @recipient_address.nil?
276
+ return false if @network.nil?
277
+ protocol_validator = EnumAttributeValidator.new('String', ["mpp", "x402"])
278
+ return false unless protocol_validator.valid?(@protocol)
279
+ return false if @signed_at.nil?
280
+ true
281
+ end
282
+
283
+ # Custom attribute writer method with validation
284
+ # @param [Object] id Value to be assigned
285
+ def id=(id)
286
+ if id.nil?
287
+ fail ArgumentError, 'id cannot be nil'
288
+ end
289
+
290
+ @id = id
291
+ end
292
+
293
+ # Custom attribute writer method checking allowed values (enum).
294
+ # @param [Object] status Object to be assigned
295
+ def status=(status)
296
+ validator = EnumAttributeValidator.new('String', ["signed", "settled", "locked", "rejected", "declined", "expired", "reverted"])
297
+ unless validator.valid?(status)
298
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
299
+ end
300
+ @status = status
301
+ end
302
+
303
+ # Custom attribute writer method with validation
304
+ # @param [Object] amount_usd Value to be assigned
305
+ def amount_usd=(amount_usd)
306
+ if amount_usd.nil?
307
+ fail ArgumentError, 'amount_usd cannot be nil'
308
+ end
309
+
310
+ @amount_usd = amount_usd
311
+ end
312
+
313
+ # Custom attribute writer method with validation
314
+ # @param [Object] recipient_address Value to be assigned
315
+ def recipient_address=(recipient_address)
316
+ if recipient_address.nil?
317
+ fail ArgumentError, 'recipient_address cannot be nil'
318
+ end
319
+
320
+ @recipient_address = recipient_address
321
+ end
322
+
323
+ # Custom attribute writer method with validation
324
+ # @param [Object] network Value to be assigned
325
+ def network=(network)
326
+ if network.nil?
327
+ fail ArgumentError, 'network cannot be nil'
328
+ end
329
+
330
+ @network = network
331
+ end
332
+
333
+ # Custom attribute writer method checking allowed values (enum).
334
+ # @param [Object] protocol Object to be assigned
335
+ def protocol=(protocol)
336
+ validator = EnumAttributeValidator.new('String', ["mpp", "x402"])
337
+ unless validator.valid?(protocol)
338
+ fail ArgumentError, "invalid value for \"protocol\", must be one of #{validator.allowable_values}."
339
+ end
340
+ @protocol = protocol
341
+ end
342
+
343
+ # Custom attribute writer method with validation
344
+ # @param [Object] signed_at Value to be assigned
345
+ def signed_at=(signed_at)
346
+ if signed_at.nil?
347
+ fail ArgumentError, 'signed_at cannot be nil'
348
+ end
349
+
350
+ @signed_at = signed_at
351
+ end
352
+
353
+ # Checks equality by comparing each attribute.
354
+ # @param [Object] Object to be compared
355
+ def ==(o)
356
+ return true if self.equal?(o)
357
+ self.class == o.class &&
358
+ id == o.id &&
359
+ status == o.status &&
360
+ amount_usd == o.amount_usd &&
361
+ recipient_address == o.recipient_address &&
362
+ network == o.network &&
363
+ protocol == o.protocol &&
364
+ context == o.context &&
365
+ tx_hash == o.tx_hash &&
366
+ reject_reason == o.reject_reason &&
367
+ failure_reason == o.failure_reason &&
368
+ idempotency_key == o.idempotency_key &&
369
+ signed_at == o.signed_at &&
370
+ settled_at == o.settled_at &&
371
+ artifact == o.artifact
372
+ end
373
+
374
+ # @see the `==` method
375
+ # @param [Object] Object to be compared
376
+ def eql?(o)
377
+ self == o
378
+ end
379
+
380
+ # Calculates hash code according to all attributes.
381
+ # @return [Integer] Hash code
382
+ def hash
383
+ [id, status, amount_usd, recipient_address, network, protocol, context, tx_hash, reject_reason, failure_reason, idempotency_key, signed_at, settled_at, artifact].hash
384
+ end
385
+
386
+ # Builds the object from hash
387
+ # @param [Hash] attributes Model attributes in the form of hash
388
+ # @return [Object] Returns the model itself
389
+ def self.build_from_hash(attributes)
390
+ return nil unless attributes.is_a?(Hash)
391
+ attributes = attributes.transform_keys(&:to_sym)
392
+ transformed_hash = {}
393
+ openapi_types.each_pair do |key, type|
394
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
395
+ transformed_hash["#{key}"] = nil
396
+ elsif type =~ /\AArray<(.*)>/i
397
+ # check to ensure the input is an array given that the attribute
398
+ # is documented as an array but the input is not
399
+ if attributes[attribute_map[key]].is_a?(Array)
400
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
401
+ end
402
+ elsif !attributes[attribute_map[key]].nil?
403
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
404
+ end
405
+ end
406
+ new(transformed_hash)
407
+ end
408
+
409
+ # Returns the object in the form of hash
410
+ # @return [Hash] Returns the object in the form of hash
411
+ def to_hash
412
+ hash = {}
413
+ self.class.attribute_map.each_pair do |attr, param|
414
+ value = self.send(attr)
415
+ if value.nil?
416
+ is_nullable = self.class.openapi_nullable.include?(attr)
417
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
418
+ end
419
+
420
+ hash[param] = _to_hash(value)
421
+ end
422
+ hash
423
+ end
424
+
425
+ end
426
+
427
+ end
@@ -0,0 +1,237 @@
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/purchases`) 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.9.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
+ class PurchaseArtifact < ApiModelBase
18
+ attr_accessor :id
19
+
20
+ attr_accessor :merchant_url
21
+
22
+ attr_accessor :bytes
23
+
24
+ attr_accessor :mime
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'id' => :'id',
30
+ :'merchant_url' => :'merchant_url',
31
+ :'bytes' => :'bytes',
32
+ :'mime' => :'mime'
33
+ }
34
+ end
35
+
36
+ # Returns attribute mapping this model knows about
37
+ def self.acceptable_attribute_map
38
+ attribute_map
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ acceptable_attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'id' => :'Integer',
50
+ :'merchant_url' => :'String',
51
+ :'bytes' => :'Integer',
52
+ :'mime' => :'String'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ :'mime'
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::PurchaseArtifact` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ acceptable_attribute_map = self.class.acceptable_attribute_map
72
+ attributes = attributes.each_with_object({}) { |(k, v), h|
73
+ if (!acceptable_attribute_map.key?(k.to_sym))
74
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::PurchaseArtifact`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
75
+ end
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:'id')
80
+ self.id = attributes[:'id']
81
+ else
82
+ self.id = nil
83
+ end
84
+
85
+ if attributes.key?(:'merchant_url')
86
+ self.merchant_url = attributes[:'merchant_url']
87
+ else
88
+ self.merchant_url = nil
89
+ end
90
+
91
+ if attributes.key?(:'bytes')
92
+ self.bytes = attributes[:'bytes']
93
+ else
94
+ self.bytes = nil
95
+ end
96
+
97
+ if attributes.key?(:'mime')
98
+ self.mime = attributes[:'mime']
99
+ else
100
+ self.mime = nil
101
+ end
102
+ end
103
+
104
+ # Show invalid properties with the reasons. Usually used together with valid?
105
+ # @return Array for valid properties with the reasons
106
+ def list_invalid_properties
107
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
+ invalid_properties = Array.new
109
+ if @id.nil?
110
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
111
+ end
112
+
113
+ if @merchant_url.nil?
114
+ invalid_properties.push('invalid value for "merchant_url", merchant_url cannot be nil.')
115
+ end
116
+
117
+ if @bytes.nil?
118
+ invalid_properties.push('invalid value for "bytes", bytes cannot be nil.')
119
+ end
120
+
121
+ if @bytes < 0
122
+ invalid_properties.push('invalid value for "bytes", must be greater than or equal to 0.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ warn '[DEPRECATED] the `valid?` method is obsolete'
132
+ return false if @id.nil?
133
+ return false if @merchant_url.nil?
134
+ return false if @bytes.nil?
135
+ return false if @bytes < 0
136
+ true
137
+ end
138
+
139
+ # Custom attribute writer method with validation
140
+ # @param [Object] id Value to be assigned
141
+ def id=(id)
142
+ if id.nil?
143
+ fail ArgumentError, 'id cannot be nil'
144
+ end
145
+
146
+ @id = id
147
+ end
148
+
149
+ # Custom attribute writer method with validation
150
+ # @param [Object] merchant_url Value to be assigned
151
+ def merchant_url=(merchant_url)
152
+ if merchant_url.nil?
153
+ fail ArgumentError, 'merchant_url cannot be nil'
154
+ end
155
+
156
+ @merchant_url = merchant_url
157
+ end
158
+
159
+ # Custom attribute writer method with validation
160
+ # @param [Object] bytes Value to be assigned
161
+ def bytes=(bytes)
162
+ if bytes.nil?
163
+ fail ArgumentError, 'bytes cannot be nil'
164
+ end
165
+
166
+ if bytes < 0
167
+ fail ArgumentError, 'invalid value for "bytes", must be greater than or equal to 0.'
168
+ end
169
+
170
+ @bytes = bytes
171
+ end
172
+
173
+ # Checks equality by comparing each attribute.
174
+ # @param [Object] Object to be compared
175
+ def ==(o)
176
+ return true if self.equal?(o)
177
+ self.class == o.class &&
178
+ id == o.id &&
179
+ merchant_url == o.merchant_url &&
180
+ bytes == o.bytes &&
181
+ mime == o.mime
182
+ end
183
+
184
+ # @see the `==` method
185
+ # @param [Object] Object to be compared
186
+ def eql?(o)
187
+ self == o
188
+ end
189
+
190
+ # Calculates hash code according to all attributes.
191
+ # @return [Integer] Hash code
192
+ def hash
193
+ [id, merchant_url, bytes, mime].hash
194
+ end
195
+
196
+ # Builds the object from hash
197
+ # @param [Hash] attributes Model attributes in the form of hash
198
+ # @return [Object] Returns the model itself
199
+ def self.build_from_hash(attributes)
200
+ return nil unless attributes.is_a?(Hash)
201
+ attributes = attributes.transform_keys(&:to_sym)
202
+ transformed_hash = {}
203
+ openapi_types.each_pair do |key, type|
204
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
205
+ transformed_hash["#{key}"] = nil
206
+ elsif type =~ /\AArray<(.*)>/i
207
+ # check to ensure the input is an array given that the attribute
208
+ # is documented as an array but the input is not
209
+ if attributes[attribute_map[key]].is_a?(Array)
210
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
211
+ end
212
+ elsif !attributes[attribute_map[key]].nil?
213
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
214
+ end
215
+ end
216
+ new(transformed_hash)
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ end
236
+
237
+ end