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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/docs/ApiKeyListResponse.md +3 -1
  3. data/docs/BalanceApi.md +74 -0
  4. data/docs/BalanceResponse.md +26 -0
  5. data/docs/DefaultApi.md +12 -12
  6. data/docs/Error.md +7 -7
  7. data/docs/FetchApi.md +77 -0
  8. data/docs/FetchBalanceSnapshot.md +22 -0
  9. data/docs/FetchErrorResponse.md +26 -0
  10. data/docs/FetchRequest.md +26 -0
  11. data/docs/FetchRequestBody.md +49 -0
  12. data/docs/FetchResponse.md +30 -0
  13. data/docs/Merchant.md +24 -0
  14. data/docs/PromoBalance.md +22 -0
  15. data/docs/SearchAgentCard.md +34 -0
  16. data/docs/SearchApi.md +77 -0
  17. data/docs/SearchEndpoints.md +24 -0
  18. data/docs/SearchErrorResponse.md +20 -0
  19. data/docs/SearchFilters.md +26 -0
  20. data/docs/SearchPricing.md +24 -0
  21. data/docs/SearchRanking.md +26 -0
  22. data/docs/SearchRequest.md +22 -0
  23. data/docs/SearchResponse.md +26 -0
  24. data/docs/SearchResult.md +36 -0
  25. data/docs/SearchSkill.md +36 -0
  26. data/docs/SearchSkillEndpoint.md +20 -0
  27. data/docs/SpendingPolicy.md +22 -0
  28. data/docs/Wallet.md +22 -0
  29. data/lib/weft/generated/api/account_api.rb +2 -2
  30. data/lib/weft/generated/api/api_keys_api.rb +2 -2
  31. data/lib/weft/generated/api/auth_api.rb +2 -2
  32. data/lib/weft/generated/api/balance_api.rb +79 -0
  33. data/lib/weft/generated/api/default_api.rb +11 -11
  34. data/lib/weft/generated/api/fetch_api.rb +90 -0
  35. data/lib/weft/generated/api/payments_api.rb +2 -2
  36. data/lib/weft/generated/api/search_api.rb +90 -0
  37. data/lib/weft/generated/api_client.rb +2 -2
  38. data/lib/weft/generated/api_error.rb +2 -2
  39. data/lib/weft/generated/api_model_base.rb +2 -2
  40. data/lib/weft/generated/configuration.rb +2 -2
  41. data/lib/weft/generated/models/account_details.rb +2 -2
  42. data/lib/weft/generated/models/api_key.rb +2 -2
  43. data/lib/weft/generated/models/api_key_created.rb +2 -2
  44. data/lib/weft/generated/models/api_key_created_response.rb +2 -2
  45. data/lib/weft/generated/models/api_key_list_response.rb +32 -6
  46. data/lib/weft/generated/models/auth_response.rb +2 -2
  47. data/lib/weft/generated/models/auth_response_data.rb +2 -2
  48. data/lib/weft/generated/models/balance_response.rb +271 -0
  49. data/lib/weft/generated/models/confirm_request.rb +2 -2
  50. data/lib/weft/generated/models/create_api_key_request.rb +2 -2
  51. data/lib/weft/generated/models/error.rb +7 -2
  52. data/lib/weft/generated/models/error_response.rb +3 -2
  53. data/lib/weft/generated/models/fetch_balance_snapshot.rb +217 -0
  54. data/lib/weft/generated/models/fetch_error_response.rb +298 -0
  55. data/lib/weft/generated/models/fetch_request.rb +266 -0
  56. data/lib/weft/generated/models/fetch_request_body.rb +105 -0
  57. data/lib/weft/generated/models/fetch_response.rb +330 -0
  58. data/lib/weft/generated/models/me_response.rb +2 -2
  59. data/lib/weft/generated/models/merchant.rb +264 -0
  60. data/lib/weft/generated/models/message_response.rb +2 -2
  61. data/lib/weft/generated/models/message_response_data.rb +2 -2
  62. data/lib/weft/generated/models/pagination.rb +2 -2
  63. data/lib/weft/generated/models/password_reset_request.rb +2 -2
  64. data/lib/weft/generated/models/password_update_request.rb +2 -2
  65. data/lib/weft/generated/models/payment.rb +2 -2
  66. data/lib/weft/generated/models/payment_list_response.rb +2 -2
  67. data/lib/weft/generated/models/payment_response.rb +2 -2
  68. data/lib/weft/generated/models/promo_balance.rb +218 -0
  69. data/lib/weft/generated/models/resend_confirmation_request.rb +2 -2
  70. data/lib/weft/generated/models/search_agent_card.rb +228 -0
  71. data/lib/weft/generated/models/{agent_stats.rb → search_endpoints.rb} +33 -57
  72. data/lib/weft/generated/models/search_error_response.rb +202 -0
  73. data/lib/weft/generated/models/search_filters.rb +277 -0
  74. data/lib/weft/generated/models/search_pricing.rb +232 -0
  75. data/lib/weft/generated/models/search_ranking.rb +277 -0
  76. data/lib/weft/generated/models/search_request.rb +223 -0
  77. data/lib/weft/generated/models/{agent_response.rb → search_response.rb} +64 -21
  78. data/lib/weft/generated/models/search_result.rb +414 -0
  79. data/lib/weft/generated/models/search_skill.rb +259 -0
  80. data/lib/weft/generated/models/{agent_list_response.rb → search_skill_endpoint.rb} +19 -54
  81. data/lib/weft/generated/models/sign_in_request.rb +2 -2
  82. data/lib/weft/generated/models/sign_up_request.rb +2 -2
  83. data/lib/weft/generated/models/spending_policy.rb +219 -0
  84. data/lib/weft/generated/models/user.rb +2 -2
  85. data/lib/weft/generated/models/wallet.rb +219 -0
  86. data/lib/weft/generated/version.rb +3 -3
  87. data/lib/weft/sdk.rb +1 -1
  88. metadata +50 -12
  89. data/docs/Agent.md +0 -38
  90. data/docs/AgentListResponse.md +0 -20
  91. data/docs/AgentResponse.md +0 -18
  92. data/docs/AgentStats.md +0 -30
  93. data/docs/AgentsApi.md +0 -147
  94. data/lib/weft/generated/api/agents_api.rb +0 -148
  95. data/lib/weft/generated/models/agent.rb +0 -417
@@ -0,0 +1,228 @@
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
+ # A2A-spec-shaped AgentCard. Free-form `capabilities` and per-skill metadata follow the upstream A2A schema; documented here only at the surface level Weft's index actually populates.
18
+ class SearchAgentCard < ApiModelBase
19
+ attr_accessor :name
20
+
21
+ attr_accessor :description
22
+
23
+ attr_accessor :url
24
+
25
+ attr_accessor :version
26
+
27
+ attr_accessor :protocol_version
28
+
29
+ attr_accessor :capabilities
30
+
31
+ attr_accessor :default_input_modes
32
+
33
+ attr_accessor :default_output_modes
34
+
35
+ attr_accessor :skills
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'name' => :'name',
41
+ :'description' => :'description',
42
+ :'url' => :'url',
43
+ :'version' => :'version',
44
+ :'protocol_version' => :'protocolVersion',
45
+ :'capabilities' => :'capabilities',
46
+ :'default_input_modes' => :'defaultInputModes',
47
+ :'default_output_modes' => :'defaultOutputModes',
48
+ :'skills' => :'skills'
49
+ }
50
+ end
51
+
52
+ # Returns attribute mapping this model knows about
53
+ def self.acceptable_attribute_map
54
+ attribute_map
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ acceptable_attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'name' => :'String',
66
+ :'description' => :'String',
67
+ :'url' => :'String',
68
+ :'version' => :'String',
69
+ :'protocol_version' => :'String',
70
+ :'capabilities' => :'Hash<String, Object>',
71
+ :'default_input_modes' => :'Array<String>',
72
+ :'default_output_modes' => :'Array<String>',
73
+ :'skills' => :'Array<SearchSkill>'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::SearchAgentCard` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ acceptable_attribute_map = self.class.acceptable_attribute_map
92
+ attributes = attributes.each_with_object({}) { |(k, v), h|
93
+ if (!acceptable_attribute_map.key?(k.to_sym))
94
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::SearchAgentCard`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
95
+ end
96
+ h[k.to_sym] = v
97
+ }
98
+
99
+ if attributes.key?(:'name')
100
+ self.name = attributes[:'name']
101
+ end
102
+
103
+ if attributes.key?(:'description')
104
+ self.description = attributes[:'description']
105
+ end
106
+
107
+ if attributes.key?(:'url')
108
+ self.url = attributes[:'url']
109
+ end
110
+
111
+ if attributes.key?(:'version')
112
+ self.version = attributes[:'version']
113
+ end
114
+
115
+ if attributes.key?(:'protocol_version')
116
+ self.protocol_version = attributes[:'protocol_version']
117
+ end
118
+
119
+ if attributes.key?(:'capabilities')
120
+ if (value = attributes[:'capabilities']).is_a?(Hash)
121
+ self.capabilities = value
122
+ end
123
+ end
124
+
125
+ if attributes.key?(:'default_input_modes')
126
+ if (value = attributes[:'default_input_modes']).is_a?(Array)
127
+ self.default_input_modes = value
128
+ end
129
+ end
130
+
131
+ if attributes.key?(:'default_output_modes')
132
+ if (value = attributes[:'default_output_modes']).is_a?(Array)
133
+ self.default_output_modes = value
134
+ end
135
+ end
136
+
137
+ if attributes.key?(:'skills')
138
+ if (value = attributes[:'skills']).is_a?(Array)
139
+ self.skills = value
140
+ end
141
+ end
142
+ end
143
+
144
+ # Show invalid properties with the reasons. Usually used together with valid?
145
+ # @return Array for valid properties with the reasons
146
+ def list_invalid_properties
147
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
148
+ invalid_properties = Array.new
149
+ invalid_properties
150
+ end
151
+
152
+ # Check to see if the all the properties in the model are valid
153
+ # @return true if the model is valid
154
+ def valid?
155
+ warn '[DEPRECATED] the `valid?` method is obsolete'
156
+ true
157
+ end
158
+
159
+ # Checks equality by comparing each attribute.
160
+ # @param [Object] Object to be compared
161
+ def ==(o)
162
+ return true if self.equal?(o)
163
+ self.class == o.class &&
164
+ name == o.name &&
165
+ description == o.description &&
166
+ url == o.url &&
167
+ version == o.version &&
168
+ protocol_version == o.protocol_version &&
169
+ capabilities == o.capabilities &&
170
+ default_input_modes == o.default_input_modes &&
171
+ default_output_modes == o.default_output_modes &&
172
+ skills == o.skills
173
+ end
174
+
175
+ # @see the `==` method
176
+ # @param [Object] Object to be compared
177
+ def eql?(o)
178
+ self == o
179
+ end
180
+
181
+ # Calculates hash code according to all attributes.
182
+ # @return [Integer] Hash code
183
+ def hash
184
+ [name, description, url, version, protocol_version, capabilities, default_input_modes, default_output_modes, skills].hash
185
+ end
186
+
187
+ # Builds the object from hash
188
+ # @param [Hash] attributes Model attributes in the form of hash
189
+ # @return [Object] Returns the model itself
190
+ def self.build_from_hash(attributes)
191
+ return nil unless attributes.is_a?(Hash)
192
+ attributes = attributes.transform_keys(&:to_sym)
193
+ transformed_hash = {}
194
+ openapi_types.each_pair do |key, type|
195
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
196
+ transformed_hash["#{key}"] = nil
197
+ elsif type =~ /\AArray<(.*)>/i
198
+ # check to ensure the input is an array given that the attribute
199
+ # is documented as an array but the input is not
200
+ if attributes[attribute_map[key]].is_a?(Array)
201
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
202
+ end
203
+ elsif !attributes[attribute_map[key]].nil?
204
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
205
+ end
206
+ end
207
+ new(transformed_hash)
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ end
227
+
228
+ end
@@ -1,9 +1,9 @@
1
1
  =begin
2
2
  #Weft API
3
3
 
4
- #API for agent-first payments and discovery.
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.3.0
6
+ The version of the OpenAPI document: 0.5.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.19.0
@@ -14,31 +14,25 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Weft
17
- class AgentStats < ApiModelBase
18
- attr_accessor :total_paid
17
+ # Per-protocol entry points for the agent. Any field may be `null` if the agent does not expose that protocol surface.
18
+ class SearchEndpoints < ApiModelBase
19
+ attr_accessor :a2a
19
20
 
20
- attr_accessor :total_received
21
+ attr_accessor :mcp
21
22
 
22
- attr_accessor :payments_made
23
+ # URL to the agent's OpenAPI document.
24
+ attr_accessor :openapi
23
25
 
24
- attr_accessor :payments_received
25
-
26
- attr_accessor :unique_counterparties
27
-
28
- attr_accessor :first_seen
29
-
30
- attr_accessor :last_active
26
+ # Base URL the `weft_fetch` MCP tool should target for this agent.
27
+ attr_accessor :weft_fetch_target
31
28
 
32
29
  # Attribute mapping from ruby-style variable name to JSON key.
33
30
  def self.attribute_map
34
31
  {
35
- :'total_paid' => :'total_paid',
36
- :'total_received' => :'total_received',
37
- :'payments_made' => :'payments_made',
38
- :'payments_received' => :'payments_received',
39
- :'unique_counterparties' => :'unique_counterparties',
40
- :'first_seen' => :'first_seen',
41
- :'last_active' => :'last_active'
32
+ :'a2a' => :'a2a',
33
+ :'mcp' => :'mcp',
34
+ :'openapi' => :'openapi',
35
+ :'weft_fetch_target' => :'weft_fetch_target'
42
36
  }
43
37
  end
44
38
 
@@ -55,13 +49,10 @@ module Weft
55
49
  # Attribute type mapping.
56
50
  def self.openapi_types
57
51
  {
58
- :'total_paid' => :'Integer',
59
- :'total_received' => :'Integer',
60
- :'payments_made' => :'Integer',
61
- :'payments_received' => :'Integer',
62
- :'unique_counterparties' => :'Integer',
63
- :'first_seen' => :'Time',
64
- :'last_active' => :'Time'
52
+ :'a2a' => :'String',
53
+ :'mcp' => :'String',
54
+ :'openapi' => :'String',
55
+ :'weft_fetch_target' => :'String'
65
56
  }
66
57
  end
67
58
 
@@ -75,44 +66,32 @@ module Weft
75
66
  # @param [Hash] attributes Model attributes in the form of hash
76
67
  def initialize(attributes = {})
77
68
  if (!attributes.is_a?(Hash))
78
- fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::AgentStats` initialize method"
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::SearchEndpoints` initialize method"
79
70
  end
80
71
 
81
72
  # check to see if the attribute exists and convert string to symbol for hash key
82
73
  acceptable_attribute_map = self.class.acceptable_attribute_map
83
74
  attributes = attributes.each_with_object({}) { |(k, v), h|
84
75
  if (!acceptable_attribute_map.key?(k.to_sym))
85
- fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::AgentStats`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::SearchEndpoints`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
86
77
  end
87
78
  h[k.to_sym] = v
88
79
  }
89
80
 
90
- if attributes.key?(:'total_paid')
91
- self.total_paid = attributes[:'total_paid']
92
- end
93
-
94
- if attributes.key?(:'total_received')
95
- self.total_received = attributes[:'total_received']
96
- end
97
-
98
- if attributes.key?(:'payments_made')
99
- self.payments_made = attributes[:'payments_made']
100
- end
101
-
102
- if attributes.key?(:'payments_received')
103
- self.payments_received = attributes[:'payments_received']
81
+ if attributes.key?(:'a2a')
82
+ self.a2a = attributes[:'a2a']
104
83
  end
105
84
 
106
- if attributes.key?(:'unique_counterparties')
107
- self.unique_counterparties = attributes[:'unique_counterparties']
85
+ if attributes.key?(:'mcp')
86
+ self.mcp = attributes[:'mcp']
108
87
  end
109
88
 
110
- if attributes.key?(:'first_seen')
111
- self.first_seen = attributes[:'first_seen']
89
+ if attributes.key?(:'openapi')
90
+ self.openapi = attributes[:'openapi']
112
91
  end
113
92
 
114
- if attributes.key?(:'last_active')
115
- self.last_active = attributes[:'last_active']
93
+ if attributes.key?(:'weft_fetch_target')
94
+ self.weft_fetch_target = attributes[:'weft_fetch_target']
116
95
  end
117
96
  end
118
97
 
@@ -136,13 +115,10 @@ module Weft
136
115
  def ==(o)
137
116
  return true if self.equal?(o)
138
117
  self.class == o.class &&
139
- total_paid == o.total_paid &&
140
- total_received == o.total_received &&
141
- payments_made == o.payments_made &&
142
- payments_received == o.payments_received &&
143
- unique_counterparties == o.unique_counterparties &&
144
- first_seen == o.first_seen &&
145
- last_active == o.last_active
118
+ a2a == o.a2a &&
119
+ mcp == o.mcp &&
120
+ openapi == o.openapi &&
121
+ weft_fetch_target == o.weft_fetch_target
146
122
  end
147
123
 
148
124
  # @see the `==` method
@@ -154,7 +130,7 @@ module Weft
154
130
  # Calculates hash code according to all attributes.
155
131
  # @return [Integer] Hash code
156
132
  def hash
157
- [total_paid, total_received, payments_made, payments_received, unique_counterparties, first_seen, last_active].hash
133
+ [a2a, mcp, openapi, weft_fetch_target].hash
158
134
  end
159
135
 
160
136
  # Builds the object from hash
@@ -0,0 +1,202 @@
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
+ # Bespoke error envelope returned by `/api/v1/search` for `422`, `502`, and `500` responses. It differs from the standard `ErrorResponse` envelope (no nested `code`/`message`/`request_id`); SDK clients should handle both shapes for this endpoint until the controller is migrated to the standard envelope.
18
+ class SearchErrorResponse < ApiModelBase
19
+ # Stable error code.
20
+ attr_accessor :error
21
+
22
+ # Optional context. Shape varies by error code.
23
+ attr_accessor :details
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'error' => :'error',
51
+ :'details' => :'details'
52
+ }
53
+ end
54
+
55
+ # Returns attribute mapping this model knows about
56
+ def self.acceptable_attribute_map
57
+ attribute_map
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ acceptable_attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'error' => :'String',
69
+ :'details' => :'Hash<String, Object>'
70
+ }
71
+ end
72
+
73
+ # List of attributes with nullable: true
74
+ def self.openapi_nullable
75
+ Set.new([
76
+ ])
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::SearchErrorResponse` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ acceptable_attribute_map = self.class.acceptable_attribute_map
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!acceptable_attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::SearchErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'error')
96
+ self.error = attributes[:'error']
97
+ else
98
+ self.error = nil
99
+ end
100
+
101
+ if attributes.key?(:'details')
102
+ if (value = attributes[:'details']).is_a?(Hash)
103
+ self.details = value
104
+ end
105
+ end
106
+ end
107
+
108
+ # Show invalid properties with the reasons. Usually used together with valid?
109
+ # @return Array for valid properties with the reasons
110
+ def list_invalid_properties
111
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
112
+ invalid_properties = Array.new
113
+ if @error.nil?
114
+ invalid_properties.push('invalid value for "error", error cannot be nil.')
115
+ end
116
+
117
+ invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ warn '[DEPRECATED] the `valid?` method is obsolete'
124
+ return false if @error.nil?
125
+ error_validator = EnumAttributeValidator.new('String', ["INVALID_QUERY", "SEARCH_UPSTREAM_ERROR", "SEARCH_BACKEND_MISCONFIGURED"])
126
+ return false unless error_validator.valid?(@error)
127
+ true
128
+ end
129
+
130
+ # Custom attribute writer method checking allowed values (enum).
131
+ # @param [Object] error Object to be assigned
132
+ def error=(error)
133
+ validator = EnumAttributeValidator.new('String', ["INVALID_QUERY", "SEARCH_UPSTREAM_ERROR", "SEARCH_BACKEND_MISCONFIGURED"])
134
+ unless validator.valid?(error)
135
+ fail ArgumentError, "invalid value for \"error\", must be one of #{validator.allowable_values}."
136
+ end
137
+ @error = error
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ error == o.error &&
146
+ details == o.details
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [error, details].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ attributes = attributes.transform_keys(&:to_sym)
167
+ transformed_hash = {}
168
+ openapi_types.each_pair do |key, type|
169
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
170
+ transformed_hash["#{key}"] = nil
171
+ elsif type =~ /\AArray<(.*)>/i
172
+ # check to ensure the input is an array given that the attribute
173
+ # is documented as an array but the input is not
174
+ if attributes[attribute_map[key]].is_a?(Array)
175
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
176
+ end
177
+ elsif !attributes[attribute_map[key]].nil?
178
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
179
+ end
180
+ end
181
+ new(transformed_hash)
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ end
201
+
202
+ end