weft-sdk 0.3.0 → 0.5.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.
- checksums.yaml +4 -4
- data/docs/ApiKeyListResponse.md +3 -1
- data/docs/BalanceApi.md +74 -0
- data/docs/BalanceResponse.md +26 -0
- data/docs/DefaultApi.md +12 -12
- data/docs/Error.md +7 -7
- data/docs/FetchApi.md +77 -0
- data/docs/FetchBalanceSnapshot.md +22 -0
- data/docs/FetchErrorResponse.md +26 -0
- data/docs/FetchRequest.md +26 -0
- data/docs/FetchRequestBody.md +49 -0
- data/docs/FetchResponse.md +30 -0
- data/docs/Merchant.md +24 -0
- data/docs/PromoBalance.md +22 -0
- data/docs/SearchAgentCard.md +34 -0
- data/docs/SearchApi.md +77 -0
- data/docs/SearchEndpoints.md +24 -0
- data/docs/SearchErrorResponse.md +20 -0
- data/docs/SearchFilters.md +26 -0
- data/docs/SearchPricing.md +24 -0
- data/docs/SearchRanking.md +26 -0
- data/docs/SearchRequest.md +22 -0
- data/docs/SearchResponse.md +26 -0
- data/docs/SearchResult.md +36 -0
- data/docs/SearchSkill.md +36 -0
- data/docs/SearchSkillEndpoint.md +20 -0
- data/docs/SpendingPolicy.md +22 -0
- data/docs/Wallet.md +22 -0
- data/lib/weft/generated/api/account_api.rb +2 -2
- data/lib/weft/generated/api/api_keys_api.rb +2 -2
- data/lib/weft/generated/api/auth_api.rb +2 -2
- data/lib/weft/generated/api/balance_api.rb +79 -0
- data/lib/weft/generated/api/default_api.rb +11 -11
- data/lib/weft/generated/api/fetch_api.rb +90 -0
- data/lib/weft/generated/api/payments_api.rb +2 -2
- data/lib/weft/generated/api/search_api.rb +90 -0
- data/lib/weft/generated/api_client.rb +2 -2
- data/lib/weft/generated/api_error.rb +2 -2
- data/lib/weft/generated/api_model_base.rb +2 -2
- data/lib/weft/generated/configuration.rb +2 -2
- data/lib/weft/generated/models/account_details.rb +2 -2
- data/lib/weft/generated/models/api_key.rb +2 -2
- data/lib/weft/generated/models/api_key_created.rb +2 -2
- data/lib/weft/generated/models/api_key_created_response.rb +2 -2
- data/lib/weft/generated/models/api_key_list_response.rb +32 -6
- data/lib/weft/generated/models/auth_response.rb +2 -2
- data/lib/weft/generated/models/auth_response_data.rb +2 -2
- data/lib/weft/generated/models/balance_response.rb +271 -0
- data/lib/weft/generated/models/confirm_request.rb +2 -2
- data/lib/weft/generated/models/create_api_key_request.rb +2 -2
- data/lib/weft/generated/models/error.rb +7 -2
- data/lib/weft/generated/models/error_response.rb +3 -2
- data/lib/weft/generated/models/fetch_balance_snapshot.rb +217 -0
- data/lib/weft/generated/models/fetch_error_response.rb +298 -0
- data/lib/weft/generated/models/fetch_request.rb +266 -0
- data/lib/weft/generated/models/fetch_request_body.rb +105 -0
- data/lib/weft/generated/models/fetch_response.rb +330 -0
- data/lib/weft/generated/models/me_response.rb +2 -2
- data/lib/weft/generated/models/merchant.rb +264 -0
- data/lib/weft/generated/models/message_response.rb +2 -2
- data/lib/weft/generated/models/message_response_data.rb +2 -2
- data/lib/weft/generated/models/pagination.rb +2 -2
- data/lib/weft/generated/models/password_reset_request.rb +2 -2
- data/lib/weft/generated/models/password_update_request.rb +2 -2
- data/lib/weft/generated/models/payment.rb +2 -2
- data/lib/weft/generated/models/payment_list_response.rb +2 -2
- data/lib/weft/generated/models/payment_response.rb +2 -2
- data/lib/weft/generated/models/promo_balance.rb +218 -0
- data/lib/weft/generated/models/resend_confirmation_request.rb +2 -2
- data/lib/weft/generated/models/search_agent_card.rb +228 -0
- data/lib/weft/generated/models/{agent_stats.rb → search_endpoints.rb} +33 -57
- data/lib/weft/generated/models/search_error_response.rb +202 -0
- data/lib/weft/generated/models/search_filters.rb +277 -0
- data/lib/weft/generated/models/search_pricing.rb +232 -0
- data/lib/weft/generated/models/search_ranking.rb +277 -0
- data/lib/weft/generated/models/search_request.rb +223 -0
- data/lib/weft/generated/models/{agent_response.rb → search_response.rb} +64 -21
- data/lib/weft/generated/models/search_result.rb +414 -0
- data/lib/weft/generated/models/search_skill.rb +259 -0
- data/lib/weft/generated/models/{agent_list_response.rb → search_skill_endpoint.rb} +19 -54
- data/lib/weft/generated/models/sign_in_request.rb +2 -2
- data/lib/weft/generated/models/sign_up_request.rb +2 -2
- data/lib/weft/generated/models/spending_policy.rb +219 -0
- data/lib/weft/generated/models/user.rb +2 -2
- data/lib/weft/generated/models/wallet.rb +219 -0
- data/lib/weft/generated/version.rb +3 -3
- data/lib/weft/sdk.rb +1 -1
- metadata +50 -12
- data/docs/Agent.md +0 -38
- data/docs/AgentListResponse.md +0 -20
- data/docs/AgentResponse.md +0 -18
- data/docs/AgentStats.md +0 -30
- data/docs/AgentsApi.md +0 -147
- data/lib/weft/generated/api/agents_api.rb +0 -148
- data/lib/weft/generated/models/agent.rb +0 -417
|
@@ -0,0 +1,266 @@
|
|
|
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.5.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 FetchRequest < ApiModelBase
|
|
18
|
+
# Target URL. Must pass Weft's URL safety check (no SSRF / private IP ranges).
|
|
19
|
+
attr_accessor :url
|
|
20
|
+
|
|
21
|
+
# Hard ceiling on what the buyer is willing to pay. Defaults to `0.10` USD.
|
|
22
|
+
attr_accessor :max_cost_usd
|
|
23
|
+
|
|
24
|
+
# HTTP method to use against the upstream.
|
|
25
|
+
attr_accessor :method
|
|
26
|
+
|
|
27
|
+
attr_accessor :body
|
|
28
|
+
|
|
29
|
+
# Headers forwarded to the upstream. Up to 32 headers, 4 KB total. The following are silently stripped: `host`, `authorization`, `cookie`, `proxy-authorization`, `x-forwarded-*`, `x-real-ip`, `x-payment`, `connection`, `upgrade`.
|
|
30
|
+
attr_accessor :headers
|
|
31
|
+
|
|
32
|
+
class EnumAttributeValidator
|
|
33
|
+
attr_reader :datatype
|
|
34
|
+
attr_reader :allowable_values
|
|
35
|
+
|
|
36
|
+
def initialize(datatype, allowable_values)
|
|
37
|
+
@allowable_values = allowable_values.map do |value|
|
|
38
|
+
case datatype.to_s
|
|
39
|
+
when /Integer/i
|
|
40
|
+
value.to_i
|
|
41
|
+
when /Float/i
|
|
42
|
+
value.to_f
|
|
43
|
+
else
|
|
44
|
+
value
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def valid?(value)
|
|
50
|
+
!value || allowable_values.include?(value)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
55
|
+
def self.attribute_map
|
|
56
|
+
{
|
|
57
|
+
:'url' => :'url',
|
|
58
|
+
:'max_cost_usd' => :'max_cost_usd',
|
|
59
|
+
:'method' => :'method',
|
|
60
|
+
:'body' => :'body',
|
|
61
|
+
:'headers' => :'headers'
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Returns attribute mapping this model knows about
|
|
66
|
+
def self.acceptable_attribute_map
|
|
67
|
+
attribute_map
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Returns all the JSON keys this model knows about
|
|
71
|
+
def self.acceptable_attributes
|
|
72
|
+
acceptable_attribute_map.values
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Attribute type mapping.
|
|
76
|
+
def self.openapi_types
|
|
77
|
+
{
|
|
78
|
+
:'url' => :'String',
|
|
79
|
+
:'max_cost_usd' => :'String',
|
|
80
|
+
:'method' => :'String',
|
|
81
|
+
:'body' => :'FetchRequestBody',
|
|
82
|
+
:'headers' => :'Hash<String, String>'
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# List of attributes with nullable: true
|
|
87
|
+
def self.openapi_nullable
|
|
88
|
+
Set.new([
|
|
89
|
+
:'body',
|
|
90
|
+
])
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Initializes the object
|
|
94
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
95
|
+
def initialize(attributes = {})
|
|
96
|
+
if (!attributes.is_a?(Hash))
|
|
97
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::FetchRequest` initialize method"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
101
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
102
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
103
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
104
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::FetchRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
105
|
+
end
|
|
106
|
+
h[k.to_sym] = v
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'url')
|
|
110
|
+
self.url = attributes[:'url']
|
|
111
|
+
else
|
|
112
|
+
self.url = nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if attributes.key?(:'max_cost_usd')
|
|
116
|
+
self.max_cost_usd = attributes[:'max_cost_usd']
|
|
117
|
+
else
|
|
118
|
+
self.max_cost_usd = '0.10'
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.key?(:'method')
|
|
122
|
+
self.method = attributes[:'method']
|
|
123
|
+
else
|
|
124
|
+
self.method = 'GET'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if attributes.key?(:'body')
|
|
128
|
+
self.body = attributes[:'body']
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
if attributes.key?(:'headers')
|
|
132
|
+
if (value = attributes[:'headers']).is_a?(Hash)
|
|
133
|
+
self.headers = value
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
139
|
+
# @return Array for valid properties with the reasons
|
|
140
|
+
def list_invalid_properties
|
|
141
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
142
|
+
invalid_properties = Array.new
|
|
143
|
+
if @url.nil?
|
|
144
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
148
|
+
if !@max_cost_usd.nil? && @max_cost_usd !~ pattern
|
|
149
|
+
invalid_properties.push("invalid value for \"max_cost_usd\", must conform to the pattern #{pattern}.")
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
invalid_properties
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Check to see if the all the properties in the model are valid
|
|
156
|
+
# @return true if the model is valid
|
|
157
|
+
def valid?
|
|
158
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
159
|
+
return false if @url.nil?
|
|
160
|
+
return false if !@max_cost_usd.nil? && @max_cost_usd !~ Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
161
|
+
method_validator = EnumAttributeValidator.new('String', ["GET", "POST", "PUT", "PATCH", "DELETE"])
|
|
162
|
+
return false unless method_validator.valid?(@method)
|
|
163
|
+
true
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Custom attribute writer method with validation
|
|
167
|
+
# @param [Object] url Value to be assigned
|
|
168
|
+
def url=(url)
|
|
169
|
+
if url.nil?
|
|
170
|
+
fail ArgumentError, 'url cannot be nil'
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
@url = url
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Custom attribute writer method with validation
|
|
177
|
+
# @param [Object] max_cost_usd Value to be assigned
|
|
178
|
+
def max_cost_usd=(max_cost_usd)
|
|
179
|
+
if max_cost_usd.nil?
|
|
180
|
+
fail ArgumentError, 'max_cost_usd cannot be nil'
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
184
|
+
if max_cost_usd !~ pattern
|
|
185
|
+
fail ArgumentError, "invalid value for \"max_cost_usd\", must conform to the pattern #{pattern}."
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
@max_cost_usd = max_cost_usd
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
192
|
+
# @param [Object] method Object to be assigned
|
|
193
|
+
def method=(method)
|
|
194
|
+
validator = EnumAttributeValidator.new('String', ["GET", "POST", "PUT", "PATCH", "DELETE"])
|
|
195
|
+
unless validator.valid?(method)
|
|
196
|
+
fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}."
|
|
197
|
+
end
|
|
198
|
+
@method = method
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Checks equality by comparing each attribute.
|
|
202
|
+
# @param [Object] Object to be compared
|
|
203
|
+
def ==(o)
|
|
204
|
+
return true if self.equal?(o)
|
|
205
|
+
self.class == o.class &&
|
|
206
|
+
url == o.url &&
|
|
207
|
+
max_cost_usd == o.max_cost_usd &&
|
|
208
|
+
method == o.method &&
|
|
209
|
+
body == o.body &&
|
|
210
|
+
headers == o.headers
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# @see the `==` method
|
|
214
|
+
# @param [Object] Object to be compared
|
|
215
|
+
def eql?(o)
|
|
216
|
+
self == o
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Calculates hash code according to all attributes.
|
|
220
|
+
# @return [Integer] Hash code
|
|
221
|
+
def hash
|
|
222
|
+
[url, max_cost_usd, method, body, headers].hash
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Builds the object from hash
|
|
226
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
227
|
+
# @return [Object] Returns the model itself
|
|
228
|
+
def self.build_from_hash(attributes)
|
|
229
|
+
return nil unless attributes.is_a?(Hash)
|
|
230
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
231
|
+
transformed_hash = {}
|
|
232
|
+
openapi_types.each_pair do |key, type|
|
|
233
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
234
|
+
transformed_hash["#{key}"] = nil
|
|
235
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
236
|
+
# check to ensure the input is an array given that the attribute
|
|
237
|
+
# is documented as an array but the input is not
|
|
238
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
239
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
240
|
+
end
|
|
241
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
242
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
new(transformed_hash)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Returns the object in the form of hash
|
|
249
|
+
# @return [Hash] Returns the object in the form of hash
|
|
250
|
+
def to_hash
|
|
251
|
+
hash = {}
|
|
252
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
253
|
+
value = self.send(attr)
|
|
254
|
+
if value.nil?
|
|
255
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
256
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
hash[param] = _to_hash(value)
|
|
260
|
+
end
|
|
261
|
+
hash
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
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.5.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
|
+
# Request body forwarded to the upstream. Pass `null` for GET.
|
|
18
|
+
module FetchRequestBody
|
|
19
|
+
class << self
|
|
20
|
+
# List of class defined in oneOf (OpenAPI v3)
|
|
21
|
+
def openapi_one_of
|
|
22
|
+
[
|
|
23
|
+
:'Object',
|
|
24
|
+
:'String'
|
|
25
|
+
]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the object
|
|
29
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
30
|
+
# @return [Object] Returns the model or the data itself
|
|
31
|
+
def build(data)
|
|
32
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
|
33
|
+
# Note:
|
|
34
|
+
# - We do not attempt to check whether exactly one item matches.
|
|
35
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
36
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
37
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
38
|
+
# - TODO: logging when debugging is set.
|
|
39
|
+
openapi_one_of.each do |klass|
|
|
40
|
+
begin
|
|
41
|
+
next if klass == :AnyType # "nullable: true"
|
|
42
|
+
return find_and_cast_into_type(klass, data)
|
|
43
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
53
|
+
|
|
54
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
55
|
+
def find_and_cast_into_type(klass, data)
|
|
56
|
+
return if data.nil?
|
|
57
|
+
|
|
58
|
+
case klass.to_s
|
|
59
|
+
when 'Boolean'
|
|
60
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
61
|
+
when 'Float'
|
|
62
|
+
return data if data.instance_of?(Float)
|
|
63
|
+
when 'Integer'
|
|
64
|
+
return data if data.instance_of?(Integer)
|
|
65
|
+
when 'Time'
|
|
66
|
+
return Time.parse(data)
|
|
67
|
+
when 'Date'
|
|
68
|
+
return Date.iso8601(data)
|
|
69
|
+
when 'String'
|
|
70
|
+
return data if data.instance_of?(String)
|
|
71
|
+
when 'Object' # "type: object"
|
|
72
|
+
return data if data.instance_of?(Hash)
|
|
73
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
74
|
+
if data.instance_of?(Array)
|
|
75
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
76
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
77
|
+
end
|
|
78
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
79
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
80
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
81
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
82
|
+
end
|
|
83
|
+
else # model
|
|
84
|
+
const = Weft.const_get(klass)
|
|
85
|
+
if const
|
|
86
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
|
87
|
+
model = const.build(data)
|
|
88
|
+
return model if model
|
|
89
|
+
else
|
|
90
|
+
# raise if data contains keys that are not known to the model
|
|
91
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
92
|
+
model = const.build_from_hash(data)
|
|
93
|
+
return model if model
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
raise # if no match by now, raise
|
|
99
|
+
rescue
|
|
100
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
@@ -0,0 +1,330 @@
|
|
|
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.5.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
|
+
# Successful fetch envelope. `body_base64` is the upstream artifact bytes, base64-encoded. `paid_usd`, `tx_hash`, and `merchant` are populated only when the upstream charged for the response.
|
|
18
|
+
class FetchResponse < ApiModelBase
|
|
19
|
+
# HTTP status returned by the upstream after the paid replay.
|
|
20
|
+
attr_accessor :status
|
|
21
|
+
|
|
22
|
+
# Response headers from the upstream.
|
|
23
|
+
attr_accessor :headers
|
|
24
|
+
|
|
25
|
+
# Base64-encoded response body. Empty string for empty bodies.
|
|
26
|
+
attr_accessor :body_base64
|
|
27
|
+
|
|
28
|
+
# USD amount actually settled. Null for free upstreams.
|
|
29
|
+
attr_accessor :paid_usd
|
|
30
|
+
|
|
31
|
+
# Settlement transaction hash. Null for free upstreams.
|
|
32
|
+
attr_accessor :tx_hash
|
|
33
|
+
|
|
34
|
+
# Internal artifact identifier if the response was persisted.
|
|
35
|
+
attr_accessor :artifact_id
|
|
36
|
+
|
|
37
|
+
# Merchant reputation snapshot. Null for free upstreams.
|
|
38
|
+
attr_accessor :merchant
|
|
39
|
+
|
|
40
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
41
|
+
def self.attribute_map
|
|
42
|
+
{
|
|
43
|
+
:'status' => :'status',
|
|
44
|
+
:'headers' => :'headers',
|
|
45
|
+
:'body_base64' => :'body_base64',
|
|
46
|
+
:'paid_usd' => :'paid_usd',
|
|
47
|
+
:'tx_hash' => :'tx_hash',
|
|
48
|
+
:'artifact_id' => :'artifact_id',
|
|
49
|
+
:'merchant' => :'merchant'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns attribute mapping this model knows about
|
|
54
|
+
def self.acceptable_attribute_map
|
|
55
|
+
attribute_map
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns all the JSON keys this model knows about
|
|
59
|
+
def self.acceptable_attributes
|
|
60
|
+
acceptable_attribute_map.values
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Attribute type mapping.
|
|
64
|
+
def self.openapi_types
|
|
65
|
+
{
|
|
66
|
+
:'status' => :'Integer',
|
|
67
|
+
:'headers' => :'Hash<String, String>',
|
|
68
|
+
:'body_base64' => :'String',
|
|
69
|
+
:'paid_usd' => :'String',
|
|
70
|
+
:'tx_hash' => :'String',
|
|
71
|
+
:'artifact_id' => :'String',
|
|
72
|
+
:'merchant' => :'Merchant'
|
|
73
|
+
}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# List of attributes with nullable: true
|
|
77
|
+
def self.openapi_nullable
|
|
78
|
+
Set.new([
|
|
79
|
+
])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Initializes the object
|
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
84
|
+
def initialize(attributes = {})
|
|
85
|
+
if (!attributes.is_a?(Hash))
|
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::FetchResponse` initialize method"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
90
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
91
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
92
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
93
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::FetchResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
94
|
+
end
|
|
95
|
+
h[k.to_sym] = v
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if attributes.key?(:'status')
|
|
99
|
+
self.status = attributes[:'status']
|
|
100
|
+
else
|
|
101
|
+
self.status = nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if attributes.key?(:'headers')
|
|
105
|
+
if (value = attributes[:'headers']).is_a?(Hash)
|
|
106
|
+
self.headers = value
|
|
107
|
+
end
|
|
108
|
+
else
|
|
109
|
+
self.headers = nil
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if attributes.key?(:'body_base64')
|
|
113
|
+
self.body_base64 = attributes[:'body_base64']
|
|
114
|
+
else
|
|
115
|
+
self.body_base64 = nil
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if attributes.key?(:'paid_usd')
|
|
119
|
+
self.paid_usd = attributes[:'paid_usd']
|
|
120
|
+
else
|
|
121
|
+
self.paid_usd = nil
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
if attributes.key?(:'tx_hash')
|
|
125
|
+
self.tx_hash = attributes[:'tx_hash']
|
|
126
|
+
else
|
|
127
|
+
self.tx_hash = nil
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
if attributes.key?(:'artifact_id')
|
|
131
|
+
self.artifact_id = attributes[:'artifact_id']
|
|
132
|
+
else
|
|
133
|
+
self.artifact_id = nil
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if attributes.key?(:'merchant')
|
|
137
|
+
self.merchant = attributes[:'merchant']
|
|
138
|
+
else
|
|
139
|
+
self.merchant = nil
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
144
|
+
# @return Array for valid properties with the reasons
|
|
145
|
+
def list_invalid_properties
|
|
146
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
147
|
+
invalid_properties = Array.new
|
|
148
|
+
if @status.nil?
|
|
149
|
+
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
if @headers.nil?
|
|
153
|
+
invalid_properties.push('invalid value for "headers", headers cannot be nil.')
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
if @body_base64.nil?
|
|
157
|
+
invalid_properties.push('invalid value for "body_base64", body_base64 cannot be nil.')
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
if @paid_usd.nil?
|
|
161
|
+
invalid_properties.push('invalid value for "paid_usd", paid_usd cannot be nil.')
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
if @tx_hash.nil?
|
|
165
|
+
invalid_properties.push('invalid value for "tx_hash", tx_hash cannot be nil.')
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
if @artifact_id.nil?
|
|
169
|
+
invalid_properties.push('invalid value for "artifact_id", artifact_id cannot be nil.')
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
if @merchant.nil?
|
|
173
|
+
invalid_properties.push('invalid value for "merchant", merchant cannot be nil.')
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
invalid_properties
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Check to see if the all the properties in the model are valid
|
|
180
|
+
# @return true if the model is valid
|
|
181
|
+
def valid?
|
|
182
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
183
|
+
return false if @status.nil?
|
|
184
|
+
return false if @headers.nil?
|
|
185
|
+
return false if @body_base64.nil?
|
|
186
|
+
return false if @paid_usd.nil?
|
|
187
|
+
return false if @tx_hash.nil?
|
|
188
|
+
return false if @artifact_id.nil?
|
|
189
|
+
return false if @merchant.nil?
|
|
190
|
+
true
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Custom attribute writer method with validation
|
|
194
|
+
# @param [Object] status Value to be assigned
|
|
195
|
+
def status=(status)
|
|
196
|
+
if status.nil?
|
|
197
|
+
fail ArgumentError, 'status cannot be nil'
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
@status = status
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Custom attribute writer method with validation
|
|
204
|
+
# @param [Object] headers Value to be assigned
|
|
205
|
+
def headers=(headers)
|
|
206
|
+
if headers.nil?
|
|
207
|
+
fail ArgumentError, 'headers cannot be nil'
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
@headers = headers
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Custom attribute writer method with validation
|
|
214
|
+
# @param [Object] body_base64 Value to be assigned
|
|
215
|
+
def body_base64=(body_base64)
|
|
216
|
+
if body_base64.nil?
|
|
217
|
+
fail ArgumentError, 'body_base64 cannot be nil'
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
@body_base64 = body_base64
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Custom attribute writer method with validation
|
|
224
|
+
# @param [Object] paid_usd Value to be assigned
|
|
225
|
+
def paid_usd=(paid_usd)
|
|
226
|
+
if paid_usd.nil?
|
|
227
|
+
fail ArgumentError, 'paid_usd cannot be nil'
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
@paid_usd = paid_usd
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Custom attribute writer method with validation
|
|
234
|
+
# @param [Object] tx_hash Value to be assigned
|
|
235
|
+
def tx_hash=(tx_hash)
|
|
236
|
+
if tx_hash.nil?
|
|
237
|
+
fail ArgumentError, 'tx_hash cannot be nil'
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
@tx_hash = tx_hash
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Custom attribute writer method with validation
|
|
244
|
+
# @param [Object] artifact_id Value to be assigned
|
|
245
|
+
def artifact_id=(artifact_id)
|
|
246
|
+
if artifact_id.nil?
|
|
247
|
+
fail ArgumentError, 'artifact_id cannot be nil'
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
@artifact_id = artifact_id
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Custom attribute writer method with validation
|
|
254
|
+
# @param [Object] merchant Value to be assigned
|
|
255
|
+
def merchant=(merchant)
|
|
256
|
+
if merchant.nil?
|
|
257
|
+
fail ArgumentError, 'merchant cannot be nil'
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
@merchant = merchant
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Checks equality by comparing each attribute.
|
|
264
|
+
# @param [Object] Object to be compared
|
|
265
|
+
def ==(o)
|
|
266
|
+
return true if self.equal?(o)
|
|
267
|
+
self.class == o.class &&
|
|
268
|
+
status == o.status &&
|
|
269
|
+
headers == o.headers &&
|
|
270
|
+
body_base64 == o.body_base64 &&
|
|
271
|
+
paid_usd == o.paid_usd &&
|
|
272
|
+
tx_hash == o.tx_hash &&
|
|
273
|
+
artifact_id == o.artifact_id &&
|
|
274
|
+
merchant == o.merchant
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# @see the `==` method
|
|
278
|
+
# @param [Object] Object to be compared
|
|
279
|
+
def eql?(o)
|
|
280
|
+
self == o
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Calculates hash code according to all attributes.
|
|
284
|
+
# @return [Integer] Hash code
|
|
285
|
+
def hash
|
|
286
|
+
[status, headers, body_base64, paid_usd, tx_hash, artifact_id, merchant].hash
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Builds the object from hash
|
|
290
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
291
|
+
# @return [Object] Returns the model itself
|
|
292
|
+
def self.build_from_hash(attributes)
|
|
293
|
+
return nil unless attributes.is_a?(Hash)
|
|
294
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
295
|
+
transformed_hash = {}
|
|
296
|
+
openapi_types.each_pair do |key, type|
|
|
297
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
298
|
+
transformed_hash["#{key}"] = nil
|
|
299
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
300
|
+
# check to ensure the input is an array given that the attribute
|
|
301
|
+
# is documented as an array but the input is not
|
|
302
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
303
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
304
|
+
end
|
|
305
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
306
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
new(transformed_hash)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# Returns the object in the form of hash
|
|
313
|
+
# @return [Hash] Returns the object in the form of hash
|
|
314
|
+
def to_hash
|
|
315
|
+
hash = {}
|
|
316
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
317
|
+
value = self.send(attr)
|
|
318
|
+
if value.nil?
|
|
319
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
320
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
hash[param] = _to_hash(value)
|
|
324
|
+
end
|
|
325
|
+
hash
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
end
|