weft-sdk 0.7.0 → 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 (170) 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 +2 -1
  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 +0 -1
  18. data/docs/Error.md +0 -1
  19. data/docs/ErrorResponse.md +0 -1
  20. data/docs/Fetch403Response.md +0 -1
  21. data/docs/FetchApi.md +10 -7
  22. data/docs/FetchBalanceSnapshot.md +2 -3
  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 +5 -2
  27. data/docs/InsufficientScopeResponse.md +0 -1
  28. data/docs/MeApiKey.md +0 -1
  29. data/docs/MeApiKeyCreator.md +0 -1
  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 +0 -1
  51. data/docs/ResourceEnrollmentResponse.md +0 -1
  52. data/docs/ResourceStats.md +0 -1
  53. data/docs/ResourcesApi.md +2 -3
  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 +3 -4
  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 +6 -6
  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 +54 -4
  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 +4 -4
  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 +2 -2
  105. data/lib/weft/generated/models/fetch_balance_snapshot.rb +5 -5
  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 +83 -5
  110. data/lib/weft/generated/models/insufficient_scope_response.rb +3 -3
  111. data/lib/weft/generated/models/me_api_key.rb +2 -2
  112. data/lib/weft/generated/models/me_api_key_creator.rb +3 -3
  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/{search_agent_card.rb → purchase_artifact.rb} +91 -82
  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/resource_enrollment_request.rb +5 -5
  132. data/lib/weft/generated/models/resource_enrollment_response.rb +2 -2
  133. data/lib/weft/generated/models/resource_stats.rb +2 -2
  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_skill.rb → search_endpoint_price.rb} +76 -112
  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 +367 -31
  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 +5 -5
  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 +57 -19
  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/SearchResponseResultsInner.md +0 -36
  166. data/docs/SearchSkill.md +0 -36
  167. data/docs/SearchSkillEndpoint.md +0 -20
  168. data/lib/weft/generated/models/search_filters.rb +0 -277
  169. data/lib/weft/generated/models/search_ranking.rb +0 -277
  170. data/lib/weft/generated/models/search_response_results_inner.rb +0 -103
@@ -0,0 +1,190 @@
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 PrincipalWallet < ApiModelBase
18
+ attr_accessor :address
19
+
20
+ attr_accessor :network
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'address' => :'address',
26
+ :'network' => :'network'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'address' => :'String',
44
+ :'network' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Weft::PrincipalWallet` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Weft::PrincipalWallet`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'address')
71
+ self.address = attributes[:'address']
72
+ else
73
+ self.address = nil
74
+ end
75
+
76
+ if attributes.key?(:'network')
77
+ self.network = attributes[:'network']
78
+ else
79
+ self.network = nil
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ invalid_properties = Array.new
88
+ if @address.nil?
89
+ invalid_properties.push('invalid value for "address", address cannot be nil.')
90
+ end
91
+
92
+ if @network.nil?
93
+ invalid_properties.push('invalid value for "network", network cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if @address.nil?
104
+ return false if @network.nil?
105
+ true
106
+ end
107
+
108
+ # Custom attribute writer method with validation
109
+ # @param [Object] address Value to be assigned
110
+ def address=(address)
111
+ if address.nil?
112
+ fail ArgumentError, 'address cannot be nil'
113
+ end
114
+
115
+ @address = address
116
+ end
117
+
118
+ # Custom attribute writer method with validation
119
+ # @param [Object] network Value to be assigned
120
+ def network=(network)
121
+ if network.nil?
122
+ fail ArgumentError, 'network cannot be nil'
123
+ end
124
+
125
+ @network = network
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ address == o.address &&
134
+ network == o.network
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [address, network].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[attribute_map[key]].is_a?(Array)
163
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ end
165
+ elsif !attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ end
168
+ end
169
+ new(transformed_hash)
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = self.send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ end
189
+
190
+ end
@@ -1,9 +1,9 @@
1
1
  =begin
2
2
  #Weft API
3
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`.
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
5
 
6
- The version of the OpenAPI document: 0.7.0
6
+ The version of the OpenAPI document: 0.9.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.19.0
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Weft
17
- # Freemium promo credit. v1 returns zero values; once the promo ledger ships (deferred from spec 10), real balances appear here without a shape change.
17
+ # Freemium promo credit. v1 returns zero values; once the promo ledger ships (deferred from spec 10), real balances appear here without a shape change.
18
18
  class PromoBalance < ApiModelBase
19
19
  attr_accessor :balance_usd
20
20
 
@@ -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