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,277 @@
|
|
|
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
|
+
# Optional narrowing applied after the embedding score is computed. Unknown keys are rejected. Price filters use the agent's cheapest skill for `max_price_usd` and the most-expensive skill for `min_price_usd`, so an agent stays in results as long as any one of its skills satisfies the band.
|
|
18
|
+
class SearchFilters < ApiModelBase
|
|
19
|
+
# Decimal USD floor; agent must have at least one skill priced at or above this.
|
|
20
|
+
attr_accessor :min_price_usd
|
|
21
|
+
|
|
22
|
+
# Decimal USD ceiling; agent must have at least one skill priced at or below this.
|
|
23
|
+
attr_accessor :max_price_usd
|
|
24
|
+
|
|
25
|
+
# Payment protocol the agent settles on.
|
|
26
|
+
attr_accessor :payment_protocol
|
|
27
|
+
|
|
28
|
+
# Agent protocol surface (Agent-to-Agent, MCP, or raw OpenAPI).
|
|
29
|
+
attr_accessor :agent_protocol
|
|
30
|
+
|
|
31
|
+
# Substring match against any of the agent's declared domain tags (e.g. `email`, `sales`, `enrichment`).
|
|
32
|
+
attr_accessor :domain
|
|
33
|
+
|
|
34
|
+
class EnumAttributeValidator
|
|
35
|
+
attr_reader :datatype
|
|
36
|
+
attr_reader :allowable_values
|
|
37
|
+
|
|
38
|
+
def initialize(datatype, allowable_values)
|
|
39
|
+
@allowable_values = allowable_values.map do |value|
|
|
40
|
+
case datatype.to_s
|
|
41
|
+
when /Integer/i
|
|
42
|
+
value.to_i
|
|
43
|
+
when /Float/i
|
|
44
|
+
value.to_f
|
|
45
|
+
else
|
|
46
|
+
value
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def valid?(value)
|
|
52
|
+
!value || allowable_values.include?(value)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
57
|
+
def self.attribute_map
|
|
58
|
+
{
|
|
59
|
+
:'min_price_usd' => :'min_price_usd',
|
|
60
|
+
:'max_price_usd' => :'max_price_usd',
|
|
61
|
+
:'payment_protocol' => :'payment_protocol',
|
|
62
|
+
:'agent_protocol' => :'agent_protocol',
|
|
63
|
+
:'domain' => :'domain'
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Returns attribute mapping this model knows about
|
|
68
|
+
def self.acceptable_attribute_map
|
|
69
|
+
attribute_map
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Returns all the JSON keys this model knows about
|
|
73
|
+
def self.acceptable_attributes
|
|
74
|
+
acceptable_attribute_map.values
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Attribute type mapping.
|
|
78
|
+
def self.openapi_types
|
|
79
|
+
{
|
|
80
|
+
:'min_price_usd' => :'String',
|
|
81
|
+
:'max_price_usd' => :'String',
|
|
82
|
+
:'payment_protocol' => :'String',
|
|
83
|
+
:'agent_protocol' => :'String',
|
|
84
|
+
:'domain' => :'String'
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# List of attributes with nullable: true
|
|
89
|
+
def self.openapi_nullable
|
|
90
|
+
Set.new([
|
|
91
|
+
])
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Initializes the object
|
|
95
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
96
|
+
def initialize(attributes = {})
|
|
97
|
+
if (!attributes.is_a?(Hash))
|
|
98
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::SearchFilters` initialize method"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
102
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
103
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
104
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
105
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::SearchFilters`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
106
|
+
end
|
|
107
|
+
h[k.to_sym] = v
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if attributes.key?(:'min_price_usd')
|
|
111
|
+
self.min_price_usd = attributes[:'min_price_usd']
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
if attributes.key?(:'max_price_usd')
|
|
115
|
+
self.max_price_usd = attributes[:'max_price_usd']
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if attributes.key?(:'payment_protocol')
|
|
119
|
+
self.payment_protocol = attributes[:'payment_protocol']
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if attributes.key?(:'agent_protocol')
|
|
123
|
+
self.agent_protocol = attributes[:'agent_protocol']
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
if attributes.key?(:'domain')
|
|
127
|
+
self.domain = attributes[:'domain']
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
132
|
+
# @return Array for valid properties with the reasons
|
|
133
|
+
def list_invalid_properties
|
|
134
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
135
|
+
invalid_properties = Array.new
|
|
136
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
137
|
+
if !@min_price_usd.nil? && @min_price_usd !~ pattern
|
|
138
|
+
invalid_properties.push("invalid value for \"min_price_usd\", must conform to the pattern #{pattern}.")
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
142
|
+
if !@max_price_usd.nil? && @max_price_usd !~ pattern
|
|
143
|
+
invalid_properties.push("invalid value for \"max_price_usd\", must conform to the pattern #{pattern}.")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
invalid_properties
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Check to see if the all the properties in the model are valid
|
|
150
|
+
# @return true if the model is valid
|
|
151
|
+
def valid?
|
|
152
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
153
|
+
return false if !@min_price_usd.nil? && @min_price_usd !~ Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
154
|
+
return false if !@max_price_usd.nil? && @max_price_usd !~ Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
155
|
+
payment_protocol_validator = EnumAttributeValidator.new('String', ["x402", "mpp", "free"])
|
|
156
|
+
return false unless payment_protocol_validator.valid?(@payment_protocol)
|
|
157
|
+
agent_protocol_validator = EnumAttributeValidator.new('String', ["a2a", "mcp", "openapi"])
|
|
158
|
+
return false unless agent_protocol_validator.valid?(@agent_protocol)
|
|
159
|
+
true
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Custom attribute writer method with validation
|
|
163
|
+
# @param [Object] min_price_usd Value to be assigned
|
|
164
|
+
def min_price_usd=(min_price_usd)
|
|
165
|
+
if min_price_usd.nil?
|
|
166
|
+
fail ArgumentError, 'min_price_usd cannot be nil'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
170
|
+
if min_price_usd !~ pattern
|
|
171
|
+
fail ArgumentError, "invalid value for \"min_price_usd\", must conform to the pattern #{pattern}."
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
@min_price_usd = min_price_usd
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Custom attribute writer method with validation
|
|
178
|
+
# @param [Object] max_price_usd Value to be assigned
|
|
179
|
+
def max_price_usd=(max_price_usd)
|
|
180
|
+
if max_price_usd.nil?
|
|
181
|
+
fail ArgumentError, 'max_price_usd cannot be nil'
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
185
|
+
if max_price_usd !~ pattern
|
|
186
|
+
fail ArgumentError, "invalid value for \"max_price_usd\", must conform to the pattern #{pattern}."
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
@max_price_usd = max_price_usd
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
193
|
+
# @param [Object] payment_protocol Object to be assigned
|
|
194
|
+
def payment_protocol=(payment_protocol)
|
|
195
|
+
validator = EnumAttributeValidator.new('String', ["x402", "mpp", "free"])
|
|
196
|
+
unless validator.valid?(payment_protocol)
|
|
197
|
+
fail ArgumentError, "invalid value for \"payment_protocol\", must be one of #{validator.allowable_values}."
|
|
198
|
+
end
|
|
199
|
+
@payment_protocol = payment_protocol
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
203
|
+
# @param [Object] agent_protocol Object to be assigned
|
|
204
|
+
def agent_protocol=(agent_protocol)
|
|
205
|
+
validator = EnumAttributeValidator.new('String', ["a2a", "mcp", "openapi"])
|
|
206
|
+
unless validator.valid?(agent_protocol)
|
|
207
|
+
fail ArgumentError, "invalid value for \"agent_protocol\", must be one of #{validator.allowable_values}."
|
|
208
|
+
end
|
|
209
|
+
@agent_protocol = agent_protocol
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Checks equality by comparing each attribute.
|
|
213
|
+
# @param [Object] Object to be compared
|
|
214
|
+
def ==(o)
|
|
215
|
+
return true if self.equal?(o)
|
|
216
|
+
self.class == o.class &&
|
|
217
|
+
min_price_usd == o.min_price_usd &&
|
|
218
|
+
max_price_usd == o.max_price_usd &&
|
|
219
|
+
payment_protocol == o.payment_protocol &&
|
|
220
|
+
agent_protocol == o.agent_protocol &&
|
|
221
|
+
domain == o.domain
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# @see the `==` method
|
|
225
|
+
# @param [Object] Object to be compared
|
|
226
|
+
def eql?(o)
|
|
227
|
+
self == o
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Calculates hash code according to all attributes.
|
|
231
|
+
# @return [Integer] Hash code
|
|
232
|
+
def hash
|
|
233
|
+
[min_price_usd, max_price_usd, payment_protocol, agent_protocol, domain].hash
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Builds the object from hash
|
|
237
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
238
|
+
# @return [Object] Returns the model itself
|
|
239
|
+
def self.build_from_hash(attributes)
|
|
240
|
+
return nil unless attributes.is_a?(Hash)
|
|
241
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
242
|
+
transformed_hash = {}
|
|
243
|
+
openapi_types.each_pair do |key, type|
|
|
244
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
245
|
+
transformed_hash["#{key}"] = nil
|
|
246
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
247
|
+
# check to ensure the input is an array given that the attribute
|
|
248
|
+
# is documented as an array but the input is not
|
|
249
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
250
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
251
|
+
end
|
|
252
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
253
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
new(transformed_hash)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Returns the object in the form of hash
|
|
260
|
+
# @return [Hash] Returns the object in the form of hash
|
|
261
|
+
def to_hash
|
|
262
|
+
hash = {}
|
|
263
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
264
|
+
value = self.send(attr)
|
|
265
|
+
if value.nil?
|
|
266
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
267
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
hash[param] = _to_hash(value)
|
|
271
|
+
end
|
|
272
|
+
hash
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
end
|
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
# Aggregate pricing at the agent level. `recipient_address` is intentionally absent from the index — under x402 it is delivered per-request in the `402 Payment Required` challenge from the agent.
|
|
18
|
+
class SearchPricing < ApiModelBase
|
|
19
|
+
attr_accessor :protocol
|
|
20
|
+
|
|
21
|
+
attr_accessor :scheme
|
|
22
|
+
|
|
23
|
+
# Default per-call amount; individual skills may override via `price_usd`.
|
|
24
|
+
attr_accessor :amount_usd
|
|
25
|
+
|
|
26
|
+
# Settlement network (e.g. `base-sepolia`).
|
|
27
|
+
attr_accessor :network
|
|
28
|
+
|
|
29
|
+
class EnumAttributeValidator
|
|
30
|
+
attr_reader :datatype
|
|
31
|
+
attr_reader :allowable_values
|
|
32
|
+
|
|
33
|
+
def initialize(datatype, allowable_values)
|
|
34
|
+
@allowable_values = allowable_values.map do |value|
|
|
35
|
+
case datatype.to_s
|
|
36
|
+
when /Integer/i
|
|
37
|
+
value.to_i
|
|
38
|
+
when /Float/i
|
|
39
|
+
value.to_f
|
|
40
|
+
else
|
|
41
|
+
value
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def valid?(value)
|
|
47
|
+
!value || allowable_values.include?(value)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
52
|
+
def self.attribute_map
|
|
53
|
+
{
|
|
54
|
+
:'protocol' => :'protocol',
|
|
55
|
+
:'scheme' => :'scheme',
|
|
56
|
+
:'amount_usd' => :'amount_usd',
|
|
57
|
+
:'network' => :'network'
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Returns attribute mapping this model knows about
|
|
62
|
+
def self.acceptable_attribute_map
|
|
63
|
+
attribute_map
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Returns all the JSON keys this model knows about
|
|
67
|
+
def self.acceptable_attributes
|
|
68
|
+
acceptable_attribute_map.values
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Attribute type mapping.
|
|
72
|
+
def self.openapi_types
|
|
73
|
+
{
|
|
74
|
+
:'protocol' => :'String',
|
|
75
|
+
:'scheme' => :'String',
|
|
76
|
+
:'amount_usd' => :'String',
|
|
77
|
+
:'network' => :'String'
|
|
78
|
+
}
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# List of attributes with nullable: true
|
|
82
|
+
def self.openapi_nullable
|
|
83
|
+
Set.new([
|
|
84
|
+
])
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Initializes the object
|
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
89
|
+
def initialize(attributes = {})
|
|
90
|
+
if (!attributes.is_a?(Hash))
|
|
91
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::SearchPricing` initialize method"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
95
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
96
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
97
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
98
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::SearchPricing`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
99
|
+
end
|
|
100
|
+
h[k.to_sym] = v
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if attributes.key?(:'protocol')
|
|
104
|
+
self.protocol = attributes[:'protocol']
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if attributes.key?(:'scheme')
|
|
108
|
+
self.scheme = attributes[:'scheme']
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if attributes.key?(:'amount_usd')
|
|
112
|
+
self.amount_usd = attributes[:'amount_usd']
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if attributes.key?(:'network')
|
|
116
|
+
self.network = attributes[:'network']
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
121
|
+
# @return Array for valid properties with the reasons
|
|
122
|
+
def list_invalid_properties
|
|
123
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
124
|
+
invalid_properties = Array.new
|
|
125
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
126
|
+
if !@amount_usd.nil? && @amount_usd !~ pattern
|
|
127
|
+
invalid_properties.push("invalid value for \"amount_usd\", must conform to the pattern #{pattern}.")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
invalid_properties
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Check to see if the all the properties in the model are valid
|
|
134
|
+
# @return true if the model is valid
|
|
135
|
+
def valid?
|
|
136
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
137
|
+
protocol_validator = EnumAttributeValidator.new('String', ["x402", "mpp", "free"])
|
|
138
|
+
return false unless protocol_validator.valid?(@protocol)
|
|
139
|
+
return false if !@amount_usd.nil? && @amount_usd !~ Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
140
|
+
true
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
144
|
+
# @param [Object] protocol Object to be assigned
|
|
145
|
+
def protocol=(protocol)
|
|
146
|
+
validator = EnumAttributeValidator.new('String', ["x402", "mpp", "free"])
|
|
147
|
+
unless validator.valid?(protocol)
|
|
148
|
+
fail ArgumentError, "invalid value for \"protocol\", must be one of #{validator.allowable_values}."
|
|
149
|
+
end
|
|
150
|
+
@protocol = protocol
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Custom attribute writer method with validation
|
|
154
|
+
# @param [Object] amount_usd Value to be assigned
|
|
155
|
+
def amount_usd=(amount_usd)
|
|
156
|
+
if amount_usd.nil?
|
|
157
|
+
fail ArgumentError, 'amount_usd cannot be nil'
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
pattern = Regexp.new(/^\d+(\.\d{1,6})?$/)
|
|
161
|
+
if amount_usd !~ pattern
|
|
162
|
+
fail ArgumentError, "invalid value for \"amount_usd\", must conform to the pattern #{pattern}."
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
@amount_usd = amount_usd
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Checks equality by comparing each attribute.
|
|
169
|
+
# @param [Object] Object to be compared
|
|
170
|
+
def ==(o)
|
|
171
|
+
return true if self.equal?(o)
|
|
172
|
+
self.class == o.class &&
|
|
173
|
+
protocol == o.protocol &&
|
|
174
|
+
scheme == o.scheme &&
|
|
175
|
+
amount_usd == o.amount_usd &&
|
|
176
|
+
network == o.network
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# @see the `==` method
|
|
180
|
+
# @param [Object] Object to be compared
|
|
181
|
+
def eql?(o)
|
|
182
|
+
self == o
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Calculates hash code according to all attributes.
|
|
186
|
+
# @return [Integer] Hash code
|
|
187
|
+
def hash
|
|
188
|
+
[protocol, scheme, amount_usd, network].hash
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Builds the object from hash
|
|
192
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
193
|
+
# @return [Object] Returns the model itself
|
|
194
|
+
def self.build_from_hash(attributes)
|
|
195
|
+
return nil unless attributes.is_a?(Hash)
|
|
196
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
197
|
+
transformed_hash = {}
|
|
198
|
+
openapi_types.each_pair do |key, type|
|
|
199
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
200
|
+
transformed_hash["#{key}"] = nil
|
|
201
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
202
|
+
# check to ensure the input is an array given that the attribute
|
|
203
|
+
# is documented as an array but the input is not
|
|
204
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
205
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
206
|
+
end
|
|
207
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
208
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
new(transformed_hash)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Returns the object in the form of hash
|
|
215
|
+
# @return [Hash] Returns the object in the form of hash
|
|
216
|
+
def to_hash
|
|
217
|
+
hash = {}
|
|
218
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
219
|
+
value = self.send(attr)
|
|
220
|
+
if value.nil?
|
|
221
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
222
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
hash[param] = _to_hash(value)
|
|
226
|
+
end
|
|
227
|
+
hash
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
end
|