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.
- checksums.yaml +4 -4
- data/docs/APIKeysApi.md +1 -2
- data/docs/AccountApi.md +6 -5
- data/docs/AccountDetails.md +2 -1
- data/docs/ApiKey.md +0 -1
- data/docs/ApiKeyCreated.md +0 -1
- data/docs/ApiKeyCreatedResponse.md +0 -1
- data/docs/ApiKeyListResponse.md +0 -1
- data/docs/AuthApi.md +6 -7
- data/docs/AuthResponse.md +0 -1
- data/docs/AuthResponseData.md +0 -1
- data/docs/BalanceApi.md +1 -2
- data/docs/BalanceResponse.md +3 -4
- data/docs/ConfirmRequest.md +0 -1
- data/docs/CreateApiKeyRequest.md +0 -1
- data/docs/DefaultApi.md +0 -1
- data/docs/EnrolledResource.md +0 -1
- data/docs/Error.md +0 -1
- data/docs/ErrorResponse.md +0 -1
- data/docs/Fetch403Response.md +0 -1
- data/docs/FetchApi.md +10 -7
- data/docs/FetchBalanceSnapshot.md +2 -3
- data/docs/FetchErrorResponse.md +0 -1
- data/docs/FetchRequest.md +0 -1
- data/docs/FetchRequestBody.md +0 -1
- data/docs/FetchResponse.md +5 -2
- data/docs/InsufficientScopeResponse.md +0 -1
- data/docs/MeApiKey.md +0 -1
- data/docs/MeApiKeyCreator.md +0 -1
- data/docs/MeResponse.md +1 -2
- data/docs/MeResponseData.md +78 -0
- data/docs/Merchant.md +0 -1
- data/docs/MessageResponse.md +0 -1
- data/docs/MessageResponseData.md +0 -1
- data/docs/Pagination.md +0 -1
- data/docs/PasswordResetRequest.md +0 -1
- data/docs/PasswordUpdateRequest.md +0 -1
- data/docs/Payment.md +0 -3
- data/docs/PaymentListResponse.md +0 -1
- data/docs/PaymentResponse.md +0 -1
- data/docs/PaymentsApi.md +0 -1
- data/docs/PrincipalWallet.md +19 -0
- data/docs/PromoBalance.md +0 -1
- data/docs/Purchase.md +43 -0
- data/docs/PurchaseArtifact.md +23 -0
- data/docs/PurchaseListResponse.md +19 -0
- data/docs/PurchaseResponse.md +17 -0
- data/docs/PurchasesApi.md +148 -0
- data/docs/ResendConfirmationRequest.md +0 -1
- data/docs/ResourceEnrollmentRequest.md +0 -1
- data/docs/ResourceEnrollmentResponse.md +0 -1
- data/docs/ResourceStats.md +0 -1
- data/docs/ResourcesApi.md +2 -3
- data/docs/SearchApi.md +2 -3
- data/docs/SearchCapabilityRef.md +19 -0
- data/docs/SearchEndpointCall.md +23 -0
- data/docs/SearchEndpointHit.md +41 -0
- data/docs/SearchEndpointPrice.md +25 -0
- data/docs/SearchErrorResponse.md +0 -1
- data/docs/SearchFilterSpec.md +23 -0
- data/docs/SearchPaymentOffer.md +31 -0
- data/docs/SearchPriceAtomicFilter.md +25 -0
- data/docs/SearchPriceUsdFilter.md +25 -0
- data/docs/SearchProtocolFilter.md +19 -0
- data/docs/SearchProviderRef.md +21 -0
- data/docs/SearchRequest.md +3 -4
- data/docs/SearchResourceTypeFilter.md +19 -0
- data/docs/SearchResponse.md +35 -8
- data/docs/SearchResponseWarningsInner.md +23 -0
- data/docs/SearchResult.md +8 -21
- data/docs/SignInRequest.md +0 -1
- data/docs/SignUpRequest.md +0 -1
- data/docs/SpendingPolicy.md +0 -1
- data/docs/User.md +0 -1
- data/docs/UserPrincipal.md +33 -0
- data/docs/Wallet.md +3 -4
- data/lib/weft/generated/api/account_api.rb +6 -4
- data/lib/weft/generated/api/api_keys_api.rb +4 -4
- data/lib/weft/generated/api/auth_api.rb +14 -14
- data/lib/weft/generated/api/balance_api.rb +4 -4
- data/lib/weft/generated/api/default_api.rb +2 -2
- data/lib/weft/generated/api/fetch_api.rb +22 -6
- data/lib/weft/generated/api/payments_api.rb +2 -2
- data/lib/weft/generated/api/purchases_api.rb +150 -0
- data/lib/weft/generated/api/resources_api.rb +6 -6
- data/lib/weft/generated/api/search_api.rb +6 -6
- 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 +54 -4
- 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 +2 -2
- 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 +5 -5
- 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/enrolled_resource.rb +4 -4
- data/lib/weft/generated/models/error.rb +3 -3
- data/lib/weft/generated/models/error_response.rb +3 -3
- data/lib/weft/generated/models/fetch403_response.rb +2 -2
- data/lib/weft/generated/models/fetch_balance_snapshot.rb +5 -5
- data/lib/weft/generated/models/fetch_error_response.rb +5 -5
- data/lib/weft/generated/models/fetch_request.rb +5 -5
- data/lib/weft/generated/models/fetch_request_body.rb +2 -2
- data/lib/weft/generated/models/fetch_response.rb +83 -5
- data/lib/weft/generated/models/insufficient_scope_response.rb +3 -3
- data/lib/weft/generated/models/me_api_key.rb +2 -2
- data/lib/weft/generated/models/me_api_key_creator.rb +3 -3
- data/lib/weft/generated/models/me_response.rb +3 -3
- data/lib/weft/generated/models/me_response_data.rb +55 -0
- data/lib/weft/generated/models/merchant.rb +2 -2
- 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 +3 -12
- 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/principal_wallet.rb +190 -0
- data/lib/weft/generated/models/promo_balance.rb +3 -3
- data/lib/weft/generated/models/purchase.rb +427 -0
- data/lib/weft/generated/models/{search_agent_card.rb → purchase_artifact.rb} +91 -82
- data/lib/weft/generated/models/purchase_list_response.rb +192 -0
- data/lib/weft/generated/models/purchase_response.rb +164 -0
- data/lib/weft/generated/models/resend_confirmation_request.rb +2 -2
- data/lib/weft/generated/models/resource_enrollment_request.rb +5 -5
- data/lib/weft/generated/models/resource_enrollment_response.rb +2 -2
- data/lib/weft/generated/models/resource_stats.rb +2 -2
- data/lib/weft/generated/models/{search_skill_endpoint.rb → search_capability_ref.rb} +18 -19
- data/lib/weft/generated/models/search_endpoint_call.rb +179 -0
- data/lib/weft/generated/models/search_endpoint_hit.rb +296 -0
- data/lib/weft/generated/models/{search_skill.rb → search_endpoint_price.rb} +76 -112
- data/lib/weft/generated/models/search_error_response.rb +5 -5
- data/lib/weft/generated/models/search_filter_spec.rb +175 -0
- data/lib/weft/generated/models/{search_pricing.rb → search_payment_offer.rb} +64 -67
- data/lib/weft/generated/models/search_price_atomic_filter.rb +284 -0
- data/lib/weft/generated/models/search_price_usd_filter.rb +294 -0
- data/lib/weft/generated/models/search_protocol_filter.rb +200 -0
- data/lib/weft/generated/models/{search_endpoints.rb → search_provider_ref.rb} +26 -36
- data/lib/weft/generated/models/search_request.rb +36 -27
- data/lib/weft/generated/models/search_resource_type_filter.rb +200 -0
- data/lib/weft/generated/models/search_response.rb +367 -31
- data/lib/weft/generated/models/search_response_warnings_inner.rb +210 -0
- data/lib/weft/generated/models/search_result.rb +68 -220
- 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 +2 -2
- data/lib/weft/generated/models/user.rb +2 -2
- data/lib/weft/generated/models/user_principal.rb +370 -0
- data/lib/weft/generated/models/wallet.rb +5 -5
- data/lib/weft/generated/version.rb +3 -3
- data/lib/weft/generated.rb +10 -4
- data/lib/weft/sdk.rb +1 -1
- metadata +57 -19
- data/docs/SearchAgentCard.md +0 -34
- data/docs/SearchEndpoints.md +0 -24
- data/docs/SearchFilters.md +0 -26
- data/docs/SearchPricing.md +0 -24
- data/docs/SearchRanking.md +0 -26
- data/docs/SearchResponseResultsInner.md +0 -36
- data/docs/SearchSkill.md +0 -36
- data/docs/SearchSkillEndpoint.md +0 -20
- data/lib/weft/generated/models/search_filters.rb +0 -277
- data/lib/weft/generated/models/search_ranking.rb +0 -277
- data/lib/weft/generated/models/search_response_results_inner.rb +0 -103
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bed3008bc143e5170f329a07eab4e6e5137e73f5ea365265ddde9030edd94403
|
|
4
|
+
data.tar.gz: e9a247db0790f417e0368b956dee3658fc691a4ef4afbc4e865b127704b08d38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e732e0ba6c605b2f0bb00a39badfee76bffaa52e5dcaf083d0a84b7d79bcca8f9a71cb80e576bf0147b5f7edb1fbca20443bc1580bff9721c45f009c8908040
|
|
7
|
+
data.tar.gz: e9aec2ac82424e9274f144c20dadf6cf297254900012b732b45b332a56e319060af11cb1bcb7af653c8675a30240809d96db91673578223c5e0d630ae64b2e19
|
data/docs/APIKeysApi.md
CHANGED
|
@@ -27,7 +27,7 @@ Weft.configure do |config|
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
api_instance = Weft::APIKeysApi.new
|
|
30
|
-
create_api_key_request = Weft::CreateApiKeyRequest.new # CreateApiKeyRequest |
|
|
30
|
+
create_api_key_request = Weft::CreateApiKeyRequest.new # CreateApiKeyRequest |
|
|
31
31
|
|
|
32
32
|
begin
|
|
33
33
|
# Create an API key
|
|
@@ -205,4 +205,3 @@ end
|
|
|
205
205
|
|
|
206
206
|
- **Content-Type**: Not defined
|
|
207
207
|
- **Accept**: application/json
|
|
208
|
-
|
data/docs/AccountApi.md
CHANGED
|
@@ -4,14 +4,16 @@ All URIs are relative to *https://weft.network*
|
|
|
4
4
|
|
|
5
5
|
| Method | HTTP request | Description |
|
|
6
6
|
| ------ | ------------ | ----------- |
|
|
7
|
-
| [**get_me**](AccountApi.md#get_me) | **GET** /api/v1/me | Get current
|
|
7
|
+
| [**get_me**](AccountApi.md#get_me) | **GET** /api/v1/me | Get the current credential principal |
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
## get_me
|
|
11
11
|
|
|
12
12
|
> <MeResponse> get_me
|
|
13
13
|
|
|
14
|
-
Get current
|
|
14
|
+
Get the current credential principal
|
|
15
|
+
|
|
16
|
+
Returns the Organization represented by a resource API key, or the User represented by an account API key or OAuth access token. Branch on `data.principal_type`; existing Organization fields remain unchanged.
|
|
15
17
|
|
|
16
18
|
### Examples
|
|
17
19
|
|
|
@@ -27,7 +29,7 @@ end
|
|
|
27
29
|
api_instance = Weft::AccountApi.new
|
|
28
30
|
|
|
29
31
|
begin
|
|
30
|
-
# Get current
|
|
32
|
+
# Get the current credential principal
|
|
31
33
|
result = api_instance.get_me
|
|
32
34
|
p result
|
|
33
35
|
rescue Weft::ApiError => e
|
|
@@ -43,7 +45,7 @@ This returns an Array which contains the response data, status code and headers.
|
|
|
43
45
|
|
|
44
46
|
```ruby
|
|
45
47
|
begin
|
|
46
|
-
# Get current
|
|
48
|
+
# Get the current credential principal
|
|
47
49
|
data, status_code, headers = api_instance.get_me_with_http_info
|
|
48
50
|
p status_code # => 2xx
|
|
49
51
|
p headers # => { ... }
|
|
@@ -69,4 +71,3 @@ This endpoint does not need any parameter.
|
|
|
69
71
|
|
|
70
72
|
- **Content-Type**: Not defined
|
|
71
73
|
- **Accept**: application/json
|
|
72
|
-
|
data/docs/AccountDetails.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| Name | Type | Description | Notes |
|
|
6
6
|
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **principal_type** | **String** | | |
|
|
7
8
|
| **id** | **Integer** | | |
|
|
8
9
|
| **name** | **String** | | |
|
|
9
10
|
| **slug** | **String** | | |
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
require 'weft-sdk'
|
|
17
18
|
|
|
18
19
|
instance = Weft::AccountDetails.new(
|
|
20
|
+
principal_type: null,
|
|
19
21
|
id: null,
|
|
20
22
|
name: null,
|
|
21
23
|
slug: null,
|
|
@@ -23,4 +25,3 @@ instance = Weft::AccountDetails.new(
|
|
|
23
25
|
api_key: null
|
|
24
26
|
)
|
|
25
27
|
```
|
|
26
|
-
|
data/docs/ApiKey.md
CHANGED
data/docs/ApiKeyCreated.md
CHANGED
data/docs/ApiKeyListResponse.md
CHANGED
data/docs/AuthApi.md
CHANGED
|
@@ -25,7 +25,7 @@ require 'time'
|
|
|
25
25
|
require 'weft-sdk'
|
|
26
26
|
|
|
27
27
|
api_instance = Weft::AuthApi.new
|
|
28
|
-
confirm_request = Weft::ConfirmRequest.new({confirmation_token: 'confirmation_token_example'}) # ConfirmRequest |
|
|
28
|
+
confirm_request = Weft::ConfirmRequest.new({confirmation_token: 'confirmation_token_example'}) # ConfirmRequest |
|
|
29
29
|
|
|
30
30
|
begin
|
|
31
31
|
# Confirm an account
|
|
@@ -87,7 +87,7 @@ require 'time'
|
|
|
87
87
|
require 'weft-sdk'
|
|
88
88
|
|
|
89
89
|
api_instance = Weft::AuthApi.new
|
|
90
|
-
password_reset_request = Weft::PasswordResetRequest.new({email: 'email_example'}) # PasswordResetRequest |
|
|
90
|
+
password_reset_request = Weft::PasswordResetRequest.new({email: 'email_example'}) # PasswordResetRequest |
|
|
91
91
|
|
|
92
92
|
begin
|
|
93
93
|
# Request password reset
|
|
@@ -149,7 +149,7 @@ require 'time'
|
|
|
149
149
|
require 'weft-sdk'
|
|
150
150
|
|
|
151
151
|
api_instance = Weft::AuthApi.new
|
|
152
|
-
resend_confirmation_request = Weft::ResendConfirmationRequest.new({email: 'email_example'}) # ResendConfirmationRequest |
|
|
152
|
+
resend_confirmation_request = Weft::ResendConfirmationRequest.new({email: 'email_example'}) # ResendConfirmationRequest |
|
|
153
153
|
|
|
154
154
|
begin
|
|
155
155
|
# Resend confirmation email
|
|
@@ -211,7 +211,7 @@ require 'time'
|
|
|
211
211
|
require 'weft-sdk'
|
|
212
212
|
|
|
213
213
|
api_instance = Weft::AuthApi.new
|
|
214
|
-
sign_in_request = Weft::SignInRequest.new({email: 'email_example', password: 'password_example'}) # SignInRequest |
|
|
214
|
+
sign_in_request = Weft::SignInRequest.new({email: 'email_example', password: 'password_example'}) # SignInRequest |
|
|
215
215
|
|
|
216
216
|
begin
|
|
217
217
|
# Sign in with email and password
|
|
@@ -273,7 +273,7 @@ require 'time'
|
|
|
273
273
|
require 'weft-sdk'
|
|
274
274
|
|
|
275
275
|
api_instance = Weft::AuthApi.new
|
|
276
|
-
sign_up_request = Weft::SignUpRequest.new({email: 'email_example', password: 'password_example', password_confirmation: 'password_confirmation_example'}) # SignUpRequest |
|
|
276
|
+
sign_up_request = Weft::SignUpRequest.new({email: 'email_example', password: 'password_example', password_confirmation: 'password_confirmation_example'}) # SignUpRequest |
|
|
277
277
|
|
|
278
278
|
begin
|
|
279
279
|
# Create an account
|
|
@@ -335,7 +335,7 @@ require 'time'
|
|
|
335
335
|
require 'weft-sdk'
|
|
336
336
|
|
|
337
337
|
api_instance = Weft::AuthApi.new
|
|
338
|
-
password_update_request = Weft::PasswordUpdateRequest.new({reset_password_token: 'reset_password_token_example', password: 'password_example', password_confirmation: 'password_confirmation_example'}) # PasswordUpdateRequest |
|
|
338
|
+
password_update_request = Weft::PasswordUpdateRequest.new({reset_password_token: 'reset_password_token_example', password: 'password_example', password_confirmation: 'password_confirmation_example'}) # PasswordUpdateRequest |
|
|
339
339
|
|
|
340
340
|
begin
|
|
341
341
|
# Update password with reset token
|
|
@@ -382,4 +382,3 @@ No authorization required
|
|
|
382
382
|
|
|
383
383
|
- **Content-Type**: application/json
|
|
384
384
|
- **Accept**: application/json
|
|
385
|
-
|
data/docs/AuthResponse.md
CHANGED
data/docs/AuthResponseData.md
CHANGED
data/docs/BalanceApi.md
CHANGED
|
@@ -13,7 +13,7 @@ All URIs are relative to *https://weft.network*
|
|
|
13
13
|
|
|
14
14
|
Get wallet, spending policy, and current-window spend
|
|
15
15
|
|
|
16
|
-
Read-only snapshot for the buyer behind the bearer token. The response always includes a `promo` block — values are zero in v1 and fill in once the freemium promo ledger ships, without a shape change. `wallet.balance_usdc` is fetched live from Privy; if Privy is unreachable the field returns `\"0.00\"` rather than erroring the whole call. Account-scoped: the bearer must be a buyer-scoped API key.
|
|
16
|
+
Read-only snapshot for the buyer behind the bearer token. The response always includes a `promo` block — values are zero in v1 and fill in once the freemium promo ledger ships, without a shape change. `wallet.balance_usdc` is fetched live from Privy; if Privy is unreachable the field returns `\"0.00\"` rather than erroring the whole call. Account-scoped: the bearer must be a buyer-scoped API key.
|
|
17
17
|
|
|
18
18
|
### Examples
|
|
19
19
|
|
|
@@ -71,4 +71,3 @@ This endpoint does not need any parameter.
|
|
|
71
71
|
|
|
72
72
|
- **Content-Type**: Not defined
|
|
73
73
|
- **Accept**: application/json
|
|
74
|
-
|
data/docs/BalanceResponse.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
| ---- | ---- | ----------- | ----- |
|
|
7
7
|
| **promo** | [**PromoBalance**](PromoBalance.md) | | |
|
|
8
8
|
| **wallet** | [**Wallet**](Wallet.md) | | |
|
|
9
|
-
| **spent_today_usd** | **String** | USD spent in the current calendar day (UTC),
|
|
10
|
-
| **spent_week_usd** | **String** | USD spent in the current calendar week (UTC, Monday start),
|
|
9
|
+
| **spent_today_usd** | **String** | USD spent in the current calendar day (UTC). Exact to the micro-dollar so sub-cent micro-payments survive (\"0.0005\", \"0.42\"), never narrower than two decimals; a zero total renders as \"0.00\". | |
|
|
10
|
+
| **spent_week_usd** | **String** | USD spent in the current calendar week (UTC, Monday start). Exact to the micro-dollar (\"0.0005\", \"3.10\"), never narrower than two decimals; a zero total renders as \"0.00\". | |
|
|
11
11
|
| **policy** | [**SpendingPolicy**](SpendingPolicy.md) | | |
|
|
12
12
|
|
|
13
13
|
## Example
|
|
@@ -18,9 +18,8 @@ require 'weft-sdk'
|
|
|
18
18
|
instance = Weft::BalanceResponse.new(
|
|
19
19
|
promo: null,
|
|
20
20
|
wallet: null,
|
|
21
|
-
spent_today_usd: 0.
|
|
21
|
+
spent_today_usd: 0.0005,
|
|
22
22
|
spent_week_usd: 3.10,
|
|
23
23
|
policy: null
|
|
24
24
|
)
|
|
25
25
|
```
|
|
26
|
-
|
data/docs/ConfirmRequest.md
CHANGED
data/docs/CreateApiKeyRequest.md
CHANGED
data/docs/DefaultApi.md
CHANGED
data/docs/EnrolledResource.md
CHANGED
data/docs/Error.md
CHANGED
data/docs/ErrorResponse.md
CHANGED
data/docs/Fetch403Response.md
CHANGED
data/docs/FetchApi.md
CHANGED
|
@@ -9,11 +9,11 @@ All URIs are relative to *https://weft.network*
|
|
|
9
9
|
|
|
10
10
|
## fetch
|
|
11
11
|
|
|
12
|
-
> <FetchResponse> fetch(fetch_request)
|
|
12
|
+
> <FetchResponse> fetch(fetch_request, opts)
|
|
13
13
|
|
|
14
14
|
Pay-and-fetch any URL (x402 proxy)
|
|
15
15
|
|
|
16
|
-
Universal x402 fetch proxy. The caller provides a target `url`, a hard `max_cost_usd` ceiling, and optional `method` / `body` / `headers`. Weft: 1. Issues the request. 2. On `402 Payment Required`, parses the merchant's challenge. 3. Compares the asking price to `max_cost_usd` and the buyer's policy (`max_tx_usd`, daily/weekly limits). 4. Signs an EIP-3009 transfer from the buyer's wallet. 5. Replays the request with the `X-Payment` header. 6. Streams the upstream artifact back, base64-encoded under `body_base64`, with `paid_usd`, `tx_hash`, and the
|
|
16
|
+
Universal x402 fetch proxy. The caller provides a target `url`, a hard `max_cost_usd` ceiling, and optional `method` / `body` / `headers`. Weft: 1. Issues the request. 2. On `402 Payment Required`, parses the merchant's challenge. 3. Compares the asking price to `max_cost_usd` and the buyer's policy (`max_tx_usd`, daily/weekly limits). 4. Signs an EIP-3009 transfer from the buyer's wallet. 5. Replays the request with the `X-Payment` header. 6. Streams the upstream artifact back, base64-encoded under `body_base64`, with `paid_usd`, `held_usd`, `payment_status`, `tx_hash`, and the merchant's reputation snapshot. `paid_usd` is \"0.00\" until the charge is CONFIRMED settled — a signed-but- unsettled hold (the common case for x402, which settles asynchronously) reports its amount in `held_usd` instead, never in `paid_usd`. Errors are structured with a stable `error` code, and each error response carries the buyer's `policy`, `balance`, and a `dashboard_url` so a CLI can render an actionable message without a second round-trip. Account-scoped: the bearer must be a buyer-scoped API key. **Forwarded headers:** the caller's `headers` are passed through to the upstream, except a denylist of hop-by-hop and Weft-internal headers (`host`, `authorization`, `cookie`, `proxy-authorization`, `x-forwarded-*`, `x-real-ip`, `x-payment`, `connection`, `upgrade`). Up to 32 headers, 4 KB of combined value bytes.
|
|
17
17
|
|
|
18
18
|
### Examples
|
|
19
19
|
|
|
@@ -27,11 +27,14 @@ Weft.configure do |config|
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
api_instance = Weft::FetchApi.new
|
|
30
|
-
fetch_request = Weft::FetchRequest.new({url: 'https://x402.api.agentmail.to/v0/inboxes'}) # FetchRequest |
|
|
30
|
+
fetch_request = Weft::FetchRequest.new({url: 'https://x402.api.agentmail.to/v0/inboxes'}) # FetchRequest |
|
|
31
|
+
opts = {
|
|
32
|
+
idempotency_key: 'idempotency_key_example' # String | Opaque caller-generated retry key. Reusing the same key for the same buyer converges on one paid fetch; keys are hashed and namespaced by buyer before storage. Send this header for every unattended or retryable paid request.
|
|
33
|
+
}
|
|
31
34
|
|
|
32
35
|
begin
|
|
33
36
|
# Pay-and-fetch any URL (x402 proxy)
|
|
34
|
-
result = api_instance.fetch(fetch_request)
|
|
37
|
+
result = api_instance.fetch(fetch_request, opts)
|
|
35
38
|
p result
|
|
36
39
|
rescue Weft::ApiError => e
|
|
37
40
|
puts "Error when calling FetchApi->fetch: #{e}"
|
|
@@ -42,12 +45,12 @@ end
|
|
|
42
45
|
|
|
43
46
|
This returns an Array which contains the response data, status code and headers.
|
|
44
47
|
|
|
45
|
-
> <Array(<FetchResponse>, Integer, Hash)> fetch_with_http_info(fetch_request)
|
|
48
|
+
> <Array(<FetchResponse>, Integer, Hash)> fetch_with_http_info(fetch_request, opts)
|
|
46
49
|
|
|
47
50
|
```ruby
|
|
48
51
|
begin
|
|
49
52
|
# Pay-and-fetch any URL (x402 proxy)
|
|
50
|
-
data, status_code, headers = api_instance.fetch_with_http_info(fetch_request)
|
|
53
|
+
data, status_code, headers = api_instance.fetch_with_http_info(fetch_request, opts)
|
|
51
54
|
p status_code # => 2xx
|
|
52
55
|
p headers # => { ... }
|
|
53
56
|
p data # => <FetchResponse>
|
|
@@ -61,6 +64,7 @@ end
|
|
|
61
64
|
| Name | Type | Description | Notes |
|
|
62
65
|
| ---- | ---- | ----------- | ----- |
|
|
63
66
|
| **fetch_request** | [**FetchRequest**](FetchRequest.md) | | |
|
|
67
|
+
| **idempotency_key** | **String** | Opaque caller-generated retry key. Reusing the same key for the same buyer converges on one paid fetch; keys are hashed and namespaced by buyer before storage. Send this header for every unattended or retryable paid request. | [optional] |
|
|
64
68
|
|
|
65
69
|
### Return type
|
|
66
70
|
|
|
@@ -74,4 +78,3 @@ end
|
|
|
74
78
|
|
|
75
79
|
- **Content-Type**: application/json
|
|
76
80
|
- **Accept**: application/json
|
|
77
|
-
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
| ---- | ---- | ----------- | ----- |
|
|
7
7
|
| **promo_usd** | **String** | | |
|
|
8
8
|
| **wallet_usdc** | **String** | Live Base USDC balance. | |
|
|
9
|
-
| **tempo_usd** | **String** | Aggregated USD of allowlisted Tempo dollar tokens,
|
|
10
|
-
| **total_usd** | **String** | Aggregated USD balance = Base USDC + Tempo dollar tokens,
|
|
9
|
+
| **tempo_usd** | **String** | Aggregated USD of allowlisted Tempo dollar tokens, exact to the micro-dollar. `null` when UNKNOWN (RPC read failed or no token allowlisted for the paired chain) — never \"0.00\" for an unread component. | |
|
|
10
|
+
| **total_usd** | **String** | Aggregated USD balance = Base USDC + Tempo dollar tokens, exact to the micro-dollar. Equals `wallet_usdc` alone when `tempo_usd` is null. Null when the Base USDC provider is unreachable. | |
|
|
11
11
|
| **spent_today_usd** | **String** | | |
|
|
12
12
|
|
|
13
13
|
## Example
|
|
@@ -23,4 +23,3 @@ instance = Weft::FetchBalanceSnapshot.new(
|
|
|
23
23
|
spent_today_usd: 0.42
|
|
24
24
|
)
|
|
25
25
|
```
|
|
26
|
-
|
data/docs/FetchErrorResponse.md
CHANGED
data/docs/FetchRequest.md
CHANGED
data/docs/FetchRequestBody.md
CHANGED
data/docs/FetchResponse.md
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
| **status** | **Integer** | HTTP status returned by the upstream after the paid replay. | |
|
|
8
8
|
| **headers** | **Hash<String, String>** | Response headers from the upstream. | |
|
|
9
9
|
| **body_base64** | **String** | Base64-encoded response body. Empty string for empty bodies. | |
|
|
10
|
-
| **paid_usd** | **String** | USD amount actually settled.
|
|
10
|
+
| **paid_usd** | **String** | USD amount actually settled on-chain. \"0.00\" for free upstreams AND for any charge that hasn't (yet, or ever) settled — a signed hold is not yet spend. See `held_usd` for the nominal amount in that case. Exact to the micro-dollar, minimum two decimals; parse as a decimal rather than string-comparing against a bare zero literal. | |
|
|
11
|
+
| **held_usd** | **String** | The nominal charge amount when `paid_usd` is \"0.00\" — a hold awaiting settlement, or a charge that failed/expired without ever settling. `null` once `paid_usd` reflects the real settlement (or for a free upstream, where nothing was ever charged). Same format as `paid_usd`: exact to the micro-dollar, minimum two decimals. | |
|
|
12
|
+
| **payment_status** | **String** | Agent-facing settlement status. `pending` = signed, no refusal signal yet (settlement may still land, e.g. x402's async facilitator webhook). `declined-pending` = the merchant refused but the authorization isn't provably dead yet. `declined` / `expired` / `reverted` are terminal — the money never moved (or, for `reverted`, moved and then reversed on-chain) and never will for this charge. | |
|
|
11
13
|
| **tx_hash** | **String** | Settlement transaction hash. Null for free upstreams. | |
|
|
12
14
|
| **artifact_id** | **Integer** | Internal artifact identifier if the response was persisted; `null` otherwise. | |
|
|
13
15
|
| **merchant** | [**Merchant**](Merchant.md) | Merchant reputation snapshot. Null for free upstreams. | |
|
|
@@ -22,9 +24,10 @@ instance = Weft::FetchResponse.new(
|
|
|
22
24
|
headers: null,
|
|
23
25
|
body_base64: null,
|
|
24
26
|
paid_usd: 0.002,
|
|
27
|
+
held_usd: 0.002,
|
|
28
|
+
payment_status: pending,
|
|
25
29
|
tx_hash: null,
|
|
26
30
|
artifact_id: null,
|
|
27
31
|
merchant: null
|
|
28
32
|
)
|
|
29
33
|
```
|
|
30
|
-
|
data/docs/MeApiKey.md
CHANGED
data/docs/MeApiKeyCreator.md
CHANGED
data/docs/MeResponse.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| Name | Type | Description | Notes |
|
|
6
6
|
| ---- | ---- | ----------- | ----- |
|
|
7
|
-
| **data** | [**
|
|
7
|
+
| **data** | [**MeResponseData**](MeResponseData.md) | | |
|
|
8
8
|
|
|
9
9
|
## Example
|
|
10
10
|
|
|
@@ -15,4 +15,3 @@ instance = Weft::MeResponse.new(
|
|
|
15
15
|
data: null
|
|
16
16
|
)
|
|
17
17
|
```
|
|
18
|
-
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Weft::MeResponseData
|
|
2
|
+
|
|
3
|
+
## Class instance methods
|
|
4
|
+
|
|
5
|
+
### `openapi_one_of`
|
|
6
|
+
|
|
7
|
+
Returns the list of classes defined in oneOf.
|
|
8
|
+
|
|
9
|
+
#### Example
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'weft-sdk'
|
|
13
|
+
|
|
14
|
+
Weft::MeResponseData.openapi_one_of
|
|
15
|
+
# =>
|
|
16
|
+
# [
|
|
17
|
+
# :'AccountDetails',
|
|
18
|
+
# :'UserPrincipal'
|
|
19
|
+
# ]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### `openapi_discriminator_name`
|
|
23
|
+
|
|
24
|
+
Returns the discriminator's property name.
|
|
25
|
+
|
|
26
|
+
#### Example
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
require 'weft-sdk'
|
|
30
|
+
|
|
31
|
+
Weft::MeResponseData.openapi_discriminator_name
|
|
32
|
+
# => :'principal_type'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `openapi_discriminator_name`
|
|
36
|
+
|
|
37
|
+
Returns the discriminator's mapping.
|
|
38
|
+
|
|
39
|
+
#### Example
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
require 'weft-sdk'
|
|
43
|
+
|
|
44
|
+
Weft::MeResponseData.openapi_discriminator_mapping
|
|
45
|
+
# =>
|
|
46
|
+
# {
|
|
47
|
+
# :'organization' => :'AccountDetails',
|
|
48
|
+
# :'user' => :'UserPrincipal'
|
|
49
|
+
# }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### build
|
|
53
|
+
|
|
54
|
+
Find the appropriate object from the `openapi_one_of` list and casts the data into it.
|
|
55
|
+
|
|
56
|
+
#### Example
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
require 'weft-sdk'
|
|
60
|
+
|
|
61
|
+
Weft::MeResponseData.build(data)
|
|
62
|
+
# => #<AccountDetails:0x00007fdd4aab02a0>
|
|
63
|
+
|
|
64
|
+
Weft::MeResponseData.build(data_that_doesnt_match)
|
|
65
|
+
# => nil
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Parameters
|
|
69
|
+
|
|
70
|
+
| Name | Type | Description |
|
|
71
|
+
| ---- | ---- | ----------- |
|
|
72
|
+
| **data** | **Mixed** | data to be matched against the list of oneOf items |
|
|
73
|
+
|
|
74
|
+
#### Return type
|
|
75
|
+
|
|
76
|
+
- `AccountDetails`
|
|
77
|
+
- `UserPrincipal`
|
|
78
|
+
- `nil` (if no type matches)
|
data/docs/Merchant.md
CHANGED
data/docs/MessageResponse.md
CHANGED
data/docs/MessageResponseData.md
CHANGED
data/docs/Pagination.md
CHANGED
data/docs/Payment.md
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
| **network** | **String** | CAIP-2 chain identifier | |
|
|
15
15
|
| **resource_url** | **String** | | [optional] |
|
|
16
16
|
| **resource_host** | **String** | | [optional] |
|
|
17
|
-
| **fee_amount** | **Integer** | | [optional] |
|
|
18
17
|
| **settlement_latency_ms** | **Integer** | | [optional] |
|
|
19
18
|
| **settled_at** | **Time** | | |
|
|
20
19
|
| **api_key_name** | **String** | | |
|
|
@@ -35,10 +34,8 @@ instance = Weft::Payment.new(
|
|
|
35
34
|
network: null,
|
|
36
35
|
resource_url: null,
|
|
37
36
|
resource_host: null,
|
|
38
|
-
fee_amount: null,
|
|
39
37
|
settlement_latency_ms: null,
|
|
40
38
|
settled_at: null,
|
|
41
39
|
api_key_name: null
|
|
42
40
|
)
|
|
43
41
|
```
|
|
44
|
-
|
data/docs/PaymentListResponse.md
CHANGED
data/docs/PaymentResponse.md
CHANGED
data/docs/PaymentsApi.md
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Weft::PrincipalWallet
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **address** | **String** | | |
|
|
8
|
+
| **network** | **String** | | |
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
require 'weft-sdk'
|
|
14
|
+
|
|
15
|
+
instance = Weft::PrincipalWallet.new(
|
|
16
|
+
address: null,
|
|
17
|
+
network: null
|
|
18
|
+
)
|
|
19
|
+
```
|
data/docs/PromoBalance.md
CHANGED
data/docs/Purchase.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Weft::Purchase
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **id** | **Integer** | | |
|
|
8
|
+
| **status** | **String** | | |
|
|
9
|
+
| **amount_usd** | **String** | Exact decimal USD amount with up to six fractional digits. | |
|
|
10
|
+
| **recipient_address** | **String** | | |
|
|
11
|
+
| **network** | **String** | | |
|
|
12
|
+
| **protocol** | **String** | | |
|
|
13
|
+
| **context** | **String** | | |
|
|
14
|
+
| **tx_hash** | **String** | | |
|
|
15
|
+
| **reject_reason** | **String** | | |
|
|
16
|
+
| **failure_reason** | **String** | | |
|
|
17
|
+
| **idempotency_key** | **String** | | |
|
|
18
|
+
| **signed_at** | **Time** | | |
|
|
19
|
+
| **settled_at** | **Time** | | |
|
|
20
|
+
| **artifact** | [**PurchaseArtifact**](PurchaseArtifact.md) | | |
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
require 'weft-sdk'
|
|
26
|
+
|
|
27
|
+
instance = Weft::Purchase.new(
|
|
28
|
+
id: null,
|
|
29
|
+
status: null,
|
|
30
|
+
amount_usd: null,
|
|
31
|
+
recipient_address: null,
|
|
32
|
+
network: null,
|
|
33
|
+
protocol: null,
|
|
34
|
+
context: null,
|
|
35
|
+
tx_hash: null,
|
|
36
|
+
reject_reason: null,
|
|
37
|
+
failure_reason: null,
|
|
38
|
+
idempotency_key: null,
|
|
39
|
+
signed_at: null,
|
|
40
|
+
settled_at: null,
|
|
41
|
+
artifact: null
|
|
42
|
+
)
|
|
43
|
+
```
|