diff --git a/.gitignore b/.gitignore index d3af99ed..47d65d5d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +/funcs +/core.* +/__tests__ /esm /dist /.tshy diff --git a/.npmignore b/.npmignore index 3ef05d12..06cd8abf 100644 --- a/.npmignore +++ b/.npmignore @@ -7,3 +7,4 @@ /cjs /.tshy /.tshy-* +/__tests__ diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 9795d763..b3623823 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 79fa0df9-852a-493c-b998-1d82654b5f18 management: - docChecksum: 8c2776c2cbcdc065c8bb4d1442f50ef5 - docVersion: 3.2.0 - speakeasyVersion: 1.344.0 - generationVersion: 2.376.0 - releaseVersion: 0.19.0 - configChecksum: 2698678ca33723eee1d35dfef136b3af + docChecksum: 854d678d5e30ebc1211187f4d0e7b3ba + docVersion: 3.2.1 + speakeasyVersion: 1.392.1 + generationVersion: 2.411.9 + releaseVersion: 0.20.0 + configChecksum: 7516b47b7e28f18cd0054673796d9e13 repoURL: https://github.com/BoltApp/Bolt-Typescript-SDK.git repoSubDirectory: . installationURL: https://github.com/BoltApp/Bolt-Typescript-SDK @@ -14,11 +14,12 @@ management: features: typescript: additionalDependencies: 0.1.0 - core: 3.11.7 + core: 3.16.4 defaultEnabledRetries: 0.1.0 - errorUnions: 0.1.0 + envVarSecurityUsage: 0.1.1 + errorUnions: 0.1.1 flattening: 2.81.1 - globalSecurity: 2.82.9 + globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalServerURLs: 2.82.4 groups: 2.81.2 @@ -29,271 +30,830 @@ features: responseFormat: 0.2.3 retries: 2.83.0 sdkHooks: 0.1.0 - unions: 2.85.6 + unions: 2.85.7 generatedFiles: - - src/sdk/account.ts - - src/sdk/loggedin.ts - - src/sdk/guest.ts - - src/sdk/payments.ts - - src/sdk/orders.ts - - src/sdk/oauth.ts - - src/sdk/testing.ts - - src/sdk/sdk.ts - .eslintrc.cjs + - .gitattributes - .npmignore + - CONTRIBUTING.md + - FUNCTIONS.md - RUNTIMES.md + - USAGE.md + - docs/lib/utils/retryconfig.md + - docs/models/components/account.md + - docs/models/components/accounttestcreationdataoutput.md + - docs/models/components/accounttestphonedata.md + - docs/models/components/action.md + - docs/models/components/addresslisting.md + - docs/models/components/addressreference.md + - docs/models/components/addressreferenceexplicit.md + - docs/models/components/addressreferenceexplicittag.md + - docs/models/components/addressreferenceid.md + - docs/models/components/addressreferenceidtag.md + - docs/models/components/amount.md + - docs/models/components/authorizationcoderequest.md + - docs/models/components/cart.md + - docs/models/components/cartdiscount.md + - docs/models/components/cartitem.md + - docs/models/components/cartshipment.md + - docs/models/components/countrycode.md + - docs/models/components/creditcardnetwork.md + - docs/models/components/currency.md + - docs/models/components/dottag.md + - docs/models/components/emailstate.md + - docs/models/components/getaccesstokenresponse.md + - docs/models/components/granttype.md + - docs/models/components/guestpaymentinitializerequest.md + - docs/models/components/order.md + - docs/models/components/orderresponse.md + - docs/models/components/paymentactionrequest.md + - docs/models/components/paymentactionrequesttag.md + - docs/models/components/paymentinitializerequest.md + - docs/models/components/paymentmethod.md + - docs/models/components/paymentmethodaffirmoutput.md + - docs/models/components/paymentmethodaffirmtag.md + - docs/models/components/paymentmethodafterpayoutput.md + - docs/models/components/paymentmethodafterpaytag.md + - docs/models/components/paymentmethodcreditcard.md + - docs/models/components/paymentmethodextended.md + - docs/models/components/paymentmethodklarnaaccountoutput.md + - docs/models/components/paymentmethodklarnaaccounttag.md + - docs/models/components/paymentmethodklarnaoutput.md + - docs/models/components/paymentmethodklarnapaynowoutput.md + - docs/models/components/paymentmethodklarnapaynowtag.md + - docs/models/components/paymentmethodklarnatag.md + - docs/models/components/paymentmethodpaypaloutput.md + - docs/models/components/paymentmethodpaypaltag.md + - docs/models/components/paymentmethodreference.md + - docs/models/components/paymentmethodreferencetag.md + - docs/models/components/paymentresponse.md + - docs/models/components/paymentresponsefinalized.md + - docs/models/components/paymentresponsefinalizedtag.md + - docs/models/components/paymentresponsepending.md + - docs/models/components/paymentresponsependingstatus.md + - docs/models/components/paymentresponsependingtag.md + - docs/models/components/phonestate.md + - docs/models/components/profile.md + - docs/models/components/profilecreationdata.md + - docs/models/components/refreshtokenrequest.md + - docs/models/components/refreshtokenrequestgranttype.md + - docs/models/components/refreshtokenrequestscope.md + - docs/models/components/scope.md + - docs/models/components/security.md + - docs/models/components/status.md + - docs/models/components/testcreditcard.md + - docs/models/components/tokenrequest.md + - docs/models/components/transaction.md + - docs/models/components/transactionauthorization.md + - docs/models/errors/accountaddpaymentmethodresponsebody.md + - docs/models/errors/accountaddresscreateresponsebody.md + - docs/models/errors/accountaddressdeleteresponsebody.md + - docs/models/errors/accountaddresseditresponsebody.md + - docs/models/errors/accountgetresponsebody.md + - docs/models/errors/accountpaymentmethoddeleteresponsebody.md + - docs/models/errors/carterror.md + - docs/models/errors/creditcarderror.md + - docs/models/errors/dottag.md + - docs/models/errors/errort.md + - docs/models/errors/fielderror.md + - docs/models/errors/guestpaymentsactionresponsebody.md + - docs/models/errors/guestpaymentsinitializeresponsebody.md + - docs/models/errors/oauthgettokenresponsebody.md + - docs/models/errors/orderscreateresponsebody.md + - docs/models/errors/paymentsactionresponsebody.md + - docs/models/errors/paymentsinitializeresponsebody.md + - docs/models/errors/schemascarterrortag.md + - docs/models/errors/schemascreditcarderrortag.md + - docs/models/errors/schemastag.md + - docs/models/errors/testingaccountcreateresponsebody.md + - docs/models/errors/testingaccountphonegetresponsebody.md + - docs/models/errors/testingcreditcardgetresponsebody.md + - docs/models/operations/accountaddpaymentmethodrequest.md + - docs/models/operations/accountaddpaymentmethodresponse.md + - docs/models/operations/accountaddresscreaterequest.md + - docs/models/operations/accountaddresscreateresponse.md + - docs/models/operations/accountaddressdeleterequest.md + - docs/models/operations/accountaddressdeleteresponse.md + - docs/models/operations/accountaddresseditrequest.md + - docs/models/operations/accountaddresseditresponse.md + - docs/models/operations/accountgetrequest.md + - docs/models/operations/accountgetresponse.md + - docs/models/operations/accountpaymentmethoddeleterequest.md + - docs/models/operations/accountpaymentmethoddeleteresponse.md + - docs/models/operations/guestpaymentsactionrequest.md + - docs/models/operations/guestpaymentsactionresponse.md + - docs/models/operations/guestpaymentsactionsecurity.md + - docs/models/operations/guestpaymentsinitializerequest.md + - docs/models/operations/guestpaymentsinitializeresponse.md + - docs/models/operations/guestpaymentsinitializesecurity.md + - docs/models/operations/oauthgettokenrequest.md + - docs/models/operations/oauthgettokenresponse.md + - docs/models/operations/orderscreaterequest.md + - docs/models/operations/orderscreateresponse.md + - docs/models/operations/orderscreatesecurity.md + - docs/models/operations/paymentsactionrequest.md + - docs/models/operations/paymentsactionresponse.md + - docs/models/operations/paymentsinitializerequest.md + - docs/models/operations/paymentsinitializeresponse.md + - docs/models/operations/testingaccountcreaterequest.md + - docs/models/operations/testingaccountcreateresponse.md + - docs/models/operations/testingaccountcreatesecurity.md + - docs/models/operations/testingaccountphonegetrequest.md + - docs/models/operations/testingaccountphonegetresponse.md + - docs/models/operations/testingaccountphonegetsecurity.md + - docs/models/operations/testingcreditcardgetrequestbody.md + - docs/models/operations/testingcreditcardgetresponse.md + - docs/models/operations/testingcreditcardgetsecurity.md + - docs/models/operations/type.md + - docs/sdks/account/README.md + - docs/sdks/bolttypescriptsdk/README.md + - docs/sdks/guest/README.md + - docs/sdks/loggedin/README.md + - docs/sdks/oauth/README.md + - docs/sdks/orders/README.md + - docs/sdks/payments/README.md + - docs/sdks/testing/README.md - jsr.json - package.json + - src/core.ts + - src/funcs/accountAddAddress.ts + - src/funcs/accountAddPaymentMethod.ts + - src/funcs/accountDeleteAddress.ts + - src/funcs/accountDeletePaymentMethod.ts + - src/funcs/accountGetDetails.ts + - src/funcs/accountUpdateAddress.ts + - src/funcs/oAuthGetToken.ts + - src/funcs/ordersOrdersCreate.ts + - src/funcs/paymentsGuestInitialize.ts + - src/funcs/paymentsGuestPerformAction.ts + - src/funcs/paymentsLoggedInInitialize.ts + - src/funcs/paymentsLoggedInPerformAction.ts + - src/funcs/testingCreateAccount.ts + - src/funcs/testingGetCreditCard.ts + - src/funcs/testingTestingAccountPhoneGet.ts + - src/hooks/hooks.ts + - src/hooks/index.ts + - src/hooks/types.ts - src/index.ts - src/lib/base64.ts - src/lib/config.ts + - src/lib/dlv.ts - src/lib/encodings.ts + - src/lib/files.ts - src/lib/http.ts - src/lib/is-plain-object.ts + - src/lib/logger.ts + - src/lib/matchers.ts - src/lib/primitives.ts - src/lib/retries.ts - src/lib/schemas.ts - src/lib/sdks.ts - src/lib/security.ts - src/lib/url.ts - - src/sdk/index.ts - - src/models/errors/sdkerror.ts - - src/models/errors/sdkvalidationerror.ts - - src/types/blobs.ts - - src/types/enums.ts - - src/types/index.ts - - src/types/operations.ts - - src/types/rfcdate.ts - - tsconfig.json - - src/models/operations/accountget.ts - - src/models/operations/accountaddresscreate.ts - - src/models/operations/accountaddressedit.ts - - src/models/operations/accountaddressdelete.ts - - src/models/operations/accountaddpaymentmethod.ts - - src/models/operations/accountpaymentmethoddelete.ts - - src/models/operations/paymentsinitialize.ts - - src/models/operations/paymentsaction.ts - - src/models/operations/guestpaymentsinitialize.ts - - src/models/operations/guestpaymentsaction.ts - - src/models/operations/orderscreate.ts - - src/models/operations/oauthgettoken.ts - - src/models/operations/testingaccountcreate.ts - - src/models/operations/testingaccountphoneget.ts - - src/models/operations/testingcreditcardget.ts - src/models/components/account.ts - - src/models/components/profile.ts - - src/models/components/paymentmethod.ts - - src/models/components/paymentmethodcreditcard.ts - - src/models/components/creditcardnetwork.ts + - src/models/components/accounttestcreationdataoutput.ts + - src/models/components/accounttestphonedata.ts + - src/models/components/addresslisting.ts + - src/models/components/addresslistinginput.ts - src/models/components/addressreference.ts - - src/models/components/addressreferenceid.ts - src/models/components/addressreferenceexplicit.ts + - src/models/components/addressreferenceid.ts + - src/models/components/addressreferenceinput.ts + - src/models/components/amount.ts + - src/models/components/authorizationcoderequest.ts + - src/models/components/cart.ts + - src/models/components/cartdiscount.ts + - src/models/components/cartitem.ts + - src/models/components/cartshipment.ts - src/models/components/countrycode.ts - - src/models/components/paymentmethodpaypaloutput.ts + - src/models/components/creditcardnetwork.ts + - src/models/components/getaccesstokenresponse.ts + - src/models/components/guestpaymentinitializerequest.ts + - src/models/components/index.ts + - src/models/components/order.ts + - src/models/components/orderresponse.ts + - src/models/components/paymentactionrequest.ts + - src/models/components/paymentinitializerequest.ts + - src/models/components/paymentmethod.ts - src/models/components/paymentmethodaffirmoutput.ts - src/models/components/paymentmethodafterpayoutput.ts - - src/models/components/paymentmethodklarnaoutput.ts + - src/models/components/paymentmethodcreditcard.ts + - src/models/components/paymentmethodextended.ts + - src/models/components/paymentmethodinput.ts - src/models/components/paymentmethodklarnaaccountoutput.ts + - src/models/components/paymentmethodklarnaoutput.ts - src/models/components/paymentmethodklarnapaynowoutput.ts - - src/models/components/addresslisting.ts - - src/models/components/addresslistinginput.ts - - src/models/components/paymentmethodinput.ts - - src/models/components/addressreferenceinput.ts + - src/models/components/paymentmethodpaypaloutput.ts + - src/models/components/paymentmethodreference.ts - src/models/components/paymentresponse.ts - src/models/components/paymentresponsefinalized.ts - - src/models/components/transaction.ts - src/models/components/paymentresponsepending.ts - - src/models/components/paymentinitializerequest.ts - - src/models/components/paymentmethodextended.ts - - src/models/components/paymentmethodreference.ts - - src/models/components/cart.ts - - src/models/components/amount.ts - - src/models/components/cartitem.ts - - src/models/components/cartdiscount.ts - - src/models/components/cartshipment.ts - - src/models/components/paymentactionrequest.ts - - src/models/components/guestpaymentinitializerequest.ts + - src/models/components/profile.ts - src/models/components/profilecreationdata.ts - - src/models/components/orderresponse.ts - - src/models/components/order.ts - - src/models/components/getaccesstokenresponse.ts - - src/models/components/tokenrequest.ts - - src/models/components/authorizationcoderequest.ts - src/models/components/refreshtokenrequest.ts - - src/models/components/accounttestcreationdataoutput.ts - - src/models/components/accounttestphonedata.ts - - src/models/components/testcreditcard.ts - src/models/components/security.ts - - src/models/errors/accountget.ts - - src/models/errors/error.ts - - src/models/errors/fielderror.ts + - src/models/components/testcreditcard.ts + - src/models/components/tokenrequest.ts + - src/models/components/transaction.ts + - src/models/components/transactionauthorization.ts + - src/models/errors/accountaddpaymentmethod.ts - src/models/errors/accountaddresscreate.ts - - src/models/errors/accountaddressedit.ts - src/models/errors/accountaddressdelete.ts - - src/models/errors/accountaddpaymentmethod.ts - - src/models/errors/creditcarderror.ts + - src/models/errors/accountaddressedit.ts + - src/models/errors/accountget.ts - src/models/errors/accountpaymentmethoddelete.ts - - src/models/errors/paymentsinitialize.ts - src/models/errors/carterror.ts - - src/models/errors/paymentsaction.ts - - src/models/errors/guestpaymentsinitialize.ts + - src/models/errors/creditcarderror.ts + - src/models/errors/error.ts + - src/models/errors/fielderror.ts - src/models/errors/guestpaymentsaction.ts - - src/models/errors/orderscreate.ts + - src/models/errors/guestpaymentsinitialize.ts + - src/models/errors/httpclienterrors.ts + - src/models/errors/index.ts - src/models/errors/oauthgettoken.ts + - src/models/errors/orderscreate.ts + - src/models/errors/paymentsaction.ts + - src/models/errors/paymentsinitialize.ts + - src/models/errors/sdkerror.ts + - src/models/errors/sdkvalidationerror.ts - src/models/errors/testingaccountcreate.ts - src/models/errors/testingaccountphoneget.ts - src/models/errors/testingcreditcardget.ts - - src/models/errors/index.ts + - src/models/operations/accountaddpaymentmethod.ts + - src/models/operations/accountaddresscreate.ts + - src/models/operations/accountaddressdelete.ts + - src/models/operations/accountaddressedit.ts + - src/models/operations/accountget.ts + - src/models/operations/accountpaymentmethoddelete.ts + - src/models/operations/guestpaymentsaction.ts + - src/models/operations/guestpaymentsinitialize.ts - src/models/operations/index.ts - - src/models/components/index.ts - - docs/models/operations/accountgetrequest.md - - docs/models/operations/accountgetresponse.md - - docs/models/operations/accountaddresscreaterequest.md - - docs/models/operations/accountaddresscreateresponse.md - - docs/models/operations/accountaddresseditrequest.md - - docs/models/operations/accountaddresseditresponse.md - - docs/models/operations/accountaddressdeleterequest.md - - docs/models/operations/accountaddressdeleteresponse.md - - docs/models/operations/accountaddpaymentmethodrequest.md - - docs/models/operations/accountaddpaymentmethodresponse.md - - docs/models/operations/accountpaymentmethoddeleterequest.md - - docs/models/operations/accountpaymentmethoddeleteresponse.md - - docs/models/operations/paymentsinitializerequest.md - - docs/models/operations/paymentsinitializeresponse.md - - docs/models/operations/paymentsactionrequest.md - - docs/models/operations/paymentsactionresponse.md - - docs/models/operations/guestpaymentsinitializesecurity.md - - docs/models/operations/guestpaymentsinitializerequest.md - - docs/models/operations/guestpaymentsinitializeresponse.md - - docs/models/operations/guestpaymentsactionsecurity.md - - docs/models/operations/guestpaymentsactionrequest.md - - docs/models/operations/guestpaymentsactionresponse.md - - docs/models/operations/orderscreatesecurity.md - - docs/models/operations/orderscreaterequest.md - - docs/models/operations/orderscreateresponse.md - - docs/models/operations/oauthgettokenrequest.md - - docs/models/operations/oauthgettokenresponse.md - - docs/models/operations/testingaccountcreatesecurity.md - - docs/models/operations/testingaccountcreaterequest.md - - docs/models/operations/testingaccountcreateresponse.md - - docs/models/operations/testingaccountphonegetsecurity.md - - docs/models/operations/testingaccountphonegetrequest.md - - docs/models/operations/testingaccountphonegetresponse.md - - docs/models/operations/testingcreditcardgetsecurity.md - - docs/models/operations/type.md - - docs/models/operations/testingcreditcardgetrequestbody.md - - docs/models/operations/testingcreditcardgetresponse.md - - docs/models/components/account.md - - docs/models/components/profile.md - - docs/models/components/paymentmethod.md - - docs/models/components/dottag.md - - docs/models/components/paymentmethodcreditcard.md - - docs/models/components/creditcardnetwork.md - - docs/models/components/addressreference.md - - docs/models/components/addressreferenceidtag.md - - docs/models/components/addressreferenceid.md - - docs/models/components/addressreferenceexplicittag.md - - docs/models/components/addressreferenceexplicit.md - - docs/models/components/countrycode.md - - docs/models/components/paymentmethodpaypaltag.md - - docs/models/components/paymentmethodpaypaloutput.md - - docs/models/components/paymentmethodaffirmtag.md - - docs/models/components/paymentmethodaffirmoutput.md - - docs/models/components/paymentmethodafterpaytag.md - - docs/models/components/paymentmethodafterpayoutput.md - - docs/models/components/paymentmethodklarnatag.md - - docs/models/components/paymentmethodklarnaoutput.md - - docs/models/components/paymentmethodklarnaaccounttag.md - - docs/models/components/paymentmethodklarnaaccountoutput.md - - docs/models/components/paymentmethodklarnapaynowtag.md - - docs/models/components/paymentmethodklarnapaynowoutput.md - - docs/models/components/addresslisting.md - - docs/models/components/addresslistinginput.md - - docs/models/components/paymentmethodinput.md - - docs/models/components/paymentmethodcreditcardinput.md - - docs/models/components/addressreferenceinput.md - - docs/models/components/addressreferenceexplicitinput.md - - docs/models/components/paymentmethodpaypal.md - - docs/models/components/paymentmethodaffirm.md - - docs/models/components/paymentmethodafterpay.md - - docs/models/components/paymentmethodklarna.md - - docs/models/components/paymentmethodklarnaaccount.md - - docs/models/components/paymentmethodklarnapaynow.md - - docs/models/components/paymentresponse.md - - docs/models/components/paymentresponsefinalizedtag.md - - docs/models/components/status.md - - docs/models/components/paymentresponsefinalized.md - - docs/models/components/transaction.md - - docs/models/components/paymentresponsependingtag.md - - docs/models/components/paymentresponsependingstatus.md - - docs/models/components/action.md - - docs/models/components/paymentresponsepending.md - - docs/models/components/paymentinitializerequest.md - - docs/models/components/paymentmethodextended.md - - docs/models/components/paymentmethodreferencetag.md - - docs/models/components/paymentmethodreference.md - - docs/models/components/cart.md - - docs/models/components/currency.md - - docs/models/components/amount.md - - docs/models/components/cartitem.md - - docs/models/components/cartdiscount.md - - docs/models/components/cartshipment.md - - docs/models/components/paymentactionrequesttag.md - - docs/models/components/paymentactionrequest.md - - docs/models/components/guestpaymentinitializerequest.md - - docs/models/components/profilecreationdata.md - - docs/models/components/orderresponse.md - - docs/models/components/order.md - - docs/models/components/getaccesstokenresponse.md - - docs/models/components/tokenrequest.md - - docs/models/components/granttype.md - - docs/models/components/scope.md - - docs/models/components/authorizationcoderequest.md - - docs/models/components/refreshtokenrequestgranttype.md - - docs/models/components/refreshtokenrequestscope.md - - docs/models/components/refreshtokenrequest.md - - docs/models/components/emailstate.md - - docs/models/components/phonestate.md - - docs/models/components/accounttestcreationdataoutput.md - - docs/models/components/accounttestcreationdata.md - - docs/models/components/accounttestphonedata.md - - docs/models/components/testcreditcard.md - - docs/models/components/security.md - - docs/models/errors/accountgetresponsebody.md - - docs/models/errors/dottag.md - - docs/models/errors/errort.md - - docs/models/errors/schemastag.md - - docs/models/errors/fielderror.md - - docs/models/errors/accountaddresscreateresponsebody.md - - docs/models/errors/accountaddresseditresponsebody.md - - docs/models/errors/accountaddressdeleteresponsebody.md - - docs/models/errors/accountaddpaymentmethodresponsebody.md - - docs/models/errors/schemascreditcarderrortag.md - - docs/models/errors/creditcarderror.md - - docs/models/errors/accountpaymentmethoddeleteresponsebody.md - - docs/models/errors/paymentsinitializeresponsebody.md - - docs/models/errors/schemascarterrortag.md - - docs/models/errors/carterror.md - - docs/models/errors/paymentsactionresponsebody.md - - docs/models/errors/guestpaymentsinitializeresponsebody.md - - docs/models/errors/guestpaymentsactionresponsebody.md - - docs/models/errors/orderscreateresponsebody.md - - docs/models/errors/oauthgettokenresponsebody.md - - docs/models/errors/testingaccountcreateresponsebody.md - - docs/models/errors/testingaccountphonegetresponsebody.md - - docs/models/errors/testingcreditcardgetresponsebody.md - - docs/sdks/bolttypescriptsdk/README.md - - docs/lib/utils/retryconfig.md - - docs/sdks/account/README.md - - docs/sdks/payments/README.md - - docs/sdks/loggedin/README.md - - docs/sdks/guest/README.md - - docs/sdks/orders/README.md - - docs/sdks/oauth/README.md - - docs/sdks/testing/README.md - - USAGE.md - - .gitattributes - - src/hooks/hooks.ts - - src/hooks/types.ts - - src/hooks/index.ts - - CONTRIBUTING.md + - src/models/operations/oauthgettoken.ts + - src/models/operations/orderscreate.ts + - src/models/operations/paymentsaction.ts + - src/models/operations/paymentsinitialize.ts + - src/models/operations/testingaccountcreate.ts + - src/models/operations/testingaccountphoneget.ts + - src/models/operations/testingcreditcardget.ts + - src/sdk/account.ts + - src/sdk/guest.ts + - src/sdk/index.ts + - src/sdk/loggedin.ts + - src/sdk/oauth.ts + - src/sdk/orders.ts + - src/sdk/payments.ts + - src/sdk/sdk.ts + - src/sdk/testing.ts + - src/types/blobs.ts + - src/types/constdatetime.ts + - src/types/enums.ts + - src/types/fp.ts + - src/types/index.ts + - src/types/operations.ts + - src/types/rfcdate.ts + - src/types/streams.ts + - tsconfig.json +examples: + accountGet: + speakeasy-default-account-get: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + responses: + "200": + application/json: {"addresses": [], "payment_methods": [], "profile": {"first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + accountAddressCreate: + address-all-fields: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + address-some-fields: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Jean", "last_name": "Blanc", "company": "ACME Corporation", "street_address1": "77 Rue Frédéric Chopin", "street_address2": "c/o Shipping Department", "locality": "Versailles", "postal_code": "78000", "region": "CA", "country_code": "FR", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + missing-input: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + invalid-input: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + invalid-postal-code: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + invalid-region: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + accountAddressEdit: + address-all-fields: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + address-some-fields: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Jean", "last_name": "Blanc", "company": "ACME Corporation", "street_address1": "77 Rue Frédéric Chopin", "street_address2": "c/o Shipping Department", "locality": "Versailles", "postal_code": "78000", "region": "CA", "country_code": "FR", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + missing-input: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + invalid-input: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + invalid-postal-code: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + invalid-region: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"} + responses: + "200": + application/json: {"id": "D4g3h5tBuVYK9", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199", "is_default": true} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + accountAddressDelete: + speakeasy-default-account-address-delete: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + responses: + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + accountAddPaymentMethod: + credit-card-address-reference-id: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "credit_card", "billing_address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2025-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"} + responses: + "200": + application/json: {".tag": "klarna"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + credit-card-address-reference-explicit: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "credit_card", "billing_address": {".tag": "explicit", "first_name": "Charlie", "last_name": "Dunn", "company": "ACME Corporation", "street_address1": "535 Mission St", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2025-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"} + responses: + "200": + application/json: {".tag": "credit_card", "id": "X5h6j8uLpVGK", "billing_address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "network": "visa", "last4": "1004", "expiration": "2029-03"} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + missing-input: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "affirm", "return_url": "www.example.com/handle_affirm_success"} + responses: + "200": + application/json: {".tag": "klarna_account"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + invalid-input: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "klarna_paynow", "return_url": "www.example.com/handle_klarna_paynow_success"} + responses: + "200": + application/json: {".tag": "affirm"} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + invalid-credit-card: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "credit_card", "billing_address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2029-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"} + responses: + "200": + application/json: {".tag": "klarna"} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + accountPaymentMethodDelete: + speakeasy-default-account-payment-method-delete: + parameters: + path: + id: "D4g3h5tBuVYK9" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + responses: + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + paymentsInitialize: + reference: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [{"address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "cost": {"currency": "USD", "units": 10000}, "carrier": "FedEx"}], "discounts": [{"amount": {"currency": "USD", "units": 10000}, "code": "SUMMER10DISCOUNT", "details_url": "https://www.example.com/SUMMER-SALE"}], "items": [{"name": "Bolt Swag Bag", "reference": "item_100", "description": "Large tote with Bolt logo.", "total_amount": {"currency": "USD", "units": 9000}, "unit_price": 1000, "quantity": 9, "image_url": "https://www.example.com/products/123456/images/1.png"}], "total": {"currency": "USD", "units": 9000}, "tax": {"currency": "USD", "units": 100}}, "payment_method": {".tag": "id", "id": "X5h6j8uLpVGK"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + credit_card: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [{"address": {".tag": "explicit", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "cost": {"currency": "USD", "units": 10000}, "carrier": "FedEx"}], "discounts": [{"amount": {"currency": "USD", "units": 10000}, "code": "SUMMER10DISCOUNT", "details_url": "https://www.example.com/SUMMER-SALE"}], "items": [{"name": "Bolt Swag Bag", "reference": "item_100", "description": "Large tote with Bolt logo.", "total_amount": {"currency": "USD", "units": 9000}, "unit_price": 1000, "quantity": 9, "image_url": "https://www.example.com/products/123456/images/1.png"}], "total": {"currency": "USD", "units": 9000}, "tax": {"currency": "USD", "units": 100}}, "payment_method": {".tag": "credit_card", "billing_address": {".tag": "explicit", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2025-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"}} + responses: + "200": + application/json: {".tag": "pending", "id": "iKv7t5bgt1gg", "status": "awaiting_user_confirmation", "action": "redirect", "url": "www.example.com/payments/finalize"} + 4XX: + application/json: {".tag": "payment_already_exists", "message": "A payment for this order already exists"} + paypal: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [{"address": {".tag": "explicit", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "cost": {"currency": "USD", "units": 10000}, "carrier": "FedEx"}], "discounts": [{"amount": {"currency": "USD", "units": 10000}, "code": "SUMMER10DISCOUNT", "details_url": "https://www.example.com/SUMMER-SALE"}], "items": [{"name": "Bolt Swag Bag", "reference": "item_100", "description": "Large tote with Bolt logo.", "total_amount": {"currency": "USD", "units": 9000}, "unit_price": 1000, "quantity": 9, "image_url": "https://www.example.com/products/123456/images/1.png"}], "total": {"currency": "USD", "units": 9000}, "tax": {"currency": "USD", "units": 100}}, "payment_method": {".tag": "paypal", "success_url": "https://www.example.com/paypal-callback/success", "cancel_url": "https://www.example.com/paypal-callback/cancel"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + finalized: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "credit_card", "billing_address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2029-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": [{"processor_reference": "123456789XYZ"}]}} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + pending: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "id", "id": "X5h6j8uLpVGK"}} + responses: + "200": + application/json: {".tag": "pending", "id": "iKv7t5bgt1gg", "status": "awaiting_user_confirmation", "action": "redirect", "url": "https://www.paypal.com/checkout/redirect"} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + missing-input: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "affirm", "return_url": "www.example.com/handle_affirm_success"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + invalid-cart: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "paypal", "success_url": "https://www.example.com/paypal-callback/success", "cancel_url": "https://www.example.com/paypal-callback/cancel"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + invalid-credit-card: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "id", "id": "X5h6j8uLpVGK"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + paymentsAction: + finalized: + parameters: + path: + id: "iKv7t5bgt1gg" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "finalize", "redirect_result": "eyJ0cmFuc"} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": [{"processor_reference": "123456789XYZ"}]}} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + guestPaymentsInitialize: + credit_card: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [{"address": {".tag": "explicit", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "cost": {"currency": "USD", "units": 10000}, "carrier": "FedEx"}], "discounts": [{"amount": {"currency": "USD", "units": 10000}, "code": "SUMMER10DISCOUNT", "details_url": "https://www.example.com/SUMMER-SALE"}], "items": [{"name": "Bolt Swag Bag", "reference": "item_100", "description": "Large tote with Bolt logo.", "total_amount": {"currency": "USD", "units": 9000}, "unit_price": 1000, "quantity": 9, "image_url": "https://www.example.com/products/123456/images/1.png"}], "total": {"currency": "USD", "units": 9000}, "tax": {"currency": "USD", "units": 100}}, "payment_method": {".tag": "credit_card", "billing_address": {".tag": "explicit", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2025-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"}} + responses: + "200": + application/json: {".tag": "pending", "id": "iKv7t5bgt1gg", "status": "awaiting_user_confirmation", "action": "redirect", "url": "www.example.com/payments/finalize"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + paypal: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [{"address": {".tag": "explicit", "first_name": "Alice", "last_name": "Baker", "company": "ACME Corporation", "street_address1": "535 Mission St, Ste 1401", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "cost": {"currency": "USD", "units": 10000}, "carrier": "FedEx"}], "discounts": [{"amount": {"currency": "USD", "units": 10000}, "code": "SUMMER10DISCOUNT", "details_url": "https://www.example.com/SUMMER-SALE"}], "items": [{"name": "Bolt Swag Bag", "reference": "item_100", "description": "Large tote with Bolt logo.", "total_amount": {"currency": "USD", "units": 9000}, "unit_price": 1000, "quantity": 9, "image_url": "https://www.example.com/products/123456/images/1.png"}], "total": {"currency": "USD", "units": 9000}, "tax": {"currency": "USD", "units": 100}}, "payment_method": {".tag": "paypal", "success_url": "https://www.example.com/paypal-callback/success", "cancel_url": "https://www.example.com/paypal-callback/cancel"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "payment_already_exists", "message": "A payment for this order already exists"} + finalized: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "paypal", "success_url": "https://www.example.com/paypal-callback/success", "cancel_url": "https://www.example.com/paypal-callback/cancel"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": [{"processor_reference": "123456789XYZ"}]}} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + pending: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "affirm", "return_url": "www.example.com/handle_affirm_success"}} + responses: + "200": + application/json: {".tag": "pending", "id": "iKv7t5bgt1gg", "status": "awaiting_user_confirmation", "action": "redirect", "url": "https://www.paypal.com/checkout/redirect"} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + missing-input: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "credit_card", "billing_address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2029-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + invalid-cart: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "affirm", "return_url": "www.example.com/handle_affirm_success"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "declined_invalid_cvv", "message": "The payment was declined because the CVV is not valid"} + invalid-credit-card: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"create_account": true, "first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}, "payment_method": {".tag": "credit_card", "billing_address": {".tag": "id", "id": "D4g3h5tBuVYK9"}, "network": "visa", "bin": "411111", "last4": "1004", "expiration": "2029-03", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"}} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + guestPaymentsAction: + speakeasy-default-guest-payments-action: + parameters: + path: + id: "iKv7t5bgt1gg" + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {".tag": "finalize", "redirect_result": "eyJ0cmFuc"} + responses: + "200": + application/json: {".tag": "finalized", "id": "iKv7t5bgt1gg", "status": "success", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + ordersCreate: + reference: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"first_name": "Charlie", "last_name": "Dunn", "email": "charlie@example.com", "phone": "+14085551111"}, "cart": {"order_reference": "instore_20240116-878", "order_description": "Order #878", "display_id": "20240116-878", "shipments": [{"address": {".tag": "explicit", "first_name": "Charlie", "last_name": "Dunn", "company": "ACME Corporation", "street_address1": "535 Mission St", "street_address2": "c/o Shipping Department", "locality": "San Francisco", "postal_code": "94105", "region": "CA", "country_code": "US", "email": "alice@example.com", "phone": "+14155550199"}, "cost": {"currency": "USD", "units": 10000}, "carrier": "FedEx"}], "discounts": [], "items": [{"name": "Red Fidget Spinner", "reference": "sku-984", "description": "Single-packed fidget spinner, red", "total_amount": {"currency": "USD", "units": 1000}, "unit_price": 1000, "quantity": 1, "image_url": "https://www.example.com/products/984/image.png"}], "total": {"currency": "USD", "units": 1000}, "tax": {"currency": "USD", "units": 100}}} + responses: + "200": + application/json: {"id": "iKv7t5bgt1gg", "transaction": {"reference": "OBYG-X1PX-FN55", "authorizations": []}} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + finalized: + parameters: + header: + X-Publishable-Key: "" + X-Merchant-Client-Id: "" + requestBody: + application/json: {"profile": {"first_name": "Alice", "last_name": "Baker", "email": "alice@example.com", "phone": "+14155550199"}, "cart": {"order_reference": "order_100", "order_description": "Order #1234567890", "display_id": "215614191", "shipments": [], "discounts": [], "items": [], "total": {"currency": "USD", "units": 900}, "tax": {"currency": "USD", "units": 900}}} + responses: + "200": + application/json: {"id": "3Cxr2keCtxju", "transaction": {"reference": "2ZF2-WZ3J-WD2Y", "authorizations": []}} + 4XX: + application/json: {".tag": "invalid_input_parameter", "message": "We were unable to process your request.", "field": "address.phone"} + oauthGetToken: + authorization-code: + parameters: + header: + X-Merchant-Client-Id: "" + requestBody: + application/x-www-form-urlencoded: {"grant_type": "authorization_code", "code": "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", "client_id": "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", "client_secret": "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", "scope": ["bolt.account.manage", "bolt.account.view", "openid"], "state": "xyzABC123"} + responses: + "200": + application/json: {"id_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFsaWNlQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6MTcwNTY1MTczMSwiZmlyc3RfbmFtZSI6IkFsaWNlIiwiaXNzIjoiaHR0cDovL2FwaS5ib2x0LmNvbSIsImxhc3RfbmFtZSI6IkJha2VyIiwicGhvbmVfbnVtYmVyIjoiKzE0MTU1NTUwMTk5IiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjp0cnVlLCJpYXQiOjE3MDU2NDg0MjF9.Ir0aKx40zfNCZol1DnqchFx9ciHlyZY9y10mndEjOBHhpHif8-7aZl2UoJVs_0Hj-5ArEouUD6n-y1SJD0Wns-gDMoA0Etoc5dT_0zt0Kw5T8FvJWbyKyyGSDEwPFVADIRxDPMpVoHx0C0nwr_GudnIX7YG6p2HCsoGm2C04ZxKpifSixB3-xNB6k9u1ESWh0KjMCYzBQ2x9wbQ_S6kFtio075PFYcZ3iRQz8oD15NsZDd2czzZkRnGTGlpG0sAvScLXMvDDOWBIu-4wvOEOT7avunJQ_rOCYUlyJe7JGh0QllpeJNau8kx-4YGMeFTkeGM_hPIKsRF1e6o_rWp5CMJnmJDPme-zlJxWodyaHNed5XW-4DR7blv_PFOJNrRvymRoTOd74LIpS21GRCNYrphj7N6-TsSfO9hMQ9ehxrgNAryWbVtTM_3VvWyzX-SRa7BcRkS97sokxc04s3cbXra3x6brE3uL1yoOWNf8GDZNkv1uUAnrOZcTuLacrPjkQgOPb-chMiWS1L0Zd1wX3rqpeCyEswsGKxRRkpgwoBaVVQmLB9m51B6SXEvURTcy2Hx8KzgfXQ_-uC-KrniQxWzYms8A1lypKXkEcyMD2E4Q7EB4UeD2qZAk4tZo611uHegaHaEM7EQyFN3nxvibaqFpXzdxVmOCX0_wQr1nDNA", "access_token": "KCqordmSK6_lpkaXaXfGD8LwnKMGGOYy4Ju2IaBXpJI.CzOF7QOmGGQEgIzBjxOEh1FbRdDpzf9zbm9eHrCZ6zw", "expires_in": 3600, "refresh_token": "4hJYNO4GHvALZoocXoLenfNeFy1RR5ZT6G5JYrFbvkI.Q_PqV0lIszCNoN-85EwD-2nYZOVEepVgJSolx-Jbzrs", "refresh_token_scope": "bolt.account.view", "scope": "bolt.account.manage openid", "token_type": "bearer"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + refresh-token: + parameters: + header: + X-Merchant-Client-Id: "" + requestBody: + application/x-www-form-urlencoded: {"grant_type": "refresh_token", "refresh_token": "4hJYNO4GHvALZoocXoLenfNeFy1RR5ZT6G5JYrFbvkI.Q_PqV0lIszCNoN-85EwD-2nYZOVEepVgJSolx-Jbzrs", "client_id": "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", "client_secret": "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", "scope": ["bolt.account.view"], "state": "xyzABC123"} + responses: + "200": + application/json: {"id_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFsaWNlQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6MTcwNTY1MTczMSwiZmlyc3RfbmFtZSI6IkFsaWNlIiwiaXNzIjoiaHR0cDovL2FwaS5ib2x0LmNvbSIsImxhc3RfbmFtZSI6IkJha2VyIiwicGhvbmVfbnVtYmVyIjoiKzE0MTU1NTUwMTk5IiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjp0cnVlLCJpYXQiOjE3MDU2NDg0MjF9.Ir0aKx40zfNCZol1DnqchFx9ciHlyZY9y10mndEjOBHhpHif8-7aZl2UoJVs_0Hj-5ArEouUD6n-y1SJD0Wns-gDMoA0Etoc5dT_0zt0Kw5T8FvJWbyKyyGSDEwPFVADIRxDPMpVoHx0C0nwr_GudnIX7YG6p2HCsoGm2C04ZxKpifSixB3-xNB6k9u1ESWh0KjMCYzBQ2x9wbQ_S6kFtio075PFYcZ3iRQz8oD15NsZDd2czzZkRnGTGlpG0sAvScLXMvDDOWBIu-4wvOEOT7avunJQ_rOCYUlyJe7JGh0QllpeJNau8kx-4YGMeFTkeGM_hPIKsRF1e6o_rWp5CMJnmJDPme-zlJxWodyaHNed5XW-4DR7blv_PFOJNrRvymRoTOd74LIpS21GRCNYrphj7N6-TsSfO9hMQ9ehxrgNAryWbVtTM_3VvWyzX-SRa7BcRkS97sokxc04s3cbXra3x6brE3uL1yoOWNf8GDZNkv1uUAnrOZcTuLacrPjkQgOPb-chMiWS1L0Zd1wX3rqpeCyEswsGKxRRkpgwoBaVVQmLB9m51B6SXEvURTcy2Hx8KzgfXQ_-uC-KrniQxWzYms8A1lypKXkEcyMD2E4Q7EB4UeD2qZAk4tZo611uHegaHaEM7EQyFN3nxvibaqFpXzdxVmOCX0_wQr1nDNA", "access_token": "KCqordmSK6_lpkaXaXfGD8LwnKMGGOYy4Ju2IaBXpJI.CzOF7QOmGGQEgIzBjxOEh1FbRdDpzf9zbm9eHrCZ6zw", "expires_in": 3600, "refresh_token": "4hJYNO4GHvALZoocXoLenfNeFy1RR5ZT6G5JYrFbvkI.Q_PqV0lIszCNoN-85EwD-2nYZOVEepVgJSolx-Jbzrs", "refresh_token_scope": "bolt.account.view", "scope": "bolt.account.manage openid", "token_type": "bearer"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + testingAccountCreate: + speakeasy-default-testing-account-create: + parameters: + header: + X-Publishable-Key: "" + requestBody: + application/json: {"email_state": "unverified", "phone_state": "verified", "is_migrated": true, "has_address": true, "has_credit_card": true} + responses: + "200": + application/json: {"email": "alice@example.com", "email_state": "unverified", "phone": "+14155550199", "phone_state": "verified", "otp_code": "123456", "oauth_code": "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + testingAccountPhoneGet: + speakeasy-default-testing-account-phone-get: + parameters: + header: + X-Publishable-Key: "" + responses: + "200": + application/json: {"phone": "+14155550199"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} + testingCreditCardGet: + speakeasy-default-testing-credit-card-get: + requestBody: + application/json: {"type": "approve"} + responses: + "200": + application/json: {"network": "visa", "bin": "411111", "last4": "1004", "expiration": "2023-10-31:T06:00:00Z", "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0"} + 4XX: + application/json: {".tag": "unprocessable_request", "message": "We were unable to process your request."} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index b2fc2ff8..f5adf4a8 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.344.0 +speakeasyVersion: 1.392.1 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:98e7ad9f70d219b7521618106928a1700247c2ef42f15199268b5c315b9514e3 - sourceBlobDigest: sha256:e23f694ae3f097bdcc023f6204f8521ecfa8dbb529379ae76560df4dc819c093 + sourceRevisionDigest: sha256:c4ac71a67d4f20ec5572fdef59cf52ebe532ae44726275beebf87ef35e8ee4a4 + sourceBlobDigest: sha256:27d07c65383b445e0fd3a098783adeabae528de8fda49d2e814fb07322139a63 tags: - latest - main @@ -11,8 +11,8 @@ targets: bolt-typescript: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:98e7ad9f70d219b7521618106928a1700247c2ef42f15199268b5c315b9514e3 - sourceBlobDigest: sha256:e23f694ae3f097bdcc023f6204f8521ecfa8dbb529379ae76560df4dc819c093 + sourceRevisionDigest: sha256:c4ac71a67d4f20ec5572fdef59cf52ebe532ae44726275beebf87ef35e8ee4a4 + sourceBlobDigest: sha256:27d07c65383b445e0fd3a098783adeabae528de8fda49d2e814fb07322139a63 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/FUNCTIONS.md b/FUNCTIONS.md new file mode 100644 index 00000000..bd25e21a --- /dev/null +++ b/FUNCTIONS.md @@ -0,0 +1,107 @@ +# Standalone Functions + +> [!NOTE] +> This section is useful if you are using a bundler and targetting browsers and +> runtimes where the size of an application affects performance and load times. + +Every method in this SDK is also available as a standalone function. This +alternative API is suitable when targetting the browser or serverless runtimes +and using a bundler to build your application since all unused functionality +will be tree-shaken away. This includes code for unused methods, Zod schemas, +encoding helpers and response handlers. The result is dramatically smaller +impact on the application's final bundle size which grows very slowly as you use +more and more functionality from this SDK. + +Calling methods through the main SDK class remains a valid and generally more +more ergonomic option. Standalone functions represent an optimisation for a +specific category of applications. + +## Example + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountGetDetails } from "@boltpay/bolt-typescript-sdk/funcs/accountGetDetails.js"; +import { SDKValidationError } from "@boltpay/bolt-typescript-sdk/models/errors/sdkvalidationerror.js"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountGetDetails(boltTypescriptSDK, "", ""); + + switch (true) { + case res.ok: + // The success case will be handled outside of the switch block + break; + case res.error instanceof SDKValidationError: + // Pretty-print validation errors. + return console.log(res.error.pretty()); + case res.error instanceof Error: + return console.log(res.error); + default: + // TypeScript's type checking will fail on the following line if the above + // cases were not exhaustive. + res.error satisfies never; + throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + } + + + const { value: result } = res; + + // Handle the result + console.log(result) +} + +run(); +``` + +## Result types + +Standalone functions differ from SDK methods in that they return a +`Result` type to capture _known errors_ and document them using +the type system. By avoiding throwing errors, application code maintains clear +control flow and error-handling become part of the regular flow of application +code. + +> We use the term "known errors" because standalone functions, and JavaScript +> code in general, can still throw unexpected errors such as `TypeError`s, +> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be +> something this SDK addresses in the future. Nevertheless, there is still a lot +> of benefit from capturing most errors and turning them into values. + +The second reason for this style of programming is because these functions will +typically be used in front-end applications where exception throwing is +sometimes discouraged or considered unidiomatic. React and similar ecosystems +and libraries tend to promote this style of programming so that components +render useful content under all states (loading, success, error and so on). + +The general pattern when calling standalone functions looks like this: + +```typescript +import { Core } from ""; +import { fetchSomething } from "/funcs/fetchSomething.js"; + +const client = new Core(); + +async function run() { + const result = await fetchSomething(client, { id: "123" }); + if (!result.ok) { + // You can throw the error or handle it. It's your choice now. + throw result.error; + } + + console.log(result.value); +} + +run(); +``` + +Notably, `result.error` above will have an explicit type compared to a try-catch +variation where the error in the catch block can only be of type `unknown` (or +`any` depending on your TypeScript settings). \ No newline at end of file diff --git a/README.md b/README.md index 09b788dd..728178ff 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,33 @@ + +## Summary + +Bolt API Reference: A comprehensive Bolt API reference for interacting with Accounts, Payments, Orders and more. + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [Requirements](#requirements) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Standalone functions](#standalone-functions) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Authentication](#authentication) +* [Debugging](#debugging) + + ## SDK Installation +The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers. + ### NPM ```bash @@ -46,6 +70,7 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -104,21 +129,23 @@ run(); All SDK methods return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type. -| Error Object | Status Code | Content Type | -| ----------------------------- | ----------------------------- | ----------------------------- | -| errors.AccountGetResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging. ```typescript import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; -import { SDKValidationError } from "@boltpay/bolt-typescript-sdk/models/errors"; +import { ErrorT, FieldError, SDKValidationError } from "@boltpay/bolt-typescript-sdk/models/errors"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -126,6 +153,9 @@ async function run() { let result; try { result = await boltTypescriptSDK.account.getDetails("", ""); + + // Handle the result + console.log(result); } catch (err) { switch (true) { case err instanceof SDKValidationError: { @@ -135,8 +165,12 @@ async function run() { console.error(err.rawValue); return; } - case err instanceof errors.AccountGetResponseBody: { - console.error(err); // handle exception + case err instanceof ErrorT: { + // Handle err.data$: ErrorTData + return; + } + case err instanceof FieldError: { + // Handle err.data$: FieldErrorData return; } default: { @@ -144,9 +178,6 @@ async function run() { } } } - - // Handle the result - console.log(result); } run(); @@ -172,6 +203,7 @@ const boltTypescriptSDK = new BoltTypescriptSDK({ serverIdx: 0, security: { oauth: "", + apiKey: "", }, }); @@ -202,6 +234,7 @@ const boltTypescriptSDK = new BoltTypescriptSDK({ serverURL: "https://{environment}.bolt.com/v3", security: { oauth: "", + apiKey: "", }, }); @@ -285,6 +318,7 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -305,7 +339,8 @@ Some operations in this SDK require the security scheme to be specified at the r ```typescript import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; import { - AddressReferenceIdTag, + AddressReferenceExplicitTag, + CountryCode, CreditCardNetwork, Currency, DotTag, @@ -315,7 +350,9 @@ const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { const result = await boltTypescriptSDK.payments.guest.initialize( - "", + { + apiKey: "", + }, "", "", { @@ -333,8 +370,18 @@ async function run() { shipments: [ { address: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", }, cost: { currency: Currency.Usd, @@ -379,8 +426,18 @@ async function run() { paymentMethod: { dotTag: DotTag.CreditCard, billingAddress: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", }, network: CreditCardNetwork.Visa, bin: "411111", @@ -406,6 +463,41 @@ run(); For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md). + +## Standalone functions + +All the methods listed above are available as standalone functions. These +functions are ideal for use in applications running in the browser, serverless +runtimes or other environments where application bundle size is a primary +concern. When using a bundler to build your application, all unused +functionality will be either excluded from the final bundle or tree-shaken away. + +To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +
+ +Available standalone functions + +- [accountAddAddress](docs/sdks/account/README.md#addaddress) +- [accountAddPaymentMethod](docs/sdks/account/README.md#addpaymentmethod) +- [accountDeleteAddress](docs/sdks/account/README.md#deleteaddress) +- [accountDeletePaymentMethod](docs/sdks/account/README.md#deletepaymentmethod) +- [accountGetDetails](docs/sdks/account/README.md#getdetails) +- [accountUpdateAddress](docs/sdks/account/README.md#updateaddress) +- [oAuthGetToken](docs/sdks/oauth/README.md#gettoken) +- [ordersOrdersCreate](docs/sdks/orders/README.md#orderscreate) +- [paymentsGuestInitialize](docs/sdks/guest/README.md#initialize) +- [paymentsGuestPerformAction](docs/sdks/guest/README.md#performaction) +- [paymentsLoggedInInitialize](docs/sdks/loggedin/README.md#initialize) +- [paymentsLoggedInPerformAction](docs/sdks/loggedin/README.md#performaction) +- [testingCreateAccount](docs/sdks/testing/README.md#createaccount) +- [testingGetCreditCard](docs/sdks/testing/README.md#getcreditcard) +- [testingTestingAccountPhoneGet](docs/sdks/testing/README.md#testingaccountphoneget) + + +
+ + ## Retries @@ -418,6 +510,7 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -460,6 +553,7 @@ const boltTypescriptSDK = new BoltTypescriptSDK({ }, security: { oauth: "", + apiKey: "", }, }); @@ -475,6 +569,23 @@ run(); ``` + +## Debugging + +You can setup your SDK to emit debug logs for SDK requests and responses. + +You can pass a logger that matches `console`'s interface as an SDK option. + +> [!WARNING] +> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. + +```typescript +import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; + +const sdk = new BoltTypescriptSDK({ debugLogger: console }); +``` + + # Development diff --git a/RELEASES.md b/RELEASES.md index 38c53455..0ebd55d3 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -548,4 +548,14 @@ Based on: ### Generated - [typescript v0.19.0] . ### Releases -- [NPM v0.19.0] https://www.npmjs.com/package/@boltpay/bolt-typescript-sdk/v/0.19.0 - . \ No newline at end of file +- [NPM v0.19.0] https://www.npmjs.com/package/@boltpay/bolt-typescript-sdk/v/0.19.0 - . + +## 2024-09-07 00:19:08 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.392.1 (2.411.9) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.20.0] . +### Releases +- [NPM v0.20.0] https://www.npmjs.com/package/@boltpay/bolt-typescript-sdk/v/0.20.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index fad04020..f2b0d697 100644 --- a/USAGE.md +++ b/USAGE.md @@ -5,6 +5,7 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); diff --git a/docs/models/components/account.md b/docs/models/components/account.md index 054588d0..4d0a1ebf 100644 --- a/docs/models/components/account.md +++ b/docs/models/components/account.md @@ -1,5 +1,41 @@ # Account +## Example Usage + +```typescript +import { Account, CountryCode, PaymentMethodAffirmTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Account = { + addresses: [ + { + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + isDefault: true, + }, + ], + paymentMethods: [ + { + dotTag: PaymentMethodAffirmTag.Affirm, + }, + ], + profile: { + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, +}; +``` ## Fields diff --git a/docs/models/components/accounttestcreationdata.md b/docs/models/components/accounttestcreationdata.md deleted file mode 100644 index 3a7322ee..00000000 --- a/docs/models/components/accounttestcreationdata.md +++ /dev/null @@ -1,12 +0,0 @@ -# AccountTestCreationData - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -| `emailState` | [components.EmailState](../../models/components/emailstate.md) | :heavy_check_mark: | N/A | unverified | -| `phoneState` | [components.PhoneState](../../models/components/phonestate.md) | :heavy_check_mark: | N/A | verified | -| `isMigrated` | *boolean* | :heavy_minus_sign: | N/A | true | -| `hasAddress` | *boolean* | :heavy_minus_sign: | N/A | true | -| `hasCreditCard` | *boolean* | :heavy_minus_sign: | N/A | true | \ No newline at end of file diff --git a/docs/models/components/accounttestcreationdataoutput.md b/docs/models/components/accounttestcreationdataoutput.md index 4d257236..1ee55544 100644 --- a/docs/models/components/accounttestcreationdataoutput.md +++ b/docs/models/components/accounttestcreationdataoutput.md @@ -1,5 +1,19 @@ # AccountTestCreationDataOutput +## Example Usage + +```typescript +import { AccountTestCreationDataOutput, EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AccountTestCreationDataOutput = { + email: "alice@example.com", + emailState: EmailState.Unverified, + phone: "+14155550199", + phoneState: PhoneState.Verified, + otpCode: "123456", + oauthCode: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", +}; +``` ## Fields diff --git a/docs/models/components/accounttestphonedata.md b/docs/models/components/accounttestphonedata.md index 7fe0a04f..30841cbe 100644 --- a/docs/models/components/accounttestphonedata.md +++ b/docs/models/components/accounttestphonedata.md @@ -1,5 +1,14 @@ # AccountTestPhoneData +## Example Usage + +```typescript +import { AccountTestPhoneData } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AccountTestPhoneData = { + phone: "+14155550199", +}; +``` ## Fields diff --git a/docs/models/components/action.md b/docs/models/components/action.md index 52dd3f7c..28e8da1c 100644 --- a/docs/models/components/action.md +++ b/docs/models/components/action.md @@ -1,5 +1,12 @@ # Action +## Example Usage + +```typescript +import { Action } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Action = Action.Redirect; +``` ## Values diff --git a/docs/models/components/addresslisting.md b/docs/models/components/addresslisting.md index 410c2e91..126c1af6 100644 --- a/docs/models/components/addresslisting.md +++ b/docs/models/components/addresslisting.md @@ -2,6 +2,27 @@ An address saved on an account, i.e. a physical address plus any additional account-specific metadata. +## Example Usage + +```typescript +import { AddressListing, CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AddressListing = { + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + isDefault: true, +}; +``` ## Fields diff --git a/docs/models/components/addresslistinginput.md b/docs/models/components/addresslistinginput.md deleted file mode 100644 index 66afaa4c..00000000 --- a/docs/models/components/addresslistinginput.md +++ /dev/null @@ -1,20 +0,0 @@ -# AddressListingInput - -An address saved on an account, i.e. a physical address plus any additional account-specific metadata. - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | -| `firstName` | *string* | :heavy_check_mark: | The first name of the person associated with this address. | Alice | -| `lastName` | *string* | :heavy_check_mark: | The last name of the person associated with this address. | Baker | -| `company` | *string* | :heavy_minus_sign: | The company associated with this address. | ACME Corporation | -| `streetAddress1` | *string* | :heavy_check_mark: | The street address associated with this address. | 535 Mission St, Ste 1401 | -| `streetAddress2` | *string* | :heavy_minus_sign: | Any additional, optional, street address information associated with this address. | c/o Shipping Department | -| `locality` | *string* | :heavy_check_mark: | The locality (e.g. city, town, etc...) associated with this address. | San Francisco | -| `postalCode` | *string* | :heavy_check_mark: | The postal code associated with this address. | 94105 | -| `region` | *string* | :heavy_minus_sign: | The region or administrative area (e.g. state, province, county, etc...) associated with this address. | CA | -| `countryCode` | [components.CountryCode](../../models/components/countrycode.md) | :heavy_check_mark: | The country (in its ISO 3166 alpha-2 format) associated with this address. | US | -| `email` | *string* | :heavy_minus_sign: | The email address associated with this address. | alice@example.com | -| `phone` | *string* | :heavy_minus_sign: | The phone number associated with this address. | +14155550199 | \ No newline at end of file diff --git a/docs/models/components/addressreference.md b/docs/models/components/addressreference.md index 1e01ef63..404ec8fb 100644 --- a/docs/models/components/addressreference.md +++ b/docs/models/components/addressreference.md @@ -1,5 +1,15 @@ # AddressReference +## Example Usage + +```typescript +import { AddressReference, AddressReferenceIdTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AddressReference = { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", +}; +``` ## Supported Types diff --git a/docs/models/components/addressreferenceexplicit.md b/docs/models/components/addressreferenceexplicit.md index daee3489..0d58ce65 100644 --- a/docs/models/components/addressreferenceexplicit.md +++ b/docs/models/components/addressreferenceexplicit.md @@ -2,6 +2,27 @@ A physical address. +## Example Usage + +```typescript +import { AddressReferenceExplicit, AddressReferenceExplicitTag, CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AddressReferenceExplicit = { + dotTag: AddressReferenceExplicitTag.Explicit, + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", +}; +``` ## Fields diff --git a/docs/models/components/addressreferenceexplicitinput.md b/docs/models/components/addressreferenceexplicitinput.md deleted file mode 100644 index 4ec6f881..00000000 --- a/docs/models/components/addressreferenceexplicitinput.md +++ /dev/null @@ -1,21 +0,0 @@ -# AddressReferenceExplicitInput - -A physical address. - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | -| `dotTag` | [components.AddressReferenceExplicitTag](../../models/components/addressreferenceexplicittag.md) | :heavy_check_mark: | The type of address reference | explicit | -| `firstName` | *string* | :heavy_check_mark: | The first name of the person associated with this address. | Alice | -| `lastName` | *string* | :heavy_check_mark: | The last name of the person associated with this address. | Baker | -| `company` | *string* | :heavy_minus_sign: | The company associated with this address. | ACME Corporation | -| `streetAddress1` | *string* | :heavy_check_mark: | The street address associated with this address. | 535 Mission St, Ste 1401 | -| `streetAddress2` | *string* | :heavy_minus_sign: | Any additional, optional, street address information associated with this address. | c/o Shipping Department | -| `locality` | *string* | :heavy_check_mark: | The locality (e.g. city, town, etc...) associated with this address. | San Francisco | -| `postalCode` | *string* | :heavy_check_mark: | The postal code associated with this address. | 94105 | -| `region` | *string* | :heavy_minus_sign: | The region or administrative area (e.g. state, province, county, etc...) associated with this address. | CA | -| `countryCode` | [components.CountryCode](../../models/components/countrycode.md) | :heavy_check_mark: | The country (in its ISO 3166 alpha-2 format) associated with this address. | US | -| `email` | *string* | :heavy_minus_sign: | The email address associated with this address. | alice@example.com | -| `phone` | *string* | :heavy_minus_sign: | The phone number associated with this address. | +14155550199 | \ No newline at end of file diff --git a/docs/models/components/addressreferenceexplicittag.md b/docs/models/components/addressreferenceexplicittag.md index 56f389ec..89b6d7ee 100644 --- a/docs/models/components/addressreferenceexplicittag.md +++ b/docs/models/components/addressreferenceexplicittag.md @@ -2,6 +2,13 @@ The type of address reference +## Example Usage + +```typescript +import { AddressReferenceExplicitTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AddressReferenceExplicitTag = AddressReferenceExplicitTag.Explicit; +``` ## Values diff --git a/docs/models/components/addressreferenceid.md b/docs/models/components/addressreferenceid.md index ada7fb27..6f575095 100644 --- a/docs/models/components/addressreferenceid.md +++ b/docs/models/components/addressreferenceid.md @@ -1,5 +1,15 @@ # AddressReferenceId +## Example Usage + +```typescript +import { AddressReferenceId, AddressReferenceIdTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AddressReferenceId = { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", +}; +``` ## Fields diff --git a/docs/models/components/addressreferenceidtag.md b/docs/models/components/addressreferenceidtag.md index 343484b2..8849e1cd 100644 --- a/docs/models/components/addressreferenceidtag.md +++ b/docs/models/components/addressreferenceidtag.md @@ -2,6 +2,13 @@ The type of address reference +## Example Usage + +```typescript +import { AddressReferenceIdTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AddressReferenceIdTag = AddressReferenceIdTag.Id; +``` ## Values diff --git a/docs/models/components/addressreferenceinput.md b/docs/models/components/addressreferenceinput.md deleted file mode 100644 index 3a3de109..00000000 --- a/docs/models/components/addressreferenceinput.md +++ /dev/null @@ -1,17 +0,0 @@ -# AddressReferenceInput - - -## Supported Types - -### `components.AddressReferenceId` - -```typescript -const value: components.AddressReferenceId = /* values here */ -``` - -### `components.AddressReferenceExplicitInput` - -```typescript -const value: components.AddressReferenceExplicitInput = /* values here */ -``` - diff --git a/docs/models/components/amount.md b/docs/models/components/amount.md index 140e9a85..8d2a94a0 100644 --- a/docs/models/components/amount.md +++ b/docs/models/components/amount.md @@ -2,6 +2,16 @@ A monetary amount, i.e. a base unit amount and a supported currency. +## Example Usage + +```typescript +import { Amount, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Amount = { + currency: Currency.Usd, + units: 900, +}; +``` ## Fields diff --git a/docs/models/components/authorizationcoderequest.md b/docs/models/components/authorizationcoderequest.md index bfdcac83..18b9d12e 100644 --- a/docs/models/components/authorizationcoderequest.md +++ b/docs/models/components/authorizationcoderequest.md @@ -1,5 +1,20 @@ # AuthorizationCodeRequest +## Example Usage + +```typescript +import { AuthorizationCodeRequest, GrantType, Scope } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: AuthorizationCodeRequest = { + grantType: GrantType.AuthorizationCode, + code: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", + clientId: + "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", + clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", + scope: [Scope.Openid], + state: "xyzABC123", +}; +``` ## Fields diff --git a/docs/models/components/cart.md b/docs/models/components/cart.md index 84875ae0..8f725c5a 100644 --- a/docs/models/components/cart.md +++ b/docs/models/components/cart.md @@ -1,5 +1,71 @@ # Cart +## Example Usage + +```typescript +import { AddressReferenceExplicitTag, Cart, CountryCode, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Cart = { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, +}; +``` ## Fields diff --git a/docs/models/components/cartdiscount.md b/docs/models/components/cartdiscount.md index 82bd6e1e..9a521ae2 100644 --- a/docs/models/components/cartdiscount.md +++ b/docs/models/components/cartdiscount.md @@ -1,5 +1,19 @@ # CartDiscount +## Example Usage + +```typescript +import { CartDiscount, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: CartDiscount = { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", +}; +``` ## Fields diff --git a/docs/models/components/cartitem.md b/docs/models/components/cartitem.md index 3f46621d..149575f8 100644 --- a/docs/models/components/cartitem.md +++ b/docs/models/components/cartitem.md @@ -1,5 +1,23 @@ # CartItem +## Example Usage + +```typescript +import { CartItem, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: CartItem = { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", +}; +``` ## Fields diff --git a/docs/models/components/cartshipment.md b/docs/models/components/cartshipment.md index f2f62bbb..bf50ef17 100644 --- a/docs/models/components/cartshipment.md +++ b/docs/models/components/cartshipment.md @@ -1,5 +1,32 @@ # CartShipment +## Example Usage + +```typescript +import { AddressReferenceExplicitTag, CartShipment, CountryCode, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: CartShipment = { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", +}; +``` ## Fields diff --git a/docs/models/components/countrycode.md b/docs/models/components/countrycode.md index 741dc7d9..7329091e 100644 --- a/docs/models/components/countrycode.md +++ b/docs/models/components/countrycode.md @@ -2,6 +2,13 @@ The country (in its ISO 3166 alpha-2 format) associated with this address. +## Example Usage + +```typescript +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: CountryCode = CountryCode.Us; +``` ## Values diff --git a/docs/models/components/creditcardnetwork.md b/docs/models/components/creditcardnetwork.md index 316df939..91e9031f 100644 --- a/docs/models/components/creditcardnetwork.md +++ b/docs/models/components/creditcardnetwork.md @@ -2,6 +2,13 @@ The credit card's network. +## Example Usage + +```typescript +import { CreditCardNetwork } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: CreditCardNetwork = CreditCardNetwork.Visa; +``` ## Values diff --git a/docs/models/components/currency.md b/docs/models/components/currency.md index 4129d330..e78aa7cb 100644 --- a/docs/models/components/currency.md +++ b/docs/models/components/currency.md @@ -2,6 +2,13 @@ A supported currency. +## Example Usage + +```typescript +import { Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Currency = Currency.Usd; +``` ## Values diff --git a/docs/models/components/dottag.md b/docs/models/components/dottag.md index ac3a866a..cca60992 100644 --- a/docs/models/components/dottag.md +++ b/docs/models/components/dottag.md @@ -1,5 +1,12 @@ # DotTag +## Example Usage + +```typescript +import { DotTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: DotTag = DotTag.CreditCard; +``` ## Values diff --git a/docs/models/components/emailstate.md b/docs/models/components/emailstate.md index 243a1f26..77642f2e 100644 --- a/docs/models/components/emailstate.md +++ b/docs/models/components/emailstate.md @@ -1,5 +1,12 @@ # EmailState +## Example Usage + +```typescript +import { EmailState } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: EmailState = EmailState.Unverified; +``` ## Values diff --git a/docs/models/components/getaccesstokenresponse.md b/docs/models/components/getaccesstokenresponse.md index 7da3eeab..e80e0825 100644 --- a/docs/models/components/getaccesstokenresponse.md +++ b/docs/models/components/getaccesstokenresponse.md @@ -1,5 +1,23 @@ # GetAccessTokenResponse +## Example Usage + +```typescript +import { GetAccessTokenResponse } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: GetAccessTokenResponse = { + idToken: + "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFsaWNlQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6MTcwNTY1MTczMSwiZmlyc3RfbmFtZSI6IkFsaWNlIiwiaXNzIjoiaHR0cDovL2FwaS5ib2x0LmNvbSIsImxhc3RfbmFtZSI6IkJha2VyIiwicGhvbmVfbnVtYmVyIjoiKzE0MTU1NTUwMTk5IiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjp0cnVlLCJpYXQiOjE3MDU2NDg0MjF9.Ir0aKx40zfNCZol1DnqchFx9ciHlyZY9y10mndEjOBHhpHif8-7aZl2UoJVs_0Hj-5ArEouUD6n-y1SJD0Wns-gDMoA0Etoc5dT_0zt0Kw5T8FvJWbyKyyGSDEwPFVADIRxDPMpVoHx0C0nwr_GudnIX7YG6p2HCsoGm2C04ZxKpifSixB3-xNB6k9u1ESWh0KjMCYzBQ2x9wbQ_S6kFtio075PFYcZ3iRQz8oD15NsZDd2czzZkRnGTGlpG0sAvScLXMvDDOWBIu-4wvOEOT7avunJQ_rOCYUlyJe7JGh0QllpeJNau8kx-4YGMeFTkeGM_hPIKsRF1e6o_rWp5CMJnmJDPme-zlJxWodyaHNed5XW-4DR7blv_PFOJNrRvymRoTOd74LIpS21GRCNYrphj7N6-TsSfO9hMQ9ehxrgNAryWbVtTM_3VvWyzX-SRa7BcRkS97sokxc04s3cbXra3x6brE3uL1yoOWNf8GDZNkv1uUAnrOZcTuLacrPjkQgOPb-chMiWS1L0Zd1wX3rqpeCyEswsGKxRRkpgwoBaVVQmLB9m51B6SXEvURTcy2Hx8KzgfXQ_-uC-KrniQxWzYms8A1lypKXkEcyMD2E4Q7EB4UeD2qZAk4tZo611uHegaHaEM7EQyFN3nxvibaqFpXzdxVmOCX0_wQr1nDNA", + accessToken: + "KCqordmSK6_lpkaXaXfGD8LwnKMGGOYy4Ju2IaBXpJI.CzOF7QOmGGQEgIzBjxOEh1FbRdDpzf9zbm9eHrCZ6zw", + expiresIn: 3600, + refreshToken: + "4hJYNO4GHvALZoocXoLenfNeFy1RR5ZT6G5JYrFbvkI.Q_PqV0lIszCNoN-85EwD-2nYZOVEepVgJSolx-Jbzrs", + refreshTokenScope: "bolt.account.view", + scope: "bolt.account.manage openid", + tokenType: "bearer", +}; +``` ## Fields diff --git a/docs/models/components/granttype.md b/docs/models/components/granttype.md index 50857e4b..6b787fc2 100644 --- a/docs/models/components/granttype.md +++ b/docs/models/components/granttype.md @@ -2,6 +2,13 @@ The type of OAuth 2.0 grant being utilized. +## Example Usage + +```typescript +import { GrantType } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: GrantType = GrantType.AuthorizationCode; +``` ## Values diff --git a/docs/models/components/guestpaymentinitializerequest.md b/docs/models/components/guestpaymentinitializerequest.md index 4dbe846d..4d437f30 100644 --- a/docs/models/components/guestpaymentinitializerequest.md +++ b/docs/models/components/guestpaymentinitializerequest.md @@ -1,5 +1,79 @@ # GuestPaymentInitializeRequest +## Example Usage + +```typescript +import { + AddressReferenceIdTag, + Currency, + GuestPaymentInitializeRequest, + PaymentMethodKlarnaAccountTag, +} from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: GuestPaymentInitializeRequest = { + profile: { + createAccount: true, + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, + }, + paymentMethod: { + dotTag: PaymentMethodKlarnaAccountTag.KlarnaAccount, + returnUrl: "www.example.com/handle_klarna_account_success", + }, +}; +``` ## Fields diff --git a/docs/models/components/order.md b/docs/models/components/order.md index c47c7264..ba738a7f 100644 --- a/docs/models/components/order.md +++ b/docs/models/components/order.md @@ -1,5 +1,79 @@ # Order +## Example Usage + +```typescript +import { AddressReferenceExplicitTag, CountryCode, Currency, Order } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Order = { + profile: { + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, + }, +}; +``` ## Fields diff --git a/docs/models/components/orderresponse.md b/docs/models/components/orderresponse.md index d303ce45..7df579fc 100644 --- a/docs/models/components/orderresponse.md +++ b/docs/models/components/orderresponse.md @@ -1,5 +1,22 @@ # OrderResponse +## Example Usage + +```typescript +import { OrderResponse } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: OrderResponse = { + id: "iKv7t5bgt1gg", + transaction: { + reference: "OBYG-X1PX-FN55", + authorizations: [ + { + processorReference: "123456789XYZ", + }, + ], + }, +}; +``` ## Fields diff --git a/docs/models/components/paymentactionrequest.md b/docs/models/components/paymentactionrequest.md index 425c7964..c30866bd 100644 --- a/docs/models/components/paymentactionrequest.md +++ b/docs/models/components/paymentactionrequest.md @@ -1,5 +1,15 @@ # PaymentActionRequest +## Example Usage + +```typescript +import { PaymentActionRequest, PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentActionRequest = { + dotTag: PaymentActionRequestTag.Finalize, + redirectResult: "eyJ0cmFuc", +}; +``` ## Fields diff --git a/docs/models/components/paymentactionrequesttag.md b/docs/models/components/paymentactionrequesttag.md index 4da04901..09270ca1 100644 --- a/docs/models/components/paymentactionrequesttag.md +++ b/docs/models/components/paymentactionrequesttag.md @@ -1,5 +1,12 @@ # PaymentActionRequestTag +## Example Usage + +```typescript +import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentActionRequestTag = PaymentActionRequestTag.Finalize; +``` ## Values diff --git a/docs/models/components/paymentinitializerequest.md b/docs/models/components/paymentinitializerequest.md index ecd49cb9..13341930 100644 --- a/docs/models/components/paymentinitializerequest.md +++ b/docs/models/components/paymentinitializerequest.md @@ -1,5 +1,83 @@ # PaymentInitializeRequest +## Example Usage + +```typescript +import { + AddressReferenceExplicitTag, + CountryCode, + Currency, + PaymentInitializeRequest, + PaymentMethodKlarnaAccountTag, +} from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentInitializeRequest = { + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, + }, + paymentMethod: { + dotTag: PaymentMethodKlarnaAccountTag.KlarnaAccount, + returnUrl: "www.example.com/handle_klarna_account_success", + }, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethod.md b/docs/models/components/paymentmethod.md index 0d05138a..7c64ae21 100644 --- a/docs/models/components/paymentmethod.md +++ b/docs/models/components/paymentmethod.md @@ -1,5 +1,39 @@ # PaymentMethod +## Example Usage + +```typescript +import { + AddressReferenceExplicitTag, + CountryCode, + CreditCardNetwork, + DotTag, + PaymentMethod, +} from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethod = { + dotTag: DotTag.CreditCard, + id: "X5h6j8uLpVGK", + billingAddress: { + dotTag: AddressReferenceExplicitTag.Explicit, + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + network: CreditCardNetwork.Visa, + last4: "1004", + expiration: "2029-03", +}; +``` ## Supported Types diff --git a/docs/models/components/paymentmethodaffirm.md b/docs/models/components/paymentmethodaffirm.md deleted file mode 100644 index ee3d6b84..00000000 --- a/docs/models/components/paymentmethodaffirm.md +++ /dev/null @@ -1,9 +0,0 @@ -# PaymentMethodAffirm - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| `dotTag` | [components.PaymentMethodAffirmTag](../../models/components/paymentmethodaffirmtag.md) | :heavy_check_mark: | N/A | affirm | -| `returnUrl` | *string* | :heavy_check_mark: | Return URL to return to after payment completion in Affirm. | www.example.com/handle_affirm_success | \ No newline at end of file diff --git a/docs/models/components/paymentmethodaffirmoutput.md b/docs/models/components/paymentmethodaffirmoutput.md index 223a9e52..bdd576fe 100644 --- a/docs/models/components/paymentmethodaffirmoutput.md +++ b/docs/models/components/paymentmethodaffirmoutput.md @@ -1,5 +1,14 @@ # PaymentMethodAffirmOutput +## Example Usage + +```typescript +import { PaymentMethodAffirmOutput, PaymentMethodAffirmTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodAffirmOutput = { + dotTag: PaymentMethodAffirmTag.Affirm, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodaffirmtag.md b/docs/models/components/paymentmethodaffirmtag.md index f943551b..46a57987 100644 --- a/docs/models/components/paymentmethodaffirmtag.md +++ b/docs/models/components/paymentmethodaffirmtag.md @@ -1,5 +1,12 @@ # PaymentMethodAffirmTag +## Example Usage + +```typescript +import { PaymentMethodAffirmTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodAffirmTag = PaymentMethodAffirmTag.Affirm; +``` ## Values diff --git a/docs/models/components/paymentmethodafterpay.md b/docs/models/components/paymentmethodafterpay.md deleted file mode 100644 index ca54b2ff..00000000 --- a/docs/models/components/paymentmethodafterpay.md +++ /dev/null @@ -1,9 +0,0 @@ -# PaymentMethodAfterpay - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | -| `dotTag` | [components.PaymentMethodAfterpayTag](../../models/components/paymentmethodafterpaytag.md) | :heavy_check_mark: | N/A | afterpay | -| `returnUrl` | *string* | :heavy_check_mark: | Return URL to return to after payment completion in Afterpay. | www.example.com/handle_afterpay_success | \ No newline at end of file diff --git a/docs/models/components/paymentmethodafterpayoutput.md b/docs/models/components/paymentmethodafterpayoutput.md index 5fc2cf69..6e35c4e4 100644 --- a/docs/models/components/paymentmethodafterpayoutput.md +++ b/docs/models/components/paymentmethodafterpayoutput.md @@ -1,5 +1,14 @@ # PaymentMethodAfterpayOutput +## Example Usage + +```typescript +import { PaymentMethodAfterpayOutput, PaymentMethodAfterpayTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodAfterpayOutput = { + dotTag: PaymentMethodAfterpayTag.Afterpay, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodafterpaytag.md b/docs/models/components/paymentmethodafterpaytag.md index b53daaf3..63492e50 100644 --- a/docs/models/components/paymentmethodafterpaytag.md +++ b/docs/models/components/paymentmethodafterpaytag.md @@ -1,5 +1,12 @@ # PaymentMethodAfterpayTag +## Example Usage + +```typescript +import { PaymentMethodAfterpayTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodAfterpayTag = PaymentMethodAfterpayTag.Afterpay; +``` ## Values diff --git a/docs/models/components/paymentmethodcreditcard.md b/docs/models/components/paymentmethodcreditcard.md index 37d469bd..9ecf8115 100644 --- a/docs/models/components/paymentmethodcreditcard.md +++ b/docs/models/components/paymentmethodcreditcard.md @@ -1,5 +1,22 @@ # PaymentMethodCreditCard +## Example Usage + +```typescript +import { AddressReferenceIdTag, CreditCardNetwork, DotTag, PaymentMethodCreditCard } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodCreditCard = { + dotTag: DotTag.CreditCard, + id: "X5h6j8uLpVGK", + billingAddress: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, + network: CreditCardNetwork.Visa, + last4: "1004", + expiration: "2029-03", +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodcreditcardinput.md b/docs/models/components/paymentmethodcreditcardinput.md deleted file mode 100644 index 9490ec62..00000000 --- a/docs/models/components/paymentmethodcreditcardinput.md +++ /dev/null @@ -1,14 +0,0 @@ -# PaymentMethodCreditCardInput - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | -| `dotTag` | [components.DotTag](../../models/components/dottag.md) | :heavy_check_mark: | N/A | credit_card | -| `billingAddress` | *components.AddressReferenceInput* | :heavy_check_mark: | N/A | | -| `network` | [components.CreditCardNetwork](../../models/components/creditcardnetwork.md) | :heavy_check_mark: | The credit card's network. | visa | -| `bin` | *string* | :heavy_check_mark: | The Bank Identification Number (BIN). This is typically the first 4 to 6 digits of the account number. | 411111 | -| `last4` | *string* | :heavy_check_mark: | The account number's last four digits. | 1004 | -| `expiration` | *string* | :heavy_check_mark: | The expiration date, in YYYY-MM format. | 2029-03 | -| `token` | *string* | :heavy_check_mark: | The Bolt token associated with the credit card. | a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0 | \ No newline at end of file diff --git a/docs/models/components/paymentmethodextended.md b/docs/models/components/paymentmethodextended.md index 06b5b6b4..87f86ee1 100644 --- a/docs/models/components/paymentmethodextended.md +++ b/docs/models/components/paymentmethodextended.md @@ -1,5 +1,39 @@ # PaymentMethodExtended +## Example Usage + +```typescript +import { + AddressReferenceExplicitTag, + CountryCode, + CreditCardNetwork, + DotTag, + PaymentMethodExtended, +} from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodExtended = { + dotTag: DotTag.CreditCard, + billingAddress: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: "2029-03", + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", +}; +``` ## Supported Types diff --git a/docs/models/components/paymentmethodinput.md b/docs/models/components/paymentmethodinput.md deleted file mode 100644 index 87d43db4..00000000 --- a/docs/models/components/paymentmethodinput.md +++ /dev/null @@ -1,47 +0,0 @@ -# PaymentMethodInput - - -## Supported Types - -### `components.PaymentMethodCreditCardInput` - -```typescript -const value: components.PaymentMethodCreditCardInput = /* values here */ -``` - -### `components.PaymentMethodPaypal` - -```typescript -const value: components.PaymentMethodPaypal = /* values here */ -``` - -### `components.PaymentMethodAffirm` - -```typescript -const value: components.PaymentMethodAffirm = /* values here */ -``` - -### `components.PaymentMethodAfterpay` - -```typescript -const value: components.PaymentMethodAfterpay = /* values here */ -``` - -### `components.PaymentMethodKlarna` - -```typescript -const value: components.PaymentMethodKlarna = /* values here */ -``` - -### `components.PaymentMethodKlarnaAccount` - -```typescript -const value: components.PaymentMethodKlarnaAccount = /* values here */ -``` - -### `components.PaymentMethodKlarnaPaynow` - -```typescript -const value: components.PaymentMethodKlarnaPaynow = /* values here */ -``` - diff --git a/docs/models/components/paymentmethodklarna.md b/docs/models/components/paymentmethodklarna.md deleted file mode 100644 index bceb96ba..00000000 --- a/docs/models/components/paymentmethodklarna.md +++ /dev/null @@ -1,9 +0,0 @@ -# PaymentMethodKlarna - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| `dotTag` | [components.PaymentMethodKlarnaTag](../../models/components/paymentmethodklarnatag.md) | :heavy_check_mark: | N/A | klarna | -| `returnUrl` | *string* | :heavy_check_mark: | Return URL to return to after payment completion in Klarna. | www.example.com/handle_klarna_success | \ No newline at end of file diff --git a/docs/models/components/paymentmethodklarnaaccount.md b/docs/models/components/paymentmethodklarnaaccount.md deleted file mode 100644 index ad2a5758..00000000 --- a/docs/models/components/paymentmethodklarnaaccount.md +++ /dev/null @@ -1,9 +0,0 @@ -# PaymentMethodKlarnaAccount - - -## Fields - -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| `dotTag` | [components.PaymentMethodKlarnaAccountTag](../../models/components/paymentmethodklarnaaccounttag.md) | :heavy_check_mark: | N/A | klarna_account | -| `returnUrl` | *string* | :heavy_check_mark: | Return URL to return to after payment completion in Klarna. | www.example.com/handle_klarna_account_success | \ No newline at end of file diff --git a/docs/models/components/paymentmethodklarnaaccountoutput.md b/docs/models/components/paymentmethodklarnaaccountoutput.md index fece098f..47323975 100644 --- a/docs/models/components/paymentmethodklarnaaccountoutput.md +++ b/docs/models/components/paymentmethodklarnaaccountoutput.md @@ -1,5 +1,14 @@ # PaymentMethodKlarnaAccountOutput +## Example Usage + +```typescript +import { PaymentMethodKlarnaAccountOutput, PaymentMethodKlarnaAccountTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodKlarnaAccountOutput = { + dotTag: PaymentMethodKlarnaAccountTag.KlarnaAccount, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodklarnaaccounttag.md b/docs/models/components/paymentmethodklarnaaccounttag.md index 172c3afc..29fcfbd8 100644 --- a/docs/models/components/paymentmethodklarnaaccounttag.md +++ b/docs/models/components/paymentmethodklarnaaccounttag.md @@ -1,5 +1,12 @@ # PaymentMethodKlarnaAccountTag +## Example Usage + +```typescript +import { PaymentMethodKlarnaAccountTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodKlarnaAccountTag = PaymentMethodKlarnaAccountTag.KlarnaAccount; +``` ## Values diff --git a/docs/models/components/paymentmethodklarnaoutput.md b/docs/models/components/paymentmethodklarnaoutput.md index 6538e87e..1748f168 100644 --- a/docs/models/components/paymentmethodklarnaoutput.md +++ b/docs/models/components/paymentmethodklarnaoutput.md @@ -1,5 +1,14 @@ # PaymentMethodKlarnaOutput +## Example Usage + +```typescript +import { PaymentMethodKlarnaOutput, PaymentMethodKlarnaTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodKlarnaOutput = { + dotTag: PaymentMethodKlarnaTag.Klarna, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodklarnapaynow.md b/docs/models/components/paymentmethodklarnapaynow.md deleted file mode 100644 index 325cfb13..00000000 --- a/docs/models/components/paymentmethodklarnapaynow.md +++ /dev/null @@ -1,9 +0,0 @@ -# PaymentMethodKlarnaPaynow - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -| `dotTag` | [components.PaymentMethodKlarnaPaynowTag](../../models/components/paymentmethodklarnapaynowtag.md) | :heavy_check_mark: | N/A | klarna_paynow | -| `returnUrl` | *string* | :heavy_check_mark: | Return URL to return to after payment completion in Klarna. | www.example.com/handle_klarna_paynow_success | \ No newline at end of file diff --git a/docs/models/components/paymentmethodklarnapaynowoutput.md b/docs/models/components/paymentmethodklarnapaynowoutput.md index 9c60d462..5331e8ce 100644 --- a/docs/models/components/paymentmethodklarnapaynowoutput.md +++ b/docs/models/components/paymentmethodklarnapaynowoutput.md @@ -1,5 +1,14 @@ # PaymentMethodKlarnaPaynowOutput +## Example Usage + +```typescript +import { PaymentMethodKlarnaPaynowOutput, PaymentMethodKlarnaPaynowTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodKlarnaPaynowOutput = { + dotTag: PaymentMethodKlarnaPaynowTag.KlarnaPaynow, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodklarnapaynowtag.md b/docs/models/components/paymentmethodklarnapaynowtag.md index b422e8d6..b70a2751 100644 --- a/docs/models/components/paymentmethodklarnapaynowtag.md +++ b/docs/models/components/paymentmethodklarnapaynowtag.md @@ -1,5 +1,12 @@ # PaymentMethodKlarnaPaynowTag +## Example Usage + +```typescript +import { PaymentMethodKlarnaPaynowTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodKlarnaPaynowTag = PaymentMethodKlarnaPaynowTag.KlarnaPaynow; +``` ## Values diff --git a/docs/models/components/paymentmethodklarnatag.md b/docs/models/components/paymentmethodklarnatag.md index 3e1f3aab..f2a94183 100644 --- a/docs/models/components/paymentmethodklarnatag.md +++ b/docs/models/components/paymentmethodklarnatag.md @@ -1,5 +1,12 @@ # PaymentMethodKlarnaTag +## Example Usage + +```typescript +import { PaymentMethodKlarnaTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodKlarnaTag = PaymentMethodKlarnaTag.Klarna; +``` ## Values diff --git a/docs/models/components/paymentmethodpaypal.md b/docs/models/components/paymentmethodpaypal.md deleted file mode 100644 index e3cff519..00000000 --- a/docs/models/components/paymentmethodpaypal.md +++ /dev/null @@ -1,10 +0,0 @@ -# PaymentMethodPaypal - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| `dotTag` | [components.PaymentMethodPaypalTag](../../models/components/paymentmethodpaypaltag.md) | :heavy_check_mark: | N/A | paypal | -| `successUrl` | *string* | :heavy_check_mark: | Redirect URL for successful PayPal transaction. | https://www.example.com/paypal-callback/success | -| `cancelUrl` | *string* | :heavy_check_mark: | Redirect URL for canceled PayPal transaction. | https://www.example.com/paypal-callback/cancel | \ No newline at end of file diff --git a/docs/models/components/paymentmethodpaypaloutput.md b/docs/models/components/paymentmethodpaypaloutput.md index 39a16a65..dd2f9112 100644 --- a/docs/models/components/paymentmethodpaypaloutput.md +++ b/docs/models/components/paymentmethodpaypaloutput.md @@ -1,5 +1,14 @@ # PaymentMethodPaypalOutput +## Example Usage + +```typescript +import { PaymentMethodPaypalOutput, PaymentMethodPaypalTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodPaypalOutput = { + dotTag: PaymentMethodPaypalTag.Paypal, +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodpaypaltag.md b/docs/models/components/paymentmethodpaypaltag.md index 91ad344d..896aaf12 100644 --- a/docs/models/components/paymentmethodpaypaltag.md +++ b/docs/models/components/paymentmethodpaypaltag.md @@ -1,5 +1,12 @@ # PaymentMethodPaypalTag +## Example Usage + +```typescript +import { PaymentMethodPaypalTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodPaypalTag = PaymentMethodPaypalTag.Paypal; +``` ## Values diff --git a/docs/models/components/paymentmethodreference.md b/docs/models/components/paymentmethodreference.md index f3528b21..65aa7ead 100644 --- a/docs/models/components/paymentmethodreference.md +++ b/docs/models/components/paymentmethodreference.md @@ -1,5 +1,15 @@ # PaymentMethodReference +## Example Usage + +```typescript +import { PaymentMethodReference, PaymentMethodReferenceTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodReference = { + dotTag: PaymentMethodReferenceTag.Id, + id: "X5h6j8uLpVGK", +}; +``` ## Fields diff --git a/docs/models/components/paymentmethodreferencetag.md b/docs/models/components/paymentmethodreferencetag.md index 97978250..604b589d 100644 --- a/docs/models/components/paymentmethodreferencetag.md +++ b/docs/models/components/paymentmethodreferencetag.md @@ -1,5 +1,12 @@ # PaymentMethodReferenceTag +## Example Usage + +```typescript +import { PaymentMethodReferenceTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentMethodReferenceTag = PaymentMethodReferenceTag.Id; +``` ## Values diff --git a/docs/models/components/paymentresponse.md b/docs/models/components/paymentresponse.md index f9bd862e..5969ff6c 100644 --- a/docs/models/components/paymentresponse.md +++ b/docs/models/components/paymentresponse.md @@ -1,5 +1,18 @@ # PaymentResponse +## Example Usage + +```typescript +import { Action, PaymentResponse, PaymentResponsePendingStatus, PaymentResponsePendingTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentResponse = { + dotTag: PaymentResponsePendingTag.Pending, + id: "iKv7t5bgt1gg", + status: PaymentResponsePendingStatus.AwaitingUserConfirmation, + action: Action.Redirect, + url: "www.example.com/payments/finalize", +}; +``` ## Supported Types diff --git a/docs/models/components/paymentresponsefinalized.md b/docs/models/components/paymentresponsefinalized.md index ffbcff22..092b0702 100644 --- a/docs/models/components/paymentresponsefinalized.md +++ b/docs/models/components/paymentresponsefinalized.md @@ -1,5 +1,24 @@ # PaymentResponseFinalized +## Example Usage + +```typescript +import { PaymentResponseFinalized, PaymentResponseFinalizedTag, Status } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentResponseFinalized = { + dotTag: PaymentResponseFinalizedTag.Finalized, + id: "iKv7t5bgt1gg", + status: Status.Success, + transaction: { + reference: "OBYG-X1PX-FN55", + authorizations: [ + { + processorReference: "123456789XYZ", + }, + ], + }, +}; +``` ## Fields diff --git a/docs/models/components/paymentresponsefinalizedtag.md b/docs/models/components/paymentresponsefinalizedtag.md index 8f4a0898..d485a548 100644 --- a/docs/models/components/paymentresponsefinalizedtag.md +++ b/docs/models/components/paymentresponsefinalizedtag.md @@ -1,5 +1,12 @@ # PaymentResponseFinalizedTag +## Example Usage + +```typescript +import { PaymentResponseFinalizedTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentResponseFinalizedTag = PaymentResponseFinalizedTag.Finalized; +``` ## Values diff --git a/docs/models/components/paymentresponsepending.md b/docs/models/components/paymentresponsepending.md index 7fd613a3..9345d6e3 100644 --- a/docs/models/components/paymentresponsepending.md +++ b/docs/models/components/paymentresponsepending.md @@ -1,5 +1,23 @@ # PaymentResponsePending +## Example Usage + +```typescript +import { + Action, + PaymentResponsePending, + PaymentResponsePendingStatus, + PaymentResponsePendingTag, +} from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentResponsePending = { + dotTag: PaymentResponsePendingTag.Pending, + id: "iKv7t5bgt1gg", + status: PaymentResponsePendingStatus.AwaitingUserConfirmation, + action: Action.Redirect, + url: "www.example.com/payments/finalize", +}; +``` ## Fields diff --git a/docs/models/components/paymentresponsependingstatus.md b/docs/models/components/paymentresponsependingstatus.md index 652d0888..a5ae37dc 100644 --- a/docs/models/components/paymentresponsependingstatus.md +++ b/docs/models/components/paymentresponsependingstatus.md @@ -1,5 +1,12 @@ # PaymentResponsePendingStatus +## Example Usage + +```typescript +import { PaymentResponsePendingStatus } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentResponsePendingStatus = PaymentResponsePendingStatus.AwaitingUserConfirmation; +``` ## Values diff --git a/docs/models/components/paymentresponsependingtag.md b/docs/models/components/paymentresponsependingtag.md index 585d82ef..8c2946d4 100644 --- a/docs/models/components/paymentresponsependingtag.md +++ b/docs/models/components/paymentresponsependingtag.md @@ -1,5 +1,12 @@ # PaymentResponsePendingTag +## Example Usage + +```typescript +import { PaymentResponsePendingTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PaymentResponsePendingTag = PaymentResponsePendingTag.Pending; +``` ## Values diff --git a/docs/models/components/phonestate.md b/docs/models/components/phonestate.md index cc81a199..ca8f794f 100644 --- a/docs/models/components/phonestate.md +++ b/docs/models/components/phonestate.md @@ -1,5 +1,12 @@ # PhoneState +## Example Usage + +```typescript +import { PhoneState } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: PhoneState = PhoneState.Verified; +``` ## Values diff --git a/docs/models/components/profile.md b/docs/models/components/profile.md index 2312b465..1621797e 100644 --- a/docs/models/components/profile.md +++ b/docs/models/components/profile.md @@ -2,6 +2,18 @@ An account's identifying information. +## Example Usage + +```typescript +import { Profile } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Profile = { + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", +}; +``` ## Fields diff --git a/docs/models/components/profilecreationdata.md b/docs/models/components/profilecreationdata.md index 5b53c873..d8645ad0 100644 --- a/docs/models/components/profilecreationdata.md +++ b/docs/models/components/profilecreationdata.md @@ -2,6 +2,19 @@ An account's identifying information. +## Example Usage + +```typescript +import { ProfileCreationData } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: ProfileCreationData = { + createAccount: true, + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", +}; +``` ## Fields diff --git a/docs/models/components/refreshtokenrequest.md b/docs/models/components/refreshtokenrequest.md index 467036e8..8c209d0f 100644 --- a/docs/models/components/refreshtokenrequest.md +++ b/docs/models/components/refreshtokenrequest.md @@ -1,5 +1,21 @@ # RefreshTokenRequest +## Example Usage + +```typescript +import { RefreshTokenRequest, RefreshTokenRequestGrantType, RefreshTokenRequestScope } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: RefreshTokenRequest = { + grantType: RefreshTokenRequestGrantType.RefreshToken, + refreshToken: + "4hJYNO4GHvALZoocXoLenfNeFy1RR5ZT6G5JYrFbvkI.Q_PqV0lIszCNoN-85EwD-2nYZOVEepVgJSolx-Jbzrs", + clientId: + "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", + clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", + scope: [RefreshTokenRequestScope.Openid], + state: "xyzABC123", +}; +``` ## Fields diff --git a/docs/models/components/refreshtokenrequestgranttype.md b/docs/models/components/refreshtokenrequestgranttype.md index ed57eae5..d976da37 100644 --- a/docs/models/components/refreshtokenrequestgranttype.md +++ b/docs/models/components/refreshtokenrequestgranttype.md @@ -2,6 +2,13 @@ The type of OAuth 2.0 grant being utilized. +## Example Usage + +```typescript +import { RefreshTokenRequestGrantType } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: RefreshTokenRequestGrantType = RefreshTokenRequestGrantType.RefreshToken; +``` ## Values diff --git a/docs/models/components/refreshtokenrequestscope.md b/docs/models/components/refreshtokenrequestscope.md index 4568c3b6..c568d853 100644 --- a/docs/models/components/refreshtokenrequestscope.md +++ b/docs/models/components/refreshtokenrequestscope.md @@ -1,5 +1,12 @@ # RefreshTokenRequestScope +## Example Usage + +```typescript +import { RefreshTokenRequestScope } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: RefreshTokenRequestScope = RefreshTokenRequestScope.BoltAccountManage; +``` ## Values diff --git a/docs/models/components/scope.md b/docs/models/components/scope.md index 72dc65cf..48d6c14a 100644 --- a/docs/models/components/scope.md +++ b/docs/models/components/scope.md @@ -1,5 +1,12 @@ # Scope +## Example Usage + +```typescript +import { Scope } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Scope = Scope.Openid; +``` ## Values diff --git a/docs/models/components/security.md b/docs/models/components/security.md index 0d61f372..ca5fcb44 100644 --- a/docs/models/components/security.md +++ b/docs/models/components/security.md @@ -1,5 +1,12 @@ # Security +## Example Usage + +```typescript +import { Security } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Security = {}; +``` ## Fields diff --git a/docs/models/components/status.md b/docs/models/components/status.md index e685b542..e2ea5a20 100644 --- a/docs/models/components/status.md +++ b/docs/models/components/status.md @@ -1,5 +1,12 @@ # Status +## Example Usage + +```typescript +import { Status } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Status = Status.Success; +``` ## Values diff --git a/docs/models/components/testcreditcard.md b/docs/models/components/testcreditcard.md index 5acabf30..e193530e 100644 --- a/docs/models/components/testcreditcard.md +++ b/docs/models/components/testcreditcard.md @@ -1,5 +1,18 @@ # TestCreditCard +## Example Usage + +```typescript +import { CreditCardNetwork, TestCreditCard } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: TestCreditCard = { + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: new Date("2023-10-31:T06:00:00Z"), + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", +}; +``` ## Fields diff --git a/docs/models/components/tokenrequest.md b/docs/models/components/tokenrequest.md index 561a2260..8195e8f3 100644 --- a/docs/models/components/tokenrequest.md +++ b/docs/models/components/tokenrequest.md @@ -1,5 +1,20 @@ # TokenRequest +## Example Usage + +```typescript +import { GrantType, Scope, TokenRequest } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: TokenRequest = { + grantType: GrantType.AuthorizationCode, + code: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", + clientId: + "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", + clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", + scope: [Scope.BoltAccountView], + state: "xyzABC123", +}; +``` ## Supported Types diff --git a/docs/models/components/transaction.md b/docs/models/components/transaction.md index bfef97a5..ec897ad7 100644 --- a/docs/models/components/transaction.md +++ b/docs/models/components/transaction.md @@ -1,8 +1,23 @@ # Transaction +## Example Usage + +```typescript +import { Transaction } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: Transaction = { + reference: "OBYG-X1PX-FN55", + authorizations: [ + { + processorReference: "123456789XYZ", + }, + ], +}; +``` ## Fields -| Field | Type | Required | Description | Example | -| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | -| `reference` | *string* | :heavy_minus_sign: | N/A | OBYG-X1PX-FN55 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `reference` | *string* | :heavy_minus_sign: | N/A | OBYG-X1PX-FN55 | +| `authorizations` | [components.TransactionAuthorization](../../models/components/transactionauthorization.md)[] | :heavy_minus_sign: | Payment authorization events attached to a transaction | | \ No newline at end of file diff --git a/docs/models/components/transactionauthorization.md b/docs/models/components/transactionauthorization.md new file mode 100644 index 00000000..53b8c9ff --- /dev/null +++ b/docs/models/components/transactionauthorization.md @@ -0,0 +1,17 @@ +# TransactionAuthorization + +## Example Usage + +```typescript +import { TransactionAuthorization } from "@boltpay/bolt-typescript-sdk/models/components"; + +let value: TransactionAuthorization = { + processorReference: "123456789XYZ", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------- | -------------------- | -------------------- | -------------------- | -------------------- | +| `processorReference` | *string* | :heavy_minus_sign: | N/A | 123456789XYZ | \ No newline at end of file diff --git a/docs/models/errors/accountaddpaymentmethodresponsebody.md b/docs/models/errors/accountaddpaymentmethodresponsebody.md index 3c8931b1..ac2f09dc 100644 --- a/docs/models/errors/accountaddpaymentmethodresponsebody.md +++ b/docs/models/errors/accountaddpaymentmethodresponsebody.md @@ -2,6 +2,13 @@ The payment method is invalid and cannot be added, or some other error has occurred +## Example Usage + +```typescript +import { AccountAddPaymentMethodResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/accountaddresscreateresponsebody.md b/docs/models/errors/accountaddresscreateresponsebody.md index 0e19a7a8..766b2209 100644 --- a/docs/models/errors/accountaddresscreateresponsebody.md +++ b/docs/models/errors/accountaddresscreateresponsebody.md @@ -2,6 +2,13 @@ The address is invalid and cannot be added, or some other error has occurred +## Example Usage + +```typescript +import { AccountAddressCreateResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/accountaddressdeleteresponsebody.md b/docs/models/errors/accountaddressdeleteresponsebody.md index f14f17b0..bcc60bb7 100644 --- a/docs/models/errors/accountaddressdeleteresponsebody.md +++ b/docs/models/errors/accountaddressdeleteresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { AccountAddressDeleteResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/accountaddresseditresponsebody.md b/docs/models/errors/accountaddresseditresponsebody.md index 6c07abe1..3c191be0 100644 --- a/docs/models/errors/accountaddresseditresponsebody.md +++ b/docs/models/errors/accountaddresseditresponsebody.md @@ -2,6 +2,13 @@ The address is invalid and cannot be added, or some other error has occurred +## Example Usage + +```typescript +import { AccountAddressEditResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/accountgetresponsebody.md b/docs/models/errors/accountgetresponsebody.md index 3f85d49c..f5e1234d 100644 --- a/docs/models/errors/accountgetresponsebody.md +++ b/docs/models/errors/accountgetresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { AccountGetResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/accountpaymentmethoddeleteresponsebody.md b/docs/models/errors/accountpaymentmethoddeleteresponsebody.md index e805b9bc..03e1017f 100644 --- a/docs/models/errors/accountpaymentmethoddeleteresponsebody.md +++ b/docs/models/errors/accountpaymentmethoddeleteresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { AccountPaymentMethodDeleteResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/carterror.md b/docs/models/errors/carterror.md index 1bbd2230..57f0f0dd 100644 --- a/docs/models/errors/carterror.md +++ b/docs/models/errors/carterror.md @@ -1,5 +1,12 @@ # CartError +## Example Usage + +```typescript +import { CartError } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/docs/models/errors/creditcarderror.md b/docs/models/errors/creditcarderror.md index 9eb0c4a0..f72ccd0e 100644 --- a/docs/models/errors/creditcarderror.md +++ b/docs/models/errors/creditcarderror.md @@ -1,5 +1,12 @@ # CreditCardError +## Example Usage + +```typescript +import { CreditCardError } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/docs/models/errors/dottag.md b/docs/models/errors/dottag.md index 9f39209e..0211fc38 100644 --- a/docs/models/errors/dottag.md +++ b/docs/models/errors/dottag.md @@ -2,6 +2,13 @@ The type of error returned +## Example Usage + +```typescript +import { DotTag } from "@boltpay/bolt-typescript-sdk/models/errors"; + +let value: DotTag = DotTag.UnprocessableRequest; +``` ## Values diff --git a/docs/models/errors/errort.md b/docs/models/errors/errort.md index 106fa3ff..2e812d46 100644 --- a/docs/models/errors/errort.md +++ b/docs/models/errors/errort.md @@ -1,5 +1,12 @@ # ErrorT +## Example Usage + +```typescript +import { ErrorT } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/docs/models/errors/fielderror.md b/docs/models/errors/fielderror.md index df8628b6..7d37987b 100644 --- a/docs/models/errors/fielderror.md +++ b/docs/models/errors/fielderror.md @@ -2,6 +2,13 @@ An error that pertains to validation of a specific field in the request. +## Example Usage + +```typescript +import { FieldError } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Fields diff --git a/docs/models/errors/guestpaymentsactionresponsebody.md b/docs/models/errors/guestpaymentsactionresponsebody.md index 9f1eecb2..452995b2 100644 --- a/docs/models/errors/guestpaymentsactionresponsebody.md +++ b/docs/models/errors/guestpaymentsactionresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { GuestPaymentsActionResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/guestpaymentsinitializeresponsebody.md b/docs/models/errors/guestpaymentsinitializeresponsebody.md index 943568be..b57c7564 100644 --- a/docs/models/errors/guestpaymentsinitializeresponsebody.md +++ b/docs/models/errors/guestpaymentsinitializeresponsebody.md @@ -2,6 +2,13 @@ The payment operation cannot complete +## Example Usage + +```typescript +import { GuestPaymentsInitializeResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/oauthgettokenresponsebody.md b/docs/models/errors/oauthgettokenresponsebody.md index 69b23b88..b9238057 100644 --- a/docs/models/errors/oauthgettokenresponsebody.md +++ b/docs/models/errors/oauthgettokenresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { OauthGetTokenResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/orderscreateresponsebody.md b/docs/models/errors/orderscreateresponsebody.md index 451b7108..abb8e7d9 100644 --- a/docs/models/errors/orderscreateresponsebody.md +++ b/docs/models/errors/orderscreateresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { OrdersCreateResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/paymentsactionresponsebody.md b/docs/models/errors/paymentsactionresponsebody.md index cfb752af..e01673cc 100644 --- a/docs/models/errors/paymentsactionresponsebody.md +++ b/docs/models/errors/paymentsactionresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { PaymentsActionResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/paymentsinitializeresponsebody.md b/docs/models/errors/paymentsinitializeresponsebody.md index f1fe5263..3dd608c0 100644 --- a/docs/models/errors/paymentsinitializeresponsebody.md +++ b/docs/models/errors/paymentsinitializeresponsebody.md @@ -2,6 +2,13 @@ The payment operation cannot complete +## Example Usage + +```typescript +import { PaymentsInitializeResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/schemascarterrortag.md b/docs/models/errors/schemascarterrortag.md index cc8e16a5..4b948f34 100644 --- a/docs/models/errors/schemascarterrortag.md +++ b/docs/models/errors/schemascarterrortag.md @@ -2,6 +2,13 @@ The type of error returned +## Example Usage + +```typescript +import { SchemasCartErrorTag } from "@boltpay/bolt-typescript-sdk/models/errors"; + +let value: SchemasCartErrorTag = SchemasCartErrorTag.PaymentAlreadyExists; +``` ## Values diff --git a/docs/models/errors/schemascreditcarderrortag.md b/docs/models/errors/schemascreditcarderrortag.md index d3aa4904..3e33def7 100644 --- a/docs/models/errors/schemascreditcarderrortag.md +++ b/docs/models/errors/schemascreditcarderrortag.md @@ -2,6 +2,13 @@ The type of error returned +## Example Usage + +```typescript +import { SchemasCreditCardErrorTag } from "@boltpay/bolt-typescript-sdk/models/errors"; + +let value: SchemasCreditCardErrorTag = SchemasCreditCardErrorTag.DeclinedInvalidCvv; +``` ## Values diff --git a/docs/models/errors/schemastag.md b/docs/models/errors/schemastag.md index 88bc085b..6afcf7ff 100644 --- a/docs/models/errors/schemastag.md +++ b/docs/models/errors/schemastag.md @@ -2,6 +2,13 @@ The type of error returned +## Example Usage + +```typescript +import { SchemasTag } from "@boltpay/bolt-typescript-sdk/models/errors"; + +let value: SchemasTag = SchemasTag.InvalidInputParameter; +``` ## Values diff --git a/docs/models/errors/testingaccountcreateresponsebody.md b/docs/models/errors/testingaccountcreateresponsebody.md index 977afafc..38569a14 100644 --- a/docs/models/errors/testingaccountcreateresponsebody.md +++ b/docs/models/errors/testingaccountcreateresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { TestingAccountCreateResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/testingaccountphonegetresponsebody.md b/docs/models/errors/testingaccountphonegetresponsebody.md index 7897eb75..aa7a1ffe 100644 --- a/docs/models/errors/testingaccountphonegetresponsebody.md +++ b/docs/models/errors/testingaccountphonegetresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { TestingAccountPhoneGetResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/errors/testingcreditcardgetresponsebody.md b/docs/models/errors/testingcreditcardgetresponsebody.md index 21703f87..75c38060 100644 --- a/docs/models/errors/testingcreditcardgetresponsebody.md +++ b/docs/models/errors/testingcreditcardgetresponsebody.md @@ -2,6 +2,13 @@ An error has occurred, and further details are contained in the response +## Example Usage + +```typescript +import { TestingCreditCardGetResponseBody } from "@boltpay/bolt-typescript-sdk/models/errors"; + +// No examples available for this model +``` ## Supported Types diff --git a/docs/models/operations/accountaddpaymentmethodrequest.md b/docs/models/operations/accountaddpaymentmethodrequest.md index d9e587ec..a87c75d5 100644 --- a/docs/models/operations/accountaddpaymentmethodrequest.md +++ b/docs/models/operations/accountaddpaymentmethodrequest.md @@ -1,5 +1,20 @@ # AccountAddPaymentMethodRequest +## Example Usage + +```typescript +import { PaymentMethodKlarnaPaynowTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountAddPaymentMethodRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddPaymentMethodRequest = { + xPublishableKey: "", + xMerchantClientId: "", + paymentMethod: { + dotTag: PaymentMethodKlarnaPaynowTag.KlarnaPaynow, + returnUrl: "www.example.com/handle_klarna_paynow_success", + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountaddpaymentmethodresponse.md b/docs/models/operations/accountaddpaymentmethodresponse.md index bad2df06..ffcb31e8 100644 --- a/docs/models/operations/accountaddpaymentmethodresponse.md +++ b/docs/models/operations/accountaddpaymentmethodresponse.md @@ -1,5 +1,22 @@ # AccountAddPaymentMethodResponse +## Example Usage + +```typescript +import { PaymentMethodKlarnaAccountTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountAddPaymentMethodResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddPaymentMethodResponse = { + contentType: "", + statusCode: 544883, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + paymentMethod: { + dotTag: PaymentMethodKlarnaAccountTag.KlarnaAccount, + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountaddresscreaterequest.md b/docs/models/operations/accountaddresscreaterequest.md index 99bc02a7..00401ac6 100644 --- a/docs/models/operations/accountaddresscreaterequest.md +++ b/docs/models/operations/accountaddresscreaterequest.md @@ -1,5 +1,29 @@ # AccountAddressCreateRequest +## Example Usage + +```typescript +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountAddressCreateRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddressCreateRequest = { + xPublishableKey: "", + xMerchantClientId: "", + addressListing: { + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountaddresscreateresponse.md b/docs/models/operations/accountaddresscreateresponse.md index 56b424b8..e90715b4 100644 --- a/docs/models/operations/accountaddresscreateresponse.md +++ b/docs/models/operations/accountaddresscreateresponse.md @@ -1,5 +1,34 @@ # AccountAddressCreateResponse +## Example Usage + +```typescript +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountAddressCreateResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddressCreateResponse = { + contentType: "", + statusCode: 715190, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + addressListing: { + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + isDefault: true, + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountaddressdeleterequest.md b/docs/models/operations/accountaddressdeleterequest.md index ef74d859..4c781970 100644 --- a/docs/models/operations/accountaddressdeleterequest.md +++ b/docs/models/operations/accountaddressdeleterequest.md @@ -1,5 +1,16 @@ # AccountAddressDeleteRequest +## Example Usage + +```typescript +import { AccountAddressDeleteRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddressDeleteRequest = { + id: "D4g3h5tBuVYK9", + xPublishableKey: "", + xMerchantClientId: "", +}; +``` ## Fields diff --git a/docs/models/operations/accountaddressdeleteresponse.md b/docs/models/operations/accountaddressdeleteresponse.md index 7180e7f7..a3899ee4 100644 --- a/docs/models/operations/accountaddressdeleteresponse.md +++ b/docs/models/operations/accountaddressdeleteresponse.md @@ -1,5 +1,18 @@ # AccountAddressDeleteResponse +## Example Usage + +```typescript +import { AccountAddressDeleteResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddressDeleteResponse = { + contentType: "", + statusCode: 602763, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/docs/models/operations/accountaddresseditrequest.md b/docs/models/operations/accountaddresseditrequest.md index b87fcc3f..5fa3d783 100644 --- a/docs/models/operations/accountaddresseditrequest.md +++ b/docs/models/operations/accountaddresseditrequest.md @@ -1,5 +1,30 @@ # AccountAddressEditRequest +## Example Usage + +```typescript +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountAddressEditRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddressEditRequest = { + id: "D4g3h5tBuVYK9", + xPublishableKey: "", + xMerchantClientId: "", + addressListing: { + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountaddresseditresponse.md b/docs/models/operations/accountaddresseditresponse.md index 50ea08ef..b8326c33 100644 --- a/docs/models/operations/accountaddresseditresponse.md +++ b/docs/models/operations/accountaddresseditresponse.md @@ -1,5 +1,34 @@ # AccountAddressEditResponse +## Example Usage + +```typescript +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountAddressEditResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountAddressEditResponse = { + contentType: "", + statusCode: 844266, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + addressListing: { + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + isDefault: true, + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountgetrequest.md b/docs/models/operations/accountgetrequest.md index c99c5209..1b6ddd4a 100644 --- a/docs/models/operations/accountgetrequest.md +++ b/docs/models/operations/accountgetrequest.md @@ -1,5 +1,15 @@ # AccountGetRequest +## Example Usage + +```typescript +import { AccountGetRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountGetRequest = { + xPublishableKey: "", + xMerchantClientId: "", +}; +``` ## Fields diff --git a/docs/models/operations/accountgetresponse.md b/docs/models/operations/accountgetresponse.md index 30868802..f8456c94 100644 --- a/docs/models/operations/accountgetresponse.md +++ b/docs/models/operations/accountgetresponse.md @@ -1,5 +1,49 @@ # AccountGetResponse +## Example Usage + +```typescript +import { CountryCode, PaymentMethodKlarnaTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AccountGetResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountGetResponse = { + contentType: "", + statusCode: 548814, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + account: { + addresses: [ + { + id: "D4g3h5tBuVYK9", + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + isDefault: true, + }, + ], + paymentMethods: [ + { + dotTag: PaymentMethodKlarnaTag.Klarna, + }, + ], + profile: { + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/accountpaymentmethoddeleterequest.md b/docs/models/operations/accountpaymentmethoddeleterequest.md index 27d9ab30..2d10b1a5 100644 --- a/docs/models/operations/accountpaymentmethoddeleterequest.md +++ b/docs/models/operations/accountpaymentmethoddeleterequest.md @@ -1,5 +1,16 @@ # AccountPaymentMethodDeleteRequest +## Example Usage + +```typescript +import { AccountPaymentMethodDeleteRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountPaymentMethodDeleteRequest = { + id: "D4g3h5tBuVYK9", + xPublishableKey: "", + xMerchantClientId: "", +}; +``` ## Fields diff --git a/docs/models/operations/accountpaymentmethoddeleteresponse.md b/docs/models/operations/accountpaymentmethoddeleteresponse.md index aa243b9e..b94e5b85 100644 --- a/docs/models/operations/accountpaymentmethoddeleteresponse.md +++ b/docs/models/operations/accountpaymentmethoddeleteresponse.md @@ -1,5 +1,18 @@ # AccountPaymentMethodDeleteResponse +## Example Usage + +```typescript +import { AccountPaymentMethodDeleteResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: AccountPaymentMethodDeleteResponse = { + contentType: "", + statusCode: 423655, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), +}; +``` ## Fields diff --git a/docs/models/operations/guestpaymentsactionrequest.md b/docs/models/operations/guestpaymentsactionrequest.md index 6fb86609..36722d19 100644 --- a/docs/models/operations/guestpaymentsactionrequest.md +++ b/docs/models/operations/guestpaymentsactionrequest.md @@ -1,5 +1,21 @@ # GuestPaymentsActionRequest +## Example Usage + +```typescript +import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { GuestPaymentsActionRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: GuestPaymentsActionRequest = { + id: "iKv7t5bgt1gg", + xPublishableKey: "", + xMerchantClientId: "", + paymentActionRequest: { + dotTag: PaymentActionRequestTag.Finalize, + redirectResult: "eyJ0cmFuc", + }, +}; +``` ## Fields diff --git a/docs/models/operations/guestpaymentsactionresponse.md b/docs/models/operations/guestpaymentsactionresponse.md index 1b837ccc..cea23723 100644 --- a/docs/models/operations/guestpaymentsactionresponse.md +++ b/docs/models/operations/guestpaymentsactionresponse.md @@ -1,5 +1,26 @@ # GuestPaymentsActionResponse +## Example Usage + +```typescript +import { Action, PaymentResponsePendingStatus, PaymentResponsePendingTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { GuestPaymentsActionResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: GuestPaymentsActionResponse = { + contentType: "", + statusCode: 477665, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + paymentResponse: { + dotTag: PaymentResponsePendingTag.Pending, + id: "iKv7t5bgt1gg", + status: PaymentResponsePendingStatus.AwaitingUserConfirmation, + action: Action.Redirect, + url: "www.example.com/payments/finalize", + }, +}; +``` ## Fields diff --git a/docs/models/operations/guestpaymentsactionsecurity.md b/docs/models/operations/guestpaymentsactionsecurity.md index 94464c7d..3df8fad1 100644 --- a/docs/models/operations/guestpaymentsactionsecurity.md +++ b/docs/models/operations/guestpaymentsactionsecurity.md @@ -1,5 +1,14 @@ # GuestPaymentsActionSecurity +## Example Usage + +```typescript +import { GuestPaymentsActionSecurity } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: GuestPaymentsActionSecurity = { + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/guestpaymentsinitializerequest.md b/docs/models/operations/guestpaymentsinitializerequest.md index 2a74250c..d2aca216 100644 --- a/docs/models/operations/guestpaymentsinitializerequest.md +++ b/docs/models/operations/guestpaymentsinitializerequest.md @@ -1,5 +1,79 @@ # GuestPaymentsInitializeRequest +## Example Usage + +```typescript +import { AddressReferenceIdTag, Currency, PaymentMethodKlarnaPaynowTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { GuestPaymentsInitializeRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: GuestPaymentsInitializeRequest = { + xPublishableKey: "", + xMerchantClientId: "", + guestPaymentInitializeRequest: { + profile: { + createAccount: true, + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, + }, + paymentMethod: { + dotTag: PaymentMethodKlarnaPaynowTag.KlarnaPaynow, + returnUrl: "www.example.com/handle_klarna_paynow_success", + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/guestpaymentsinitializeresponse.md b/docs/models/operations/guestpaymentsinitializeresponse.md index 493824a1..a39550a9 100644 --- a/docs/models/operations/guestpaymentsinitializeresponse.md +++ b/docs/models/operations/guestpaymentsinitializeresponse.md @@ -1,5 +1,32 @@ # GuestPaymentsInitializeResponse +## Example Usage + +```typescript +import { PaymentResponseFinalizedTag, Status } from "@boltpay/bolt-typescript-sdk/models/components"; +import { GuestPaymentsInitializeResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: GuestPaymentsInitializeResponse = { + contentType: "", + statusCode: 272656, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + paymentResponse: { + dotTag: PaymentResponseFinalizedTag.Finalized, + id: "iKv7t5bgt1gg", + status: Status.Success, + transaction: { + reference: "OBYG-X1PX-FN55", + authorizations: [ + { + processorReference: "123456789XYZ", + }, + ], + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/guestpaymentsinitializesecurity.md b/docs/models/operations/guestpaymentsinitializesecurity.md index 909ddd2c..c28be0d2 100644 --- a/docs/models/operations/guestpaymentsinitializesecurity.md +++ b/docs/models/operations/guestpaymentsinitializesecurity.md @@ -1,5 +1,14 @@ # GuestPaymentsInitializeSecurity +## Example Usage + +```typescript +import { GuestPaymentsInitializeSecurity } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: GuestPaymentsInitializeSecurity = { + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/oauthgettokenrequest.md b/docs/models/operations/oauthgettokenrequest.md index 4d62c790..387ca01c 100644 --- a/docs/models/operations/oauthgettokenrequest.md +++ b/docs/models/operations/oauthgettokenrequest.md @@ -1,5 +1,24 @@ # OauthGetTokenRequest +## Example Usage + +```typescript +import { GrantType, Scope } from "@boltpay/bolt-typescript-sdk/models/components"; +import { OauthGetTokenRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: OauthGetTokenRequest = { + xMerchantClientId: "", + tokenRequest: { + grantType: GrantType.AuthorizationCode, + code: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", + clientId: + "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", + clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", + scope: [Scope.BoltAccountView], + state: "xyzABC123", + }, +}; +``` ## Fields diff --git a/docs/models/operations/oauthgettokenresponse.md b/docs/models/operations/oauthgettokenresponse.md index 3b43377c..8436d669 100644 --- a/docs/models/operations/oauthgettokenresponse.md +++ b/docs/models/operations/oauthgettokenresponse.md @@ -1,5 +1,30 @@ # OauthGetTokenResponse +## Example Usage + +```typescript +import { OauthGetTokenResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: OauthGetTokenResponse = { + contentType: "", + statusCode: 392785, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + getAccessTokenResponse: { + idToken: + "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFsaWNlQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6MTcwNTY1MTczMSwiZmlyc3RfbmFtZSI6IkFsaWNlIiwiaXNzIjoiaHR0cDovL2FwaS5ib2x0LmNvbSIsImxhc3RfbmFtZSI6IkJha2VyIiwicGhvbmVfbnVtYmVyIjoiKzE0MTU1NTUwMTk5IiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjp0cnVlLCJpYXQiOjE3MDU2NDg0MjF9.Ir0aKx40zfNCZol1DnqchFx9ciHlyZY9y10mndEjOBHhpHif8-7aZl2UoJVs_0Hj-5ArEouUD6n-y1SJD0Wns-gDMoA0Etoc5dT_0zt0Kw5T8FvJWbyKyyGSDEwPFVADIRxDPMpVoHx0C0nwr_GudnIX7YG6p2HCsoGm2C04ZxKpifSixB3-xNB6k9u1ESWh0KjMCYzBQ2x9wbQ_S6kFtio075PFYcZ3iRQz8oD15NsZDd2czzZkRnGTGlpG0sAvScLXMvDDOWBIu-4wvOEOT7avunJQ_rOCYUlyJe7JGh0QllpeJNau8kx-4YGMeFTkeGM_hPIKsRF1e6o_rWp5CMJnmJDPme-zlJxWodyaHNed5XW-4DR7blv_PFOJNrRvymRoTOd74LIpS21GRCNYrphj7N6-TsSfO9hMQ9ehxrgNAryWbVtTM_3VvWyzX-SRa7BcRkS97sokxc04s3cbXra3x6brE3uL1yoOWNf8GDZNkv1uUAnrOZcTuLacrPjkQgOPb-chMiWS1L0Zd1wX3rqpeCyEswsGKxRRkpgwoBaVVQmLB9m51B6SXEvURTcy2Hx8KzgfXQ_-uC-KrniQxWzYms8A1lypKXkEcyMD2E4Q7EB4UeD2qZAk4tZo611uHegaHaEM7EQyFN3nxvibaqFpXzdxVmOCX0_wQr1nDNA", + accessToken: + "KCqordmSK6_lpkaXaXfGD8LwnKMGGOYy4Ju2IaBXpJI.CzOF7QOmGGQEgIzBjxOEh1FbRdDpzf9zbm9eHrCZ6zw", + expiresIn: 3600, + refreshToken: + "4hJYNO4GHvALZoocXoLenfNeFy1RR5ZT6G5JYrFbvkI.Q_PqV0lIszCNoN-85EwD-2nYZOVEepVgJSolx-Jbzrs", + refreshTokenScope: "bolt.account.view", + scope: "bolt.account.manage openid", + tokenType: "bearer", + }, +}; +``` ## Fields diff --git a/docs/models/operations/orderscreaterequest.md b/docs/models/operations/orderscreaterequest.md index 831d8318..148cc6c0 100644 --- a/docs/models/operations/orderscreaterequest.md +++ b/docs/models/operations/orderscreaterequest.md @@ -1,5 +1,84 @@ # OrdersCreateRequest +## Example Usage + +```typescript +import { AddressReferenceExplicitTag, CountryCode, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; +import { OrdersCreateRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: OrdersCreateRequest = { + xPublishableKey: "", + xMerchantClientId: "", + order: { + profile: { + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/orderscreateresponse.md b/docs/models/operations/orderscreateresponse.md index c0efc147..f1c42df9 100644 --- a/docs/models/operations/orderscreateresponse.md +++ b/docs/models/operations/orderscreateresponse.md @@ -1,5 +1,29 @@ # OrdersCreateResponse +## Example Usage + +```typescript +import { OrdersCreateResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: OrdersCreateResponse = { + contentType: "", + statusCode: 528895, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + orderResponse: { + id: "iKv7t5bgt1gg", + transaction: { + reference: "OBYG-X1PX-FN55", + authorizations: [ + { + processorReference: "123456789XYZ", + }, + ], + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/orderscreatesecurity.md b/docs/models/operations/orderscreatesecurity.md index 6737f502..d5637862 100644 --- a/docs/models/operations/orderscreatesecurity.md +++ b/docs/models/operations/orderscreatesecurity.md @@ -1,5 +1,14 @@ # OrdersCreateSecurity +## Example Usage + +```typescript +import { OrdersCreateSecurity } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: OrdersCreateSecurity = { + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/paymentsactionrequest.md b/docs/models/operations/paymentsactionrequest.md index 4c83c1b4..47588894 100644 --- a/docs/models/operations/paymentsactionrequest.md +++ b/docs/models/operations/paymentsactionrequest.md @@ -1,5 +1,21 @@ # PaymentsActionRequest +## Example Usage + +```typescript +import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { PaymentsActionRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: PaymentsActionRequest = { + id: "iKv7t5bgt1gg", + xPublishableKey: "", + xMerchantClientId: "", + paymentActionRequest: { + dotTag: PaymentActionRequestTag.Finalize, + redirectResult: "eyJ0cmFuc", + }, +}; +``` ## Fields diff --git a/docs/models/operations/paymentsactionresponse.md b/docs/models/operations/paymentsactionresponse.md index 4e068179..4e98ec27 100644 --- a/docs/models/operations/paymentsactionresponse.md +++ b/docs/models/operations/paymentsactionresponse.md @@ -1,5 +1,26 @@ # PaymentsActionResponse +## Example Usage + +```typescript +import { Action, PaymentResponsePendingStatus, PaymentResponsePendingTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { PaymentsActionResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: PaymentsActionResponse = { + contentType: "", + statusCode: 297534, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + paymentResponse: { + dotTag: PaymentResponsePendingTag.Pending, + id: "iKv7t5bgt1gg", + status: PaymentResponsePendingStatus.AwaitingUserConfirmation, + action: Action.Redirect, + url: "www.example.com/payments/finalize", + }, +}; +``` ## Fields diff --git a/docs/models/operations/paymentsinitializerequest.md b/docs/models/operations/paymentsinitializerequest.md index 8af20250..dabe646b 100644 --- a/docs/models/operations/paymentsinitializerequest.md +++ b/docs/models/operations/paymentsinitializerequest.md @@ -1,5 +1,82 @@ # PaymentsInitializeRequest +## Example Usage + +```typescript +import { AddressReferenceExplicitTag, CountryCode, Currency, PaymentMethodKlarnaTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { PaymentsInitializeRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: PaymentsInitializeRequest = { + xPublishableKey: "", + xMerchantClientId: "", + paymentInitializeRequest: { + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 900, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 900, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 900, + }, + tax: { + currency: Currency.Usd, + units: 900, + }, + }, + paymentMethod: { + dotTag: PaymentMethodKlarnaTag.Klarna, + returnUrl: "www.example.com/handle_klarna_success", + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/paymentsinitializeresponse.md b/docs/models/operations/paymentsinitializeresponse.md index 2048b57e..7e24e274 100644 --- a/docs/models/operations/paymentsinitializeresponse.md +++ b/docs/models/operations/paymentsinitializeresponse.md @@ -1,5 +1,32 @@ # PaymentsInitializeResponse +## Example Usage + +```typescript +import { PaymentResponseFinalizedTag, Status } from "@boltpay/bolt-typescript-sdk/models/components"; +import { PaymentsInitializeResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: PaymentsInitializeResponse = { + contentType: "", + statusCode: 384382, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + paymentResponse: { + dotTag: PaymentResponseFinalizedTag.Finalized, + id: "iKv7t5bgt1gg", + status: Status.Success, + transaction: { + reference: "OBYG-X1PX-FN55", + authorizations: [ + { + processorReference: "123456789XYZ", + }, + ], + }, + }, +}; +``` ## Fields diff --git a/docs/models/operations/testingaccountcreaterequest.md b/docs/models/operations/testingaccountcreaterequest.md index fa13c2cf..9212b809 100644 --- a/docs/models/operations/testingaccountcreaterequest.md +++ b/docs/models/operations/testingaccountcreaterequest.md @@ -1,5 +1,22 @@ # TestingAccountCreateRequest +## Example Usage + +```typescript +import { EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/components"; +import { TestingAccountCreateRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingAccountCreateRequest = { + xPublishableKey: "", + accountTestCreationData: { + emailState: EmailState.Unverified, + phoneState: PhoneState.Verified, + isMigrated: true, + hasAddress: true, + hasCreditCard: true, + }, +}; +``` ## Fields diff --git a/docs/models/operations/testingaccountcreateresponse.md b/docs/models/operations/testingaccountcreateresponse.md index 4049b73a..191d65b6 100644 --- a/docs/models/operations/testingaccountcreateresponse.md +++ b/docs/models/operations/testingaccountcreateresponse.md @@ -1,5 +1,27 @@ # TestingAccountCreateResponse +## Example Usage + +```typescript +import { EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/components"; +import { TestingAccountCreateResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingAccountCreateResponse = { + contentType: "", + statusCode: 925597, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + accountTestCreationData: { + email: "alice@example.com", + emailState: EmailState.Unverified, + phone: "+14155550199", + phoneState: PhoneState.Verified, + otpCode: "123456", + oauthCode: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", + }, +}; +``` ## Fields diff --git a/docs/models/operations/testingaccountcreatesecurity.md b/docs/models/operations/testingaccountcreatesecurity.md index a6c57c27..52c3641f 100644 --- a/docs/models/operations/testingaccountcreatesecurity.md +++ b/docs/models/operations/testingaccountcreatesecurity.md @@ -1,5 +1,14 @@ # TestingAccountCreateSecurity +## Example Usage + +```typescript +import { TestingAccountCreateSecurity } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingAccountCreateSecurity = { + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/testingaccountphonegetrequest.md b/docs/models/operations/testingaccountphonegetrequest.md index 241ba08e..55cf028a 100644 --- a/docs/models/operations/testingaccountphonegetrequest.md +++ b/docs/models/operations/testingaccountphonegetrequest.md @@ -1,5 +1,14 @@ # TestingAccountPhoneGetRequest +## Example Usage + +```typescript +import { TestingAccountPhoneGetRequest } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingAccountPhoneGetRequest = { + xPublishableKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/testingaccountphonegetresponse.md b/docs/models/operations/testingaccountphonegetresponse.md index 5db226fd..d91ab10d 100644 --- a/docs/models/operations/testingaccountphonegetresponse.md +++ b/docs/models/operations/testingaccountphonegetresponse.md @@ -1,5 +1,21 @@ # TestingAccountPhoneGetResponse +## Example Usage + +```typescript +import { TestingAccountPhoneGetResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingAccountPhoneGetResponse = { + contentType: "", + statusCode: 836079, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + accountTestPhoneData: { + phone: "+14155550199", + }, +}; +``` ## Fields diff --git a/docs/models/operations/testingaccountphonegetsecurity.md b/docs/models/operations/testingaccountphonegetsecurity.md index 5ce67751..54507075 100644 --- a/docs/models/operations/testingaccountphonegetsecurity.md +++ b/docs/models/operations/testingaccountphonegetsecurity.md @@ -1,5 +1,14 @@ # TestingAccountPhoneGetSecurity +## Example Usage + +```typescript +import { TestingAccountPhoneGetSecurity } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingAccountPhoneGetSecurity = { + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/testingcreditcardgetrequestbody.md b/docs/models/operations/testingcreditcardgetrequestbody.md index d16265b9..462bea3a 100644 --- a/docs/models/operations/testingcreditcardgetrequestbody.md +++ b/docs/models/operations/testingcreditcardgetrequestbody.md @@ -1,5 +1,14 @@ # TestingCreditCardGetRequestBody +## Example Usage + +```typescript +import { TestingCreditCardGetRequestBody, Type } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingCreditCardGetRequestBody = { + type: Type.Approve, +}; +``` ## Fields diff --git a/docs/models/operations/testingcreditcardgetresponse.md b/docs/models/operations/testingcreditcardgetresponse.md index 789a211f..ae15c708 100644 --- a/docs/models/operations/testingcreditcardgetresponse.md +++ b/docs/models/operations/testingcreditcardgetresponse.md @@ -1,5 +1,26 @@ # TestingCreditCardGetResponse +## Example Usage + +```typescript +import { CreditCardNetwork } from "@boltpay/bolt-typescript-sdk/models/components"; +import { TestingCreditCardGetResponse } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingCreditCardGetResponse = { + contentType: "", + statusCode: 71036, + rawResponse: new Response('{"message": "hello world"}', { + headers: { "Content-Type": "application/json" }, + }), + testCreditCard: { + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: new Date("2023-10-31:T06:00:00Z"), + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", + }, +}; +``` ## Fields diff --git a/docs/models/operations/testingcreditcardgetsecurity.md b/docs/models/operations/testingcreditcardgetsecurity.md index 7980042f..8e98d031 100644 --- a/docs/models/operations/testingcreditcardgetsecurity.md +++ b/docs/models/operations/testingcreditcardgetsecurity.md @@ -1,5 +1,14 @@ # TestingCreditCardGetSecurity +## Example Usage + +```typescript +import { TestingCreditCardGetSecurity } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: TestingCreditCardGetSecurity = { + apiKey: "", +}; +``` ## Fields diff --git a/docs/models/operations/type.md b/docs/models/operations/type.md index cabc9fd4..395ac1ab 100644 --- a/docs/models/operations/type.md +++ b/docs/models/operations/type.md @@ -2,6 +2,13 @@ The expected authorization result when using the generated token for a payment. +## Example Usage + +```typescript +import { Type } from "@boltpay/bolt-typescript-sdk/models/operations"; + +let value: Type = Type.Approve; +``` ## Values diff --git a/docs/sdks/account/README.md b/docs/sdks/account/README.md index f33764a7..169daf55 100644 --- a/docs/sdks/account/README.md +++ b/docs/sdks/account/README.md @@ -26,11 +26,45 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); async function run() { const result = await boltTypescriptSDK.account.getDetails("", ""); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountGetDetails } from "@boltpay/bolt-typescript-sdk/funcs/accountGetDetails.js"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountGetDetails(boltTypescriptSDK, "", ""); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -49,16 +83,18 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.AccountGetResponse](../../models/operations/accountgetresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ----------------------------- | ----------------------------- | ----------------------------- | -| errors.AccountGetResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## addAddress @@ -73,6 +109,7 @@ import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -90,6 +127,52 @@ async function run() { email: "alice@example.com", phone: "+14155550199", }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountAddAddress } from "@boltpay/bolt-typescript-sdk/funcs/accountAddAddress.js"; +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountAddAddress(boltTypescriptSDK, "", "", { + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -109,16 +192,18 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.AccountAddressCreateResponse](../../models/operations/accountaddresscreateresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------------------- | --------------------------------------- | --------------------------------------- | -| errors.AccountAddressCreateResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## updateAddress @@ -133,6 +218,7 @@ import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -150,6 +236,52 @@ async function run() { email: "alice@example.com", phone: "+14155550199", }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountUpdateAddress } from "@boltpay/bolt-typescript-sdk/funcs/accountUpdateAddress.js"; +import { CountryCode } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountUpdateAddress(boltTypescriptSDK, "D4g3h5tBuVYK9", "", "", { + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -170,16 +302,18 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.AccountAddressEditResponse](../../models/operations/accountaddresseditresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------------- | ------------------------------------- | ------------------------------------- | -| errors.AccountAddressEditResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## deleteAddress @@ -193,11 +327,45 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); async function run() { const result = await boltTypescriptSDK.account.deleteAddress("D4g3h5tBuVYK9", "", ""); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountDeleteAddress } from "@boltpay/bolt-typescript-sdk/funcs/accountDeleteAddress.js"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountDeleteAddress(boltTypescriptSDK, "D4g3h5tBuVYK9", "", ""); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -217,16 +385,18 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.AccountAddressDeleteResponse](../../models/operations/accountaddressdeleteresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------------------- | --------------------------------------- | --------------------------------------- | -| errors.AccountAddressDeleteResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## addPaymentMethod @@ -241,22 +411,68 @@ import { AddressReferenceIdTag, CreditCardNetwork, DotTag } from "@boltpay/bolt- const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); async function run() { const result = await boltTypescriptSDK.account.addPaymentMethod("", "", { - dotTag: DotTag.CreditCard, - billingAddress: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", - }, - network: CreditCardNetwork.Visa, - bin: "411111", - last4: "1004", - expiration: "2025-03", - token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", - }); + dotTag: DotTag.CreditCard, + billingAddress: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: "2025-03", + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountAddPaymentMethod } from "@boltpay/bolt-typescript-sdk/funcs/accountAddPaymentMethod.js"; +import { AddressReferenceIdTag, CreditCardNetwork, DotTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountAddPaymentMethod(boltTypescriptSDK, "", "", { + dotTag: DotTag.CreditCard, + billingAddress: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: "2025-03", + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -276,16 +492,19 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.AccountAddPaymentMethodResponse](../../models/operations/accountaddpaymentmethodresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | -| errors.AccountAddPaymentMethodResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ---------------------- | ---------------------- | ---------------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.CreditCardError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## deletePaymentMethod @@ -299,11 +518,45 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); async function run() { const result = await boltTypescriptSDK.account.deletePaymentMethod("D4g3h5tBuVYK9", "", ""); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { accountDeletePaymentMethod } from "@boltpay/bolt-typescript-sdk/funcs/accountDeletePaymentMethod.js"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await accountDeletePaymentMethod(boltTypescriptSDK, "D4g3h5tBuVYK9", "", ""); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -323,13 +576,14 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.AccountPaymentMethodDeleteResponse](../../models/operations/accountpaymentmethoddeleteresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | -| errors.AccountPaymentMethodDeleteResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/docs/sdks/bolttypescriptsdk/README.md b/docs/sdks/bolttypescriptsdk/README.md index c388cd2e..bd94c5f6 100644 --- a/docs/sdks/bolttypescriptsdk/README.md +++ b/docs/sdks/bolttypescriptsdk/README.md @@ -1,9 +1,5 @@ # BoltTypescriptSDK - ## Overview -Bolt API Reference: A comprehensive Bolt API reference for interacting with Accounts, Payments, Orders and more. - -### Available Operations - +Bolt API Reference: A comprehensive Bolt API reference for interacting with Accounts, Payments, Orders and more. \ No newline at end of file diff --git a/docs/sdks/guest/README.md b/docs/sdks/guest/README.md index cef80262..779ef771 100644 --- a/docs/sdks/guest/README.md +++ b/docs/sdks/guest/README.md @@ -1,6 +1,8 @@ # Guest (*payments.guest*) +## Overview + ### Available Operations * [initialize](#initialize) - Initialize a Bolt payment for guest shoppers @@ -14,12 +16,14 @@ Initialize a Bolt guest shopper's intent to pay for a cart, using the specified ```typescript import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; -import { AddressReferenceIdTag, CreditCardNetwork, Currency, DotTag } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AddressReferenceExplicitTag, CountryCode, CreditCardNetwork, Currency, DotTag } from "@boltpay/bolt-typescript-sdk/models/components"; const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { - const result = await boltTypescriptSDK.payments.guest.initialize("", "", "", { + const result = await boltTypescriptSDK.payments.guest.initialize({ + apiKey: "", + }, "", "", { profile: { createAccount: true, firstName: "Alice", @@ -33,10 +37,20 @@ async function run() { displayId: "215614191", shipments: [ { - address: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", - }, + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, cost: { currency: Currency.Usd, units: 10000, @@ -77,20 +91,151 @@ async function run() { units: 100, }, }, - paymentMethod: { - dotTag: DotTag.CreditCard, - billingAddress: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", + paymentMethod: { + dotTag: DotTag.CreditCard, + billingAddress: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: "2025-03", + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", + }, + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { paymentsGuestInitialize } from "@boltpay/bolt-typescript-sdk/funcs/paymentsGuestInitialize.js"; +import { AddressReferenceExplicitTag, CountryCode, CreditCardNetwork, Currency, DotTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await paymentsGuestInitialize(boltTypescriptSDK, { + apiKey: "", + }, "", "", { + profile: { + createAccount: true, + firstName: "Alice", + lastName: "Baker", + email: "alice@example.com", + phone: "+14155550199", + }, + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 10000, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 10000, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 9000, }, - network: CreditCardNetwork.Visa, - bin: "411111", - last4: "1004", - expiration: "2025-03", - token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", + unitPrice: 1000, + quantity: 9, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 9000, + }, + tax: { + currency: Currency.Usd, + units: 100, + }, + }, + paymentMethod: { + dotTag: DotTag.CreditCard, + billingAddress: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Alice", + lastName: "Baker", + company: "ACME Corporation", + streetAddress1: "535 Mission St, Ste 1401", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", }, + network: CreditCardNetwork.Visa, + bin: "411111", + last4: "1004", + expiration: "2025-03", + token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0", + }, }); + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + // Handle the result console.log(result) } @@ -110,16 +255,20 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.GuestPaymentsInitializeResponse](../../models/operations/guestpaymentsinitializeresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | -| errors.GuestPaymentsInitializeResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ---------------------- | ---------------------- | ---------------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.CartError | 4XX | application/json | +| errors.CreditCardError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## performAction @@ -134,11 +283,47 @@ import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/com const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { - const result = await boltTypescriptSDK.payments.guest.performAction("", "iKv7t5bgt1gg", "", "", { + const result = await boltTypescriptSDK.payments.guest.performAction({ + apiKey: "", + }, "iKv7t5bgt1gg", "", "", { + dotTag: PaymentActionRequestTag.Finalize, + redirectResult: "eyJ0cmFuc", + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { paymentsGuestPerformAction } from "@boltpay/bolt-typescript-sdk/funcs/paymentsGuestPerformAction.js"; +import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await paymentsGuestPerformAction(boltTypescriptSDK, { + apiKey: "", + }, "iKv7t5bgt1gg", "", "", { dotTag: PaymentActionRequestTag.Finalize, redirectResult: "eyJ0cmFuc", }); + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + // Handle the result console.log(result) } @@ -159,13 +344,14 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.GuestPaymentsActionResponse](../../models/operations/guestpaymentsactionresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| errors.GuestPaymentsActionResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/docs/sdks/loggedin/README.md b/docs/sdks/loggedin/README.md index 32e1db40..bac12ffc 100644 --- a/docs/sdks/loggedin/README.md +++ b/docs/sdks/loggedin/README.md @@ -1,6 +1,8 @@ # LoggedIn (*payments.loggedIn*) +## Overview + ### Available Operations * [initialize](#initialize) - Initialize a Bolt payment for logged in shoppers @@ -20,6 +22,7 @@ import { AddressReferenceIdTag, Currency, PaymentMethodReferenceTag } from "@bol const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -31,10 +34,10 @@ async function run() { displayId: "215614191", shipments: [ { - address: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", - }, + address: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, cost: { currency: Currency.Usd, units: 10000, @@ -75,12 +78,101 @@ async function run() { units: 100, }, }, - paymentMethod: { - dotTag: PaymentMethodReferenceTag.Id, - id: "X5h6j8uLpVGK", + paymentMethod: { + dotTag: PaymentMethodReferenceTag.Id, + id: "X5h6j8uLpVGK", + }, + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { paymentsLoggedInInitialize } from "@boltpay/bolt-typescript-sdk/funcs/paymentsLoggedInInitialize.js"; +import { AddressReferenceIdTag, Currency, PaymentMethodReferenceTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await paymentsLoggedInInitialize(boltTypescriptSDK, "", "", { + cart: { + orderReference: "order_100", + orderDescription: "Order #1234567890", + displayId: "215614191", + shipments: [ + { + address: { + dotTag: AddressReferenceIdTag.Id, + id: "D4g3h5tBuVYK9", + }, + cost: { + currency: Currency.Usd, + units: 10000, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 10000, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Bolt Swag Bag", + reference: "item_100", + description: "Large tote with Bolt logo.", + totalAmount: { + currency: Currency.Usd, + units: 9000, + }, + unitPrice: 1000, + quantity: 9, + imageUrl: "https://www.example.com/products/123456/images/1.png", + }, + ], + total: { + currency: Currency.Usd, + units: 9000, }, + tax: { + currency: Currency.Usd, + units: 100, + }, + }, + paymentMethod: { + dotTag: PaymentMethodReferenceTag.Id, + id: "X5h6j8uLpVGK", + }, }); + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + // Handle the result console.log(result) } @@ -99,16 +191,20 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.PaymentsInitializeResponse](../../models/operations/paymentsinitializeresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------------- | ------------------------------------- | ------------------------------------- | -| errors.PaymentsInitializeResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ---------------------- | ---------------------- | ---------------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.CartError | 4XX | application/json | +| errors.CreditCardError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## performAction @@ -123,6 +219,7 @@ import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/com const boltTypescriptSDK = new BoltTypescriptSDK({ security: { oauth: "", + apiKey: "", }, }); @@ -131,6 +228,43 @@ async function run() { dotTag: PaymentActionRequestTag.Finalize, redirectResult: "eyJ0cmFuc", }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { paymentsLoggedInPerformAction } from "@boltpay/bolt-typescript-sdk/funcs/paymentsLoggedInPerformAction.js"; +import { PaymentActionRequestTag } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore({ + security: { + oauth: "", + apiKey: "", + }, +}); + +async function run() { + const res = await paymentsLoggedInPerformAction(boltTypescriptSDK, "iKv7t5bgt1gg", "", "", { + dotTag: PaymentActionRequestTag.Finalize, + redirectResult: "eyJ0cmFuc", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -151,13 +285,14 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | | - ### Response **Promise\<[operations.PaymentsActionResponse](../../models/operations/paymentsactionresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------------- | --------------------------------- | --------------------------------- | -| errors.PaymentsActionResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/docs/sdks/oauth/README.md b/docs/sdks/oauth/README.md index 0ecaaf25..b2b60221 100644 --- a/docs/sdks/oauth/README.md +++ b/docs/sdks/oauth/README.md @@ -4,8 +4,8 @@ ## Overview Use the OAuth API to enable your ecommerce server to make API calls on behalf of a Bolt logged-in shopper. - + ### Available Operations * [getToken](#gettoken) - Get OAuth token @@ -24,17 +24,57 @@ const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { const result = await boltTypescriptSDK.oAuth.getToken("", { - grantType: GrantType.AuthorizationCode, - code: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", - clientId: "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", - clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", - scope: [ - Scope.BoltAccountManage, - Scope.BoltAccountView, - Scope.Openid, - ], - state: "xyzABC123", - }); + grantType: GrantType.AuthorizationCode, + code: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", + clientId: "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", + clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", + scope: [ + Scope.BoltAccountManage, + Scope.BoltAccountView, + Scope.Openid, + ], + state: "xyzABC123", + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { oAuthGetToken } from "@boltpay/bolt-typescript-sdk/funcs/oAuthGetToken.js"; +import { GrantType, Scope } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await oAuthGetToken(boltTypescriptSDK, "", { + grantType: GrantType.AuthorizationCode, + code: "7GSjMRSHs6Ak7C_zvVW6P2IhZOHxMK7HZKW1fMX85ms", + clientId: "8fd9diIy59sj.IraJdeIgmdsO.fd233434fg2c616cgo932aa6e1e4fc627a9385045gr395222a127gi93c595rg4", + clientSecret: "23ee7ec7301779eaff451d7c6f6cba322499e3c0ec752f800c72a8f99217e3a8", + scope: [ + Scope.BoltAccountManage, + Scope.BoltAccountView, + Scope.Openid, + ], + state: "xyzABC123", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -53,13 +93,14 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.OauthGetTokenResponse](../../models/operations/oauthgettokenresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| -------------------------------- | -------------------------------- | -------------------------------- | -| errors.OauthGetTokenResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/docs/sdks/orders/README.md b/docs/sdks/orders/README.md index 53e0a5eb..220532f5 100644 --- a/docs/sdks/orders/README.md +++ b/docs/sdks/orders/README.md @@ -17,12 +17,14 @@ Create an order that was prepared outside the Bolt ecosystem. Some Bolt-powered ```typescript import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; -import { AddressReferenceIdTag, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; +import { AddressReferenceExplicitTag, CountryCode, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { - const result = await boltTypescriptSDK.orders.ordersCreate("", "", "", { + const result = await boltTypescriptSDK.orders.ordersCreate({ + apiKey: "", + }, "", "", { profile: { firstName: "Charlie", lastName: "Dunn", @@ -35,10 +37,112 @@ async function run() { displayId: "20240116-878", shipments: [ { - address: { - dotTag: AddressReferenceIdTag.Id, - id: "D4g3h5tBuVYK9", - }, + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Charlie", + lastName: "Dunn", + company: "ACME Corporation", + streetAddress1: "535 Mission St", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, + cost: { + currency: Currency.Usd, + units: 10000, + }, + carrier: "FedEx", + }, + ], + discounts: [ + { + amount: { + currency: Currency.Usd, + units: 900, + }, + code: "SUMMER10DISCOUNT", + detailsUrl: "https://www.example.com/SUMMER-SALE", + }, + ], + items: [ + { + name: "Red Fidget Spinner", + reference: "sku-984", + description: "Single-packed fidget spinner, red", + totalAmount: { + currency: Currency.Usd, + units: 1000, + }, + unitPrice: 1000, + quantity: 1, + imageUrl: "https://www.example.com/products/984/image.png", + }, + ], + total: { + currency: Currency.Usd, + units: 1000, + }, + tax: { + currency: Currency.Usd, + units: 100, + }, + }, + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { ordersOrdersCreate } from "@boltpay/bolt-typescript-sdk/funcs/ordersOrdersCreate.js"; +import { AddressReferenceExplicitTag, CountryCode, Currency } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await ordersOrdersCreate(boltTypescriptSDK, { + apiKey: "", + }, "", "", { + profile: { + firstName: "Charlie", + lastName: "Dunn", + email: "charlie@example.com", + phone: "+14085551111", + }, + cart: { + orderReference: "instore_20240116-878", + orderDescription: "Order #878", + displayId: "20240116-878", + shipments: [ + { + address: { + dotTag: AddressReferenceExplicitTag.Explicit, + firstName: "Charlie", + lastName: "Dunn", + company: "ACME Corporation", + streetAddress1: "535 Mission St", + streetAddress2: "c/o Shipping Department", + locality: "San Francisco", + postalCode: "94105", + region: "CA", + countryCode: CountryCode.Us, + email: "alice@example.com", + phone: "+14155550199", + }, cost: { currency: Currency.Usd, units: 10000, @@ -81,6 +185,12 @@ async function run() { }, }); + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + // Handle the result console.log(result) } @@ -100,13 +210,14 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.OrdersCreateResponse](../../models/operations/orderscreateresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ------------------------------- | ------------------------------- | ------------------------------- | -| errors.OrdersCreateResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/docs/sdks/payments/README.md b/docs/sdks/payments/README.md index 58efe494..b5bccd69 100644 --- a/docs/sdks/payments/README.md +++ b/docs/sdks/payments/README.md @@ -1,5 +1,2 @@ # Payments -(*payments*) - -### Available Operations - +(*payments*) \ No newline at end of file diff --git a/docs/sdks/testing/README.md b/docs/sdks/testing/README.md index c6818b66..face05cf 100644 --- a/docs/sdks/testing/README.md +++ b/docs/sdks/testing/README.md @@ -24,7 +24,40 @@ import { EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/comp const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { - const result = await boltTypescriptSDK.testing.createAccount("", "", { + const result = await boltTypescriptSDK.testing.createAccount({ + apiKey: "", + }, "", { + emailState: EmailState.Unverified, + phoneState: PhoneState.Verified, + isMigrated: true, + hasAddress: true, + hasCreditCard: true, + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { testingCreateAccount } from "@boltpay/bolt-typescript-sdk/funcs/testingCreateAccount.js"; +import { EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/components"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await testingCreateAccount(boltTypescriptSDK, { + apiKey: "", + }, "", { emailState: EmailState.Unverified, phoneState: PhoneState.Verified, isMigrated: true, @@ -32,6 +65,12 @@ async function run() { hasCreditCard: true, }); + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + // Handle the result console.log(result) } @@ -50,16 +89,18 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.TestingAccountCreateResponse](../../models/operations/testingaccountcreateresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------------------- | --------------------------------------- | --------------------------------------- | -| errors.TestingAccountCreateResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## testingAccountPhoneGet @@ -73,7 +114,39 @@ import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk"; const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { - const result = await boltTypescriptSDK.testing.testingAccountPhoneGet("", ""); + const result = await boltTypescriptSDK.testing.testingAccountPhoneGet({ + apiKey: "", + }, ""); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { testingTestingAccountPhoneGet } from "@boltpay/bolt-typescript-sdk/funcs/testingTestingAccountPhoneGet.js"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await testingTestingAccountPhoneGet(boltTypescriptSDK, { + apiKey: "", + }, ""); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -92,16 +165,18 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.TestingAccountPhoneGetResponse](../../models/operations/testingaccountphonegetresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | -| errors.TestingAccountPhoneGetResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | + ## getCreditCard @@ -118,7 +193,42 @@ const boltTypescriptSDK = new BoltTypescriptSDK(); async function run() { const result = await boltTypescriptSDK.testing.getCreditCard({ type: Type.Approve, - }, ""); + }, { + apiKey: "", + }); + + // Handle the result + console.log(result) +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js"; +import { testingGetCreditCard } from "@boltpay/bolt-typescript-sdk/funcs/testingGetCreditCard.js"; +import { Type } from "@boltpay/bolt-typescript-sdk/models/operations"; + +// Use `BoltTypescriptSDKCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const boltTypescriptSDK = new BoltTypescriptSDKCore(); + +async function run() { + const res = await testingGetCreditCard(boltTypescriptSDK, { + type: Type.Approve, + }, { + apiKey: "", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; // Handle the result console.log(result) @@ -137,13 +247,14 @@ run(); | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | - ### Response **Promise\<[operations.TestingCreditCardGetResponse](../../models/operations/testingcreditcardgetresponse.md)\>** + ### Errors -| Error Object | Status Code | Content Type | -| --------------------------------------- | --------------------------------------- | --------------------------------------- | -| errors.TestingCreditCardGetResponseBody | 4XX | application/json | -| errors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------- | ----------------- | ----------------- | +| errors.ErrorT | 4XX | application/json | +| errors.FieldError | 4XX | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/gen.yaml b/gen.yaml index 66d920ae..4088c8bb 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.19.0 + version: 0.20.0 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/jsr.json b/jsr.json index d963d4d5..0c097809 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@boltpay/bolt-typescript-sdk", - "version": "0.19.0", + "version": "0.20.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index eef6a38f..dcb620e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,14 @@ { "name": "@boltpay/bolt-typescript-sdk", - "version": "0.19.0", + "version": "0.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@boltpay/bolt-typescript-sdk", - "version": "0.19.0", + "version": "0.20.0", "devDependencies": { + "@types/node": "^18.19.3", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", @@ -209,6 +210,16 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/node": { + "version": "18.19.50", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.50.tgz", + "integrity": "sha512-xonK+NRrMBRtkL1hVCc3G+uXtjh1Al4opBLjqVmipe5ZAaBYWW6cNAiBVZ1BvmkBhep698rP3UM3aRAdSALuhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -2921,6 +2932,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -3156,6 +3174,15 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "@types/node": { + "version": "18.19.50", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.50.tgz", + "integrity": "sha512-xonK+NRrMBRtkL1hVCc3G+uXtjh1Al4opBLjqVmipe5ZAaBYWW6cNAiBVZ1BvmkBhep698rP3UM3aRAdSALuhg==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, "@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -5076,6 +5103,12 @@ "which-boxed-primitive": "^1.0.2" } }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 0f811f6e..6628f871 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@boltpay/bolt-typescript-sdk", - "version": "0.19.0", + "version": "0.20.0", "author": "BoltPublicAPI", "main": "./index.js", "sideEffects": false, @@ -18,6 +18,7 @@ "zod": ">= 3" }, "devDependencies": { + "@types/node": "^18.19.3", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", diff --git a/src/core.ts b/src/core.ts new file mode 100644 index 00000000..ca874964 --- /dev/null +++ b/src/core.ts @@ -0,0 +1,13 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { ClientSDK } from "./lib/sdks.js"; + +/** + * A minimal client to use when calling standalone SDK functions. Typically, an + * instance of this class would be instantiated once at the start of an + * application and passed around through some dependency injection mechanism to + * parts of an application that need to make SDK calls. + */ +export class BoltTypescriptSDKCore extends ClientSDK {} diff --git a/src/funcs/accountAddAddress.ts b/src/funcs/accountAddAddress.ts new file mode 100644 index 00000000..c2d51669 --- /dev/null +++ b/src/funcs/accountAddAddress.ts @@ -0,0 +1,150 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Add an address + * + * @remarks + * Add an address to the shopper's account + */ +export async function accountAddAddress( + client$: BoltTypescriptSDKCore, + xPublishableKey: string, + xMerchantClientId: string, + addressListing: components.AddressListingInput, + options?: RequestOptions +): Promise< + Result< + operations.AccountAddressCreateResponse, + | errors.AccountAddressCreateResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.AccountAddressCreateRequest = { + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + addressListing: addressListing, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.AccountAddressCreateRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["address-listing"], { explode: true }); + + const path$ = pathToFunc("/account/addresses")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "accountAddressCreate", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.AccountAddressCreateResponse, + | errors.AccountAddressCreateResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.AccountAddressCreateResponse$inboundSchema, { + key: "address-listing", + }), + m$.jsonErr("4XX", errors.AccountAddressCreateResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.AccountAddressCreateResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/accountAddPaymentMethod.ts b/src/funcs/accountAddPaymentMethod.ts new file mode 100644 index 00000000..75a44cc2 --- /dev/null +++ b/src/funcs/accountAddPaymentMethod.ts @@ -0,0 +1,150 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Add a payment method + * + * @remarks + * Add a payment method to a shopper's Bolt Account Wallet. For security purposes, this request must come from your backend.
**Note**: Before using this API, the credit card details must be tokenized by Bolt's credit card tokenization service. Please review our [Bolt Payment Field Component](https://help.bolt.com/products/ignite/api-implementation/#enhance-payments) or [Install the Bolt Tokenizer](https://help.bolt.com/developers/references/bolt-tokenizer) documentation. + */ +export async function accountAddPaymentMethod( + client$: BoltTypescriptSDKCore, + xPublishableKey: string, + xMerchantClientId: string, + paymentMethod: components.PaymentMethodInput, + options?: RequestOptions +): Promise< + Result< + operations.AccountAddPaymentMethodResponse, + | errors.AccountAddPaymentMethodResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.AccountAddPaymentMethodRequest = { + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + paymentMethod: paymentMethod, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.AccountAddPaymentMethodRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["payment-method"], { explode: true }); + + const path$ = pathToFunc("/account/payment-methods")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "accountAddPaymentMethod", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.AccountAddPaymentMethodResponse, + | errors.AccountAddPaymentMethodResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.AccountAddPaymentMethodResponse$inboundSchema, { + key: "payment-method", + }), + m$.jsonErr("4XX", errors.AccountAddPaymentMethodResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.AccountAddPaymentMethodResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/accountDeleteAddress.ts b/src/funcs/accountDeleteAddress.ts new file mode 100644 index 00000000..431912f8 --- /dev/null +++ b/src/funcs/accountDeleteAddress.ts @@ -0,0 +1,149 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Delete an existing address + * + * @remarks + * Delete an existing address. Deleting an address does not invalidate or remove the address from transactions or shipments that are associated with it. + */ +export async function accountDeleteAddress( + client$: BoltTypescriptSDKCore, + id: string, + xPublishableKey: string, + xMerchantClientId: string, + options?: RequestOptions +): Promise< + Result< + operations.AccountAddressDeleteResponse, + | errors.AccountAddressDeleteResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.AccountAddressDeleteRequest = { + id: id, + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.AccountAddressDeleteRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), + }; + + const path$ = pathToFunc("/account/addresses/{id}")(pathParams$); + + const headers$ = new Headers({ + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "accountAddressDelete", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "DELETE", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.AccountAddressDeleteResponse, + | errors.AccountAddressDeleteResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.jsonErr("4XX", errors.AccountAddressDeleteResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil([200, "default"], operations.AccountAddressDeleteResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/accountDeletePaymentMethod.ts b/src/funcs/accountDeletePaymentMethod.ts new file mode 100644 index 00000000..8e0b7e44 --- /dev/null +++ b/src/funcs/accountDeletePaymentMethod.ts @@ -0,0 +1,149 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Delete an existing payment method + * + * @remarks + * Delete an existing payment method. Deleting a payment method does not invalidate or remove it from transactions or orders that are associated with it. + */ +export async function accountDeletePaymentMethod( + client$: BoltTypescriptSDKCore, + id: string, + xPublishableKey: string, + xMerchantClientId: string, + options?: RequestOptions +): Promise< + Result< + operations.AccountPaymentMethodDeleteResponse, + | errors.AccountPaymentMethodDeleteResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.AccountPaymentMethodDeleteRequest = { + id: id, + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.AccountPaymentMethodDeleteRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const pathParams$ = { + id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), + }; + + const path$ = pathToFunc("/account/payment-methods/{id}")(pathParams$); + + const headers$ = new Headers({ + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "accountPaymentMethodDelete", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "DELETE", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.AccountPaymentMethodDeleteResponse, + | errors.AccountPaymentMethodDeleteResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.jsonErr("4XX", errors.AccountPaymentMethodDeleteResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil([200, "default"], operations.AccountPaymentMethodDeleteResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/accountGetDetails.ts b/src/funcs/accountGetDetails.ts new file mode 100644 index 00000000..6d5f9495 --- /dev/null +++ b/src/funcs/accountGetDetails.ts @@ -0,0 +1,144 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Retrieve account details + * + * @remarks + * Retrieve a shopper's account details, such as addresses and payment information + */ +export async function accountGetDetails( + client$: BoltTypescriptSDKCore, + xPublishableKey: string, + xMerchantClientId: string, + options?: RequestOptions +): Promise< + Result< + operations.AccountGetResponse, + | errors.AccountGetResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.AccountGetRequest = { + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.AccountGetRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const path$ = pathToFunc("/account")(); + + const headers$ = new Headers({ + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "accountGet", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.AccountGetResponse, + | errors.AccountGetResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.AccountGetResponse$inboundSchema, { key: "account" }), + m$.jsonErr("4XX", errors.AccountGetResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.AccountGetResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/accountUpdateAddress.ts b/src/funcs/accountUpdateAddress.ts new file mode 100644 index 00000000..2c374048 --- /dev/null +++ b/src/funcs/accountUpdateAddress.ts @@ -0,0 +1,156 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Edit an existing address + * + * @remarks + * Edit an existing address on the shopper's account. This does not edit addresses that are already associated with other resources, such as transactions or shipments. + */ +export async function accountUpdateAddress( + client$: BoltTypescriptSDKCore, + id: string, + xPublishableKey: string, + xMerchantClientId: string, + addressListing: components.AddressListingInput, + options?: RequestOptions +): Promise< + Result< + operations.AccountAddressEditResponse, + | errors.AccountAddressEditResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.AccountAddressEditRequest = { + id: id, + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + addressListing: addressListing, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.AccountAddressEditRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["address-listing"], { explode: true }); + + const pathParams$ = { + id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), + }; + + const path$ = pathToFunc("/account/addresses/{id}")(pathParams$); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "accountAddressEdit", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "PUT", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.AccountAddressEditResponse, + | errors.AccountAddressEditResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.AccountAddressEditResponse$inboundSchema, { + key: "address-listing", + }), + m$.jsonErr("4XX", errors.AccountAddressEditResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.AccountAddressEditResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/oAuthGetToken.ts b/src/funcs/oAuthGetToken.ts new file mode 100644 index 00000000..02226c00 --- /dev/null +++ b/src/funcs/oAuthGetToken.ts @@ -0,0 +1,143 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { + encodeBodyForm as encodeBodyForm$, + encodeSimple as encodeSimple$, +} from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Get OAuth token + * + * @remarks + * Retrieve a new or refresh an existing OAuth token. + */ +export async function oAuthGetToken( + client$: BoltTypescriptSDKCore, + xMerchantClientId: string, + tokenRequest: components.TokenRequest, + options?: RequestOptions +): Promise< + Result< + operations.OauthGetTokenResponse, + | errors.OauthGetTokenResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.OauthGetTokenRequest = { + xMerchantClientId: xMerchantClientId, + tokenRequest: tokenRequest, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.OauthGetTokenRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = Object.entries(payload$["token-request"] || {}) + .map(([k, v]) => { + return encodeBodyForm$(k, v, { charEncoding: "percent" }); + }) + .join("&"); + + const path$ = pathToFunc("/oauth/token")(); + + const headers$ = new Headers({ + "Content-Type": "application/x-www-form-urlencoded", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + }); + + const context = { operationID: "oauthGetToken", oAuth2Scopes: [], securitySource: null }; + + const requestRes = client$.createRequest$( + context, + { + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.OauthGetTokenResponse, + | errors.OauthGetTokenResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.OauthGetTokenResponse$inboundSchema, { + key: "get-access-token-response", + }), + m$.jsonErr("4XX", errors.OauthGetTokenResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.OauthGetTokenResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/ordersOrdersCreate.ts b/src/funcs/ordersOrdersCreate.ts new file mode 100644 index 00000000..3f804882 --- /dev/null +++ b/src/funcs/ordersOrdersCreate.ts @@ -0,0 +1,153 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity, SecurityInput } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Create an order that was prepared outside the Bolt ecosystem. + * + * @remarks + * Create an order that was prepared outside the Bolt ecosystem. Some Bolt-powered flows automatically manage order creation - in those flows the order ID will be provided separately and not through this API. + */ +export async function ordersOrdersCreate( + client$: BoltTypescriptSDKCore, + security: operations.OrdersCreateSecurity, + xPublishableKey: string, + xMerchantClientId: string, + order: components.Order, + options?: RequestOptions +): Promise< + Result< + operations.OrdersCreateResponse, + | errors.OrdersCreateResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.OrdersCreateRequest = { + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + order: order, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.OrdersCreateRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$.order, { explode: true }); + + const path$ = pathToFunc("/orders")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$: SecurityInput[][] = [ + [ + { + fieldName: "X-API-Key", + type: "apiKey:header", + value: security?.apiKey, + }, + ], + ]; + const securitySettings$ = resolveSecurity(...security$); + const context = { operationID: "ordersCreate", oAuth2Scopes: [], securitySource: security }; + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.OrdersCreateResponse, + | errors.OrdersCreateResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.OrdersCreateResponse$inboundSchema, { key: "order-response" }), + m$.jsonErr("4XX", errors.OrdersCreateResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.OrdersCreateResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/paymentsGuestInitialize.ts b/src/funcs/paymentsGuestInitialize.ts new file mode 100644 index 00000000..985ddfb7 --- /dev/null +++ b/src/funcs/paymentsGuestInitialize.ts @@ -0,0 +1,161 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity, SecurityInput } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Initialize a Bolt payment for guest shoppers + * + * @remarks + * Initialize a Bolt guest shopper's intent to pay for a cart, using the specified payment method. Payments must be finalized before indicating the payment result to the shopper. Some payment methods will finalize automatically after initialization. For these payments, they will transition directly to "finalized" and the response from Initialize Payment will contain a finalized payment. + */ +export async function paymentsGuestInitialize( + client$: BoltTypescriptSDKCore, + security: operations.GuestPaymentsInitializeSecurity, + xPublishableKey: string, + xMerchantClientId: string, + guestPaymentInitializeRequest: components.GuestPaymentInitializeRequest, + options?: RequestOptions +): Promise< + Result< + operations.GuestPaymentsInitializeResponse, + | errors.GuestPaymentsInitializeResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.GuestPaymentsInitializeRequest = { + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + guestPaymentInitializeRequest: guestPaymentInitializeRequest, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.GuestPaymentsInitializeRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["guest-payment-initialize-request"], { + explode: true, + }); + + const path$ = pathToFunc("/guest/payments")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$: SecurityInput[][] = [ + [ + { + fieldName: "X-API-Key", + type: "apiKey:header", + value: security?.apiKey, + }, + ], + ]; + const securitySettings$ = resolveSecurity(...security$); + const context = { + operationID: "guestPaymentsInitialize", + oAuth2Scopes: [], + securitySource: security, + }; + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.GuestPaymentsInitializeResponse, + | errors.GuestPaymentsInitializeResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.GuestPaymentsInitializeResponse$inboundSchema, { + key: "payment-response", + }), + m$.jsonErr("4XX", errors.GuestPaymentsInitializeResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.GuestPaymentsInitializeResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/paymentsGuestPerformAction.ts b/src/funcs/paymentsGuestPerformAction.ts new file mode 100644 index 00000000..6f096939 --- /dev/null +++ b/src/funcs/paymentsGuestPerformAction.ts @@ -0,0 +1,165 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity, SecurityInput } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Finalize a pending guest payment + * + * @remarks + * Finalize a pending payment being made by a Bolt guest shopper. Upon receipt of a finalized payment result, payment success should be communicated to the shopper. + */ +export async function paymentsGuestPerformAction( + client$: BoltTypescriptSDKCore, + security: operations.GuestPaymentsActionSecurity, + id: string, + xPublishableKey: string, + xMerchantClientId: string, + paymentActionRequest: components.PaymentActionRequest, + options?: RequestOptions +): Promise< + Result< + operations.GuestPaymentsActionResponse, + | errors.GuestPaymentsActionResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.GuestPaymentsActionRequest = { + id: id, + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + paymentActionRequest: paymentActionRequest, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.GuestPaymentsActionRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["payment-action-request"], { explode: true }); + + const pathParams$ = { + id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), + }; + + const path$ = pathToFunc("/guest/payments/{id}")(pathParams$); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$: SecurityInput[][] = [ + [ + { + fieldName: "X-API-Key", + type: "apiKey:header", + value: security?.apiKey, + }, + ], + ]; + const securitySettings$ = resolveSecurity(...security$); + const context = { + operationID: "guestPaymentsAction", + oAuth2Scopes: [], + securitySource: security, + }; + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.GuestPaymentsActionResponse, + | errors.GuestPaymentsActionResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.GuestPaymentsActionResponse$inboundSchema, { + key: "payment-response", + }), + m$.jsonErr("4XX", errors.GuestPaymentsActionResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.GuestPaymentsActionResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/paymentsLoggedInInitialize.ts b/src/funcs/paymentsLoggedInInitialize.ts new file mode 100644 index 00000000..d3cf1d35 --- /dev/null +++ b/src/funcs/paymentsLoggedInInitialize.ts @@ -0,0 +1,151 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Initialize a Bolt payment for logged in shoppers + * + * @remarks + * Initialize a Bolt logged-in shopper's intent to pay for a cart, using the specified payment method. Payments must be finalized before indicating the payment result to the shopper. Some payment methods will finalize automatically after initialization. For these payments, they will transition directly to "finalized" and the response from Initialize Payment will contain a finalized payment. + * + */ +export async function paymentsLoggedInInitialize( + client$: BoltTypescriptSDKCore, + xPublishableKey: string, + xMerchantClientId: string, + paymentInitializeRequest: components.PaymentInitializeRequest, + options?: RequestOptions +): Promise< + Result< + operations.PaymentsInitializeResponse, + | errors.PaymentsInitializeResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.PaymentsInitializeRequest = { + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + paymentInitializeRequest: paymentInitializeRequest, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.PaymentsInitializeRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["payment-initialize-request"], { explode: true }); + + const path$ = pathToFunc("/payments")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "paymentsInitialize", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.PaymentsInitializeResponse, + | errors.PaymentsInitializeResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.PaymentsInitializeResponse$inboundSchema, { + key: "payment-response", + }), + m$.jsonErr("4XX", errors.PaymentsInitializeResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.PaymentsInitializeResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/paymentsLoggedInPerformAction.ts b/src/funcs/paymentsLoggedInPerformAction.ts new file mode 100644 index 00000000..f59d8ff1 --- /dev/null +++ b/src/funcs/paymentsLoggedInPerformAction.ts @@ -0,0 +1,154 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Finalize a pending payment + * + * @remarks + * Finalize a pending payment being made by a Bolt logged-in shopper. Upon receipt of a finalized payment result, payment success should be communicated to the shopper. + */ +export async function paymentsLoggedInPerformAction( + client$: BoltTypescriptSDKCore, + id: string, + xPublishableKey: string, + xMerchantClientId: string, + paymentActionRequest: components.PaymentActionRequest, + options?: RequestOptions +): Promise< + Result< + operations.PaymentsActionResponse, + | errors.PaymentsActionResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.PaymentsActionRequest = { + id: id, + xPublishableKey: xPublishableKey, + xMerchantClientId: xMerchantClientId, + paymentActionRequest: paymentActionRequest, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.PaymentsActionRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["payment-action-request"], { explode: true }); + + const pathParams$ = { + id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), + }; + + const path$ = pathToFunc("/payments/{id}")(pathParams$); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Merchant-Client-Id": encodeSimple$( + "X-Merchant-Client-Id", + payload$["X-Merchant-Client-Id"], + { explode: false, charEncoding: "none" } + ), + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$ = await extractSecurity(client$.options$.security); + const context = { + operationID: "paymentsAction", + oAuth2Scopes: [], + securitySource: client$.options$.security, + }; + const securitySettings$ = resolveGlobalSecurity(security$); + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.PaymentsActionResponse, + | errors.PaymentsActionResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.PaymentsActionResponse$inboundSchema, { key: "payment-response" }), + m$.jsonErr("4XX", errors.PaymentsActionResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.PaymentsActionResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/testingCreateAccount.ts b/src/funcs/testingCreateAccount.ts new file mode 100644 index 00000000..4ba7a591 --- /dev/null +++ b/src/funcs/testingCreateAccount.ts @@ -0,0 +1,152 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity, SecurityInput } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Create a test account + * + * @remarks + * Create a Bolt shopper account for testing purposes. + */ +export async function testingCreateAccount( + client$: BoltTypescriptSDKCore, + security: operations.TestingAccountCreateSecurity, + xPublishableKey: string, + accountTestCreationData: components.AccountTestCreationData, + options?: RequestOptions +): Promise< + Result< + operations.TestingAccountCreateResponse, + | errors.TestingAccountCreateResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.TestingAccountCreateRequest = { + xPublishableKey: xPublishableKey, + accountTestCreationData: accountTestCreationData, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.TestingAccountCreateRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$["account-test-creation-data"], { explode: true }); + + const path$ = pathToFunc("/testing/accounts")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$: SecurityInput[][] = [ + [ + { + fieldName: "X-API-Key", + type: "apiKey:header", + value: security?.apiKey, + }, + ], + ]; + const securitySettings$ = resolveSecurity(...security$); + const context = { + operationID: "testingAccountCreate", + oAuth2Scopes: [], + securitySource: security, + }; + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.TestingAccountCreateResponse, + | errors.TestingAccountCreateResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.TestingAccountCreateResponse$inboundSchema, { + key: "account-test-creation-data", + }), + m$.jsonErr("4XX", errors.TestingAccountCreateResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.TestingAccountCreateResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/testingGetCreditCard.ts b/src/funcs/testingGetCreditCard.ts new file mode 100644 index 00000000..20871a56 --- /dev/null +++ b/src/funcs/testingGetCreditCard.ts @@ -0,0 +1,143 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeJSON as encodeJSON$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity, SecurityInput } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Retrieve a tokenized test credit card + * + * @remarks + * Retrieve a test credit card that can be used to process payments in your Bolt testing environment. The response includes the card's Bolt credit card token. + */ +export async function testingGetCreditCard( + client$: BoltTypescriptSDKCore, + request: operations.TestingCreditCardGetRequestBody, + security: operations.TestingCreditCardGetSecurity, + options?: RequestOptions +): Promise< + Result< + operations.TestingCreditCardGetResponse, + | errors.TestingCreditCardGetResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$ = request; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.TestingCreditCardGetRequestBody$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = encodeJSON$("body", payload$, { explode: true }); + + const path$ = pathToFunc("/testing/credit-cards")(); + + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const security$: SecurityInput[][] = [ + [ + { + fieldName: "X-API-Key", + type: "apiKey:header", + value: security?.apiKey, + }, + ], + ]; + const securitySettings$ = resolveSecurity(...security$); + const context = { + operationID: "testingCreditCardGet", + oAuth2Scopes: [], + securitySource: security, + }; + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "POST", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.TestingCreditCardGetResponse, + | errors.TestingCreditCardGetResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.TestingCreditCardGetResponse$inboundSchema, { + key: "test-credit-card", + }), + m$.jsonErr("4XX", errors.TestingCreditCardGetResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.TestingCreditCardGetResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/funcs/testingTestingAccountPhoneGet.ts b/src/funcs/testingTestingAccountPhoneGet.ts new file mode 100644 index 00000000..a96b67a2 --- /dev/null +++ b/src/funcs/testingTestingAccountPhoneGet.ts @@ -0,0 +1,148 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { BoltTypescriptSDKCore } from "../core.js"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; +import * as m$ from "../lib/matchers.js"; +import * as schemas$ from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { resolveSecurity, SecurityInput } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Get a random phone number + * + * @remarks + * Get a random, fictitious phone number that is not assigned to any existing Bolt account. + */ +export async function testingTestingAccountPhoneGet( + client$: BoltTypescriptSDKCore, + security: operations.TestingAccountPhoneGetSecurity, + xPublishableKey: string, + options?: RequestOptions +): Promise< + Result< + operations.TestingAccountPhoneGetResponse, + | errors.TestingAccountPhoneGetResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input$: operations.TestingAccountPhoneGetRequest = { + xPublishableKey: xPublishableKey, + }; + + const parsed$ = schemas$.safeParse( + input$, + (value$) => operations.TestingAccountPhoneGetRequest$outboundSchema.parse(value$), + "Input validation failed" + ); + if (!parsed$.ok) { + return parsed$; + } + const payload$ = parsed$.value; + const body$ = null; + + const path$ = pathToFunc("/testing/accounts/phones")(); + + const headers$ = new Headers({ + Accept: "application/json", + "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { + explode: false, + charEncoding: "none", + }), + }); + + const security$: SecurityInput[][] = [ + [ + { + fieldName: "X-API-Key", + type: "apiKey:header", + value: security?.apiKey, + }, + ], + ]; + const securitySettings$ = resolveSecurity(...security$); + const context = { + operationID: "testingAccountPhoneGet", + oAuth2Scopes: [], + securitySource: security, + }; + + const requestRes = client$.createRequest$( + context, + { + security: securitySettings$, + method: "GET", + path: path$, + headers: headers$, + body: body$, + timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + }, + options + ); + if (!requestRes.ok) { + return requestRes; + } + const request$ = requestRes.value; + + const doResult = await client$.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || client$.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields$ = { + ContentType: response.headers.get("content-type") ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result$] = await m$.match< + operations.TestingAccountPhoneGetResponse, + | errors.TestingAccountPhoneGetResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + m$.json(200, operations.TestingAccountPhoneGetResponse$inboundSchema, { + key: "account-test-phone-data", + }), + m$.jsonErr("4XX", errors.TestingAccountPhoneGetResponseBody$inboundSchema), + m$.fail("5XX"), + m$.nil("default", operations.TestingAccountPhoneGetResponse$inboundSchema) + )(response, { extraFields: responseFields$ }); + if (!result$.ok) { + return result$; + } + + return result$; +} diff --git a/src/hooks/hooks.ts b/src/hooks/hooks.ts index 37ee8cd4..27751fde 100644 --- a/src/hooks/hooks.ts +++ b/src/hooks/hooks.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { RequestInput } from "../lib/http.js"; diff --git a/src/hooks/index.ts b/src/hooks/index.ts index d5fdd742..8f0e4dbf 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./types.js"; diff --git a/src/hooks/types.ts b/src/hooks/types.ts index dd23b024..3a31914a 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { HTTPClient, RequestInput } from "../lib/http.js"; diff --git a/src/index.ts b/src/index.ts index 8bc6ae3e..c6fc7f02 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./sdk/sdk.js"; export * from "./lib/config.js"; +export * as files from "./lib/files.js"; diff --git a/src/lib/base64.ts b/src/lib/base64.ts index cda07641..c2d5b389 100644 --- a/src/lib/base64.ts +++ b/src/lib/base64.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/src/lib/config.ts b/src/lib/config.ts index 71b0d091..2eab62bf 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1,10 +1,11 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as components from "../models/components/index.js"; import { ClosedEnum } from "../types/enums.js"; import { HTTPClient } from "./http.js"; +import { Logger } from "./logger.js"; import { RetryConfig } from "./retries.js"; import { Params, pathToFunc } from "./url.js"; @@ -31,7 +32,7 @@ export type SDKOptions = { */ serverIdx?: number; /** - * Allows setting the environment variable for url substitution + * Sets the environment variable for url substitution */ environment?: ServerEnvironment; /** @@ -43,6 +44,7 @@ export type SDKOptions = { */ retryConfig?: RetryConfig; timeoutMs?: number; + debugLogger?: Logger; }; export function serverURLFromOptions(options: SDKOptions): URL | null { @@ -70,8 +72,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", - openapiDocVersion: "3.2.0", - sdkVersion: "0.19.0", - genVersion: "2.376.0", - userAgent: "speakeasy-sdk/typescript 0.19.0 2.376.0 3.2.0 @boltpay/bolt-typescript-sdk", + openapiDocVersion: "3.2.1", + sdkVersion: "0.20.0", + genVersion: "2.411.9", + userAgent: "speakeasy-sdk/typescript 0.20.0 2.411.9 3.2.1 @boltpay/bolt-typescript-sdk", } as const; diff --git a/src/lib/dlv.ts b/src/lib/dlv.ts new file mode 100644 index 00000000..e81091f5 --- /dev/null +++ b/src/lib/dlv.ts @@ -0,0 +1,53 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/* +MIT License + +Copyright (c) 2024 Jason Miller (http://jasonformat.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/** + * @param obj The object to walk + * @param key The key path to walk the object with + * @param def A default value to return if the result is undefined + * + * @example + * dlv(obj, "a.b.c.d") + * @example + * dlv(object, ["a", "b", "c", "d"]) + * @example + * dlv(object, "foo.bar.baz", "Hello, default value!") + */ +export function dlv( + obj: any, + key: string | string[], + def?: T, + p?: number, + undef?: never, +): T | undefined { + key = Array.isArray(key) ? key : key.split("."); + for (p = 0; p < key.length; p++) { + const k = key[p]; + obj = k != null && obj ? obj[k] : undef; + } + return obj === undef ? def : obj; +} diff --git a/src/lib/encodings.ts b/src/lib/encodings.ts index 9ddea674..44fa7284 100644 --- a/src/lib/encodings.ts +++ b/src/lib/encodings.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { bytesToBase64 } from "./base64.js"; diff --git a/src/lib/files.ts b/src/lib/files.ts new file mode 100644 index 00000000..19e08041 --- /dev/null +++ b/src/lib/files.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Consumes a stream and returns a concatenated array buffer. Useful in + * situations where we need to read the whole file because it forms part of a + * larger payload containing other fields, and we can't modify the underlying + * request structure. + */ +export async function readableStreamToArrayBuffer( + readable: ReadableStream, +): Promise { + const reader = readable.getReader(); + const chunks: Uint8Array[] = []; + + let totalLength = 0; + let done = false; + + while (!done) { + const { value, done: doneReading } = await reader.read(); + + if (doneReading) { + done = true; + } else { + chunks.push(value); + totalLength += value.length; + } + } + + const concatenatedChunks = new Uint8Array(totalLength); + let offset = 0; + + for (const chunk of chunks) { + concatenatedChunks.set(chunk, offset); + offset += chunk.length; + } + + return concatenatedChunks.buffer; +} diff --git a/src/lib/http.ts b/src/lib/http.ts index 0bbdb4b9..13cf1fd7 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -1,41 +1,39 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { never as znever } from "zod"; -import { parse } from "./schemas.js"; -import { isPlainObject } from "./is-plain-object.js"; -import { SDKError } from "../models/errors/sdkerror.js"; - -export type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise; +export type Fetcher = ( + input: RequestInfo | URL, + init?: RequestInit, +) => Promise; export type Awaitable = T | Promise; const DEFAULT_FETCHER: Fetcher = (input, init) => { - // If input is a Request and init is undefined, Bun will discard the method, - // headers, body and other options that were set on the request object. - // Node.js and browers would ignore an undefined init value. This check is - // therefore needed for interop with Bun. - if (init == null) { - return fetch(input); - } else { - return fetch(input, init); - } + // If input is a Request and init is undefined, Bun will discard the method, + // headers, body and other options that were set on the request object. + // Node.js and browers would ignore an undefined init value. This check is + // therefore needed for interop with Bun. + if (init == null) { + return fetch(input); + } else { + return fetch(input, init); + } }; export type RequestInput = { - /** - * The URL the request will use. - */ - url: URL; - /** - * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). - */ - options?: RequestInit | undefined; + /** + * The URL the request will use. + */ + url: URL; + /** + * Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). + */ + options?: RequestInit | undefined; }; export interface HTTPClientOptions { - fetcher?: Fetcher; + fetcher?: Fetcher; } export type BeforeRequestHook = (req: Request) => Awaitable; @@ -43,114 +41,114 @@ export type RequestErrorHook = (err: unknown, req: Request) => Awaitable; export type ResponseHook = (res: Response, req: Request) => Awaitable; export class HTTPClient { - private fetcher: Fetcher; - private requestHooks: BeforeRequestHook[] = []; - private requestErrorHooks: RequestErrorHook[] = []; - private responseHooks: ResponseHook[] = []; - - constructor(private options: HTTPClientOptions = {}) { - this.fetcher = options.fetcher || DEFAULT_FETCHER; + private fetcher: Fetcher; + private requestHooks: BeforeRequestHook[] = []; + private requestErrorHooks: RequestErrorHook[] = []; + private responseHooks: ResponseHook[] = []; + + constructor(private options: HTTPClientOptions = {}) { + this.fetcher = options.fetcher || DEFAULT_FETCHER; + } + + async request(request: Request): Promise { + let req = request; + for (const hook of this.requestHooks) { + const nextRequest = await hook(req); + if (nextRequest) { + req = nextRequest; + } } - async request(request: Request): Promise { - let req = request; - for (const hook of this.requestHooks) { - const nextRequest = await hook(req); - if (nextRequest) { - req = nextRequest; - } - } - - try { - const res = await this.fetcher(req); - - for (const hook of this.responseHooks) { - await hook(res, req); - } - - return res; - } catch (err) { - for (const hook of this.requestErrorHooks) { - await hook(err, req); - } - - throw err; - } - } + try { + const res = await this.fetcher(req); + + for (const hook of this.responseHooks) { + await hook(res, req); + } + + return res; + } catch (err) { + for (const hook of this.requestErrorHooks) { + await hook(err, req); + } - /** - * Registers a hook that is called before a request is made. The hook function - * can mutate the request or return a new request. This may be useful to add - * additional information to request such as request IDs and tracing headers. - */ - addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** - * Registers a hook that is called when a request cannot be made due to a - * network error. - */ - addHook(hook: "requestError", fn: RequestErrorHook): this; - /** - * Registers a hook that is called when a response has been received from the - * server. - */ - addHook(hook: "response", fn: ResponseHook): this; - addHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ) { - if (args[0] === "beforeRequest") { - this.requestHooks.push(args[1]); - } else if (args[0] === "requestError") { - this.requestErrorHooks.push(args[1]); - } else if (args[0] === "response") { - this.responseHooks.push(args[1]); - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - return this; + throw err; + } + } + + /** + * Registers a hook that is called before a request is made. The hook function + * can mutate the request or return a new request. This may be useful to add + * additional information to request such as request IDs and tracing headers. + */ + addHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** + * Registers a hook that is called when a request cannot be made due to a + * network error. + */ + addHook(hook: "requestError", fn: RequestErrorHook): this; + /** + * Registers a hook that is called when a response has been received from the + * server. + */ + addHook(hook: "response", fn: ResponseHook): this; + addHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ) { + if (args[0] === "beforeRequest") { + this.requestHooks.push(args[1]); + } else if (args[0] === "requestError") { + this.requestErrorHooks.push(args[1]); + } else if (args[0] === "response") { + this.responseHooks.push(args[1]); + } else { + throw new Error(`Invalid hook type: ${args[0]}`); + } + return this; + } + + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "requestError", fn: RequestErrorHook): this; + /** Removes a hook that was previously registered with `addHook`. */ + removeHook(hook: "response", fn: ResponseHook): this; + removeHook( + ...args: + | [hook: "beforeRequest", fn: BeforeRequestHook] + | [hook: "requestError", fn: RequestErrorHook] + | [hook: "response", fn: ResponseHook] + ): this { + let target: unknown[]; + if (args[0] === "beforeRequest") { + target = this.requestHooks; + } else if (args[0] === "requestError") { + target = this.requestErrorHooks; + } else if (args[0] === "response") { + target = this.responseHooks; + } else { + throw new Error(`Invalid hook type: ${args[0]}`); } - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "requestError", fn: RequestErrorHook): this; - /** Removes a hook that was previously registered with `addHook`. */ - removeHook(hook: "response", fn: ResponseHook): this; - removeHook( - ...args: - | [hook: "beforeRequest", fn: BeforeRequestHook] - | [hook: "requestError", fn: RequestErrorHook] - | [hook: "response", fn: ResponseHook] - ): this { - let target: unknown[]; - if (args[0] === "beforeRequest") { - target = this.requestHooks; - } else if (args[0] === "requestError") { - target = this.requestErrorHooks; - } else if (args[0] === "response") { - target = this.responseHooks; - } else { - throw new Error(`Invalid hook type: ${args[0]}`); - } - - const index = target.findIndex((v) => v === args[1]); - if (index >= 0) { - target.splice(index, 1); - } - - return this; + const index = target.findIndex((v) => v === args[1]); + if (index >= 0) { + target.splice(index, 1); } - clone(): HTTPClient { - const child = new HTTPClient(this.options); - child.requestHooks = this.requestHooks.slice(); - child.requestErrorHooks = this.requestErrorHooks.slice(); - child.responseHooks = this.responseHooks.slice(); + return this; + } - return child; - } + clone(): HTTPClient { + const child = new HTTPClient(this.options); + child.requestHooks = this.requestHooks.slice(); + child.requestErrorHooks = this.requestErrorHooks.slice(); + child.responseHooks = this.responseHooks.slice(); + + return child; + } } export type StatusCodePredicate = number | string | (number | string)[]; @@ -159,348 +157,167 @@ export type StatusCodePredicate = number | string | (number | string)[]; // segments in a media type string. const mediaParamSeparator = /\s*;\s*/g; -function matchContentType(response: Response, pattern: string): boolean { - // `*` is a special case which means anything is acceptable. - if (pattern === "*") { - return true; +export function matchContentType(response: Response, pattern: string): boolean { + // `*` is a special case which means anything is acceptable. + if (pattern === "*") { + return true; + } + + let contentType = + response.headers.get("content-type")?.trim() || "application/octet-stream"; + contentType = contentType.toLowerCase(); + + const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); + const [wantType = "", ...wantParams] = wantParts; + + if (wantType.split("/").length !== 2) { + return false; + } + + const gotParts = contentType.split(mediaParamSeparator); + const [gotType = "", ...gotParams] = gotParts; + + const [type = "", subtype = ""] = gotType.split("/"); + if (!type || !subtype) { + return false; + } + + if ( + wantType !== "*/*" && + gotType !== wantType && + `${type}/*` !== wantType && + `*/${subtype}` !== wantType + ) { + return false; + } + + if (gotParams.length < wantParams.length) { + return false; + } + + const params = new Set(gotParams); + for (const wantParam of wantParams) { + if (!params.has(wantParam)) { + return false; } + } - let contentType = response.headers.get("content-type")?.trim() || "application/octet-stream"; - contentType = contentType.toLowerCase(); + return true; +} - const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator); - const [wantType = "", ...wantParams] = wantParts; +const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - if (wantType.split("/").length !== 2) { - return false; - } +export function matchStatusCode( + response: Response, + codes: StatusCodePredicate, +): boolean { + const actual = `${response.status}`; + const expectedCodes = Array.isArray(codes) ? codes : [codes]; + if (!expectedCodes.length) { + return false; + } - const gotParts = contentType.split(mediaParamSeparator); - const [gotType = "", ...gotParams] = gotParts; + return expectedCodes.some((ec) => { + const code = `${ec}`; - const [type = "", subtype = ""] = gotType.split("/"); - if (!type || !subtype) { - return false; + if (code === "default") { + return true; } - if ( - wantType !== "*/*" && - gotType !== wantType && - `${type}/*` !== wantType && - `*/${subtype}` !== wantType - ) { - return false; + if (!codeRangeRE.test(`${code}`)) { + return code === actual; } - if (gotParams.length < wantParams.length) { - return false; + const expectFamily = code.charAt(0); + if (!expectFamily) { + throw new Error("Invalid status code range"); } - const params = new Set(gotParams); - for (const wantParam of wantParams) { - if (!params.has(wantParam)) { - return false; - } + const actualFamily = actual.charAt(0); + if (!actualFamily) { + throw new Error(`Invalid response status code: ${actual}`); } - return true; -} - -const codeRangeRE = new RegExp("^[0-9]xx$", "i"); - -export function matchStatusCode(response: Response, codes: StatusCodePredicate): boolean { - const actual = `${response.status}`; - const expectedCodes = Array.isArray(codes) ? codes : [codes]; - if (!expectedCodes.length) { - return false; - } - - return expectedCodes.some((ec) => { - const code = `${ec}`; - - if (code === "default") { - return true; - } - - if (!codeRangeRE.test(`${code}`)) { - return code === actual; - } - - const expectFamily = code.charAt(0); - if (!expectFamily) { - throw new Error("Invalid status code range"); - } - - const actualFamily = actual.charAt(0); - if (!actualFamily) { - throw new Error(`Invalid response status code: ${actual}`); - } - - return actualFamily === expectFamily; - }); + return actualFamily === expectFamily; + }); } export function matchResponse( - response: Response, - code: StatusCodePredicate, - contentTypePattern: string + response: Response, + code: StatusCodePredicate, + contentTypePattern: string, ): boolean { - return matchStatusCode(response, code) && matchContentType(response, contentTypePattern); -} - -const headerValRE = /, */; -export function unpackHeaders(headers: Headers): Record { - const out: Record = {}; - - for (const [k, v] of headers.entries()) { - out[k] = v.split(headerValRE); - } - - return out; + return ( + matchStatusCode(response, code) && + matchContentType(response, contentTypePattern) + ); } -type ResponseMatcherSchema = - | { parse: (data: unknown) => T } - | { inboundSchema: { parse: (data: unknown) => T } }; +/** + * Uses various heurisitics to determine if an error is a connection error. + */ +export function isConnectionError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } -type SerializationMethod = "sse" | "json" | "rawBytes" | "rawStream" | "text" | "void" | "fail"; + // Covers fetch in Deno as well + const isBrowserErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("failed to fetch"); -const defaultContentTypes: Record = { - sse: "text/event-stream", - json: "application/json", - rawBytes: "application/octet-stream", - rawStream: "application/octet-stream", - text: "text/plain", - void: "", - fail: "", -}; + const isNodeErr = + err instanceof TypeError && + err.message.toLowerCase().startsWith("fetch failed"); -type ResponsePredicateMatch = { - method: SerializationMethod; - codes: StatusCodePredicate; - ctype: string; - schema: ResponseMatcherSchema; - hdrs: boolean; - key: string | undefined; - err: boolean; - fail: boolean; - sseSentinel?: string | undefined; -}; + const isBunErr = "name" in err && err.name === "ConnectionError"; -type ResponsePredicateOptions = { - /** Content type to match on. */ - ctype?: string; - /** Pass HTTP headers to deserializer. */ - hdrs?: boolean; - /** A value for an SSE event's data field that indicates a stream should be terminated. */ - sseSentinel?: string; -} & ( - | { - /** The result key to store the deserialized value into. */ - key?: string; - fail?: never; - err?: never; - } - | { - /** Indicates the matched response must throw the built-in error. */ - fail: true; - key?: never; - err?: never; - } - | { - /** Indicates the matched response is a custom error. */ - err: true; - key?: never; - fail?: never; - } -); - -export class ResponseMatcher { - private predicates: ResponsePredicateMatch[] = []; - - #any( - method: SerializationMethod, - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ) { - const ctype = opts?.ctype || defaultContentTypes[method]; - const hdrs = !!opts?.hdrs; - const key = opts?.key; - const err = !!opts?.err; - const fail = !!opts?.fail; - const sseSentinel = opts?.sseSentinel; - this.predicates.push({ - method, - codes, - ctype, - schema, - hdrs, - key, - err, - fail, - sseSentinel, - }); - return this; - } + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnreset"; - json( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("json", codes, schema, opts); - } - bytes( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawBytes", codes, schema, opts); - } - stream( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("rawStream", codes, schema, opts); - } - text( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: ResponsePredicateOptions - ): this { - return this.#any("text", codes, schema, opts); - } - sse( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Omit - ): this { - return this.#any("sse", codes, schema, opts); - } - void( - codes: StatusCodePredicate, - schema: ResponseMatcherSchema, - opts?: Pick - ): this { - return this.#any("void", codes, schema, opts); - } - fail(codes: StatusCodePredicate): this { - return this.#any("fail", codes, znever(), { fail: true }); - } - - async match( - response: Response, - // envelope - options?: { - resultKey?: string; - extraFields?: Record; - } - ): Promise<[result: Result, rawData: unknown]> { - let pred: ResponsePredicateMatch | undefined; - for (const predicate of this.predicates) { - const { codes, ctype } = predicate; - if (ctype && matchResponse(response, codes, ctype)) { - pred = predicate; - break; - } else if (!ctype && matchStatusCode(response, codes)) { - pred = predicate; - break; - } - } - if (pred == null) { - const responseBody = await response.text(); - throw new SDKError( - "Unexpected API response status or content-type", - response, - responseBody - ); - } - - const { method, schema } = pred; - - let raw: unknown; - switch (method) { - case "json": - raw = await response.json(); - break; - case "rawBytes": - raw = await response.arrayBuffer(); - break; - case "rawStream": - raw = response.body; - break; - case "text": - raw = await response.text(); - break; - case "sse": - raw = response.body; - break; - case "void": - raw = await discardResponseBody(response); - break; - case "fail": - raw = await response.text(); - break; - default: - method satisfies never; - throw new Error(`Unsupported response type: ${method}`); - } - - const resultKey = pred.key || options?.resultKey; - let data: unknown; - if (pred.fail) { - throw new SDKError("API error occurred", response, typeof raw === "string" ? raw : ""); - } else if (pred.err) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - ...(isPlainObject(raw) ? raw : null), - }; - } else if (resultKey) { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - [resultKey]: raw, - }; - } else { - data = { - ...options?.extraFields, - ...(pred.hdrs ? { Headers: unpackHeaders(response.headers) } : null), - }; - } - - const parser = "inboundSchema" in schema ? schema.inboundSchema : schema; - const body = parse(data, (v: unknown) => parser.parse(v), "Response validation failed"); - - if (body instanceof Error) { - throw body; - } - - return [body, raw]; - } + return isBrowserErr || isNodeErr || isGenericErr || isBunErr; } /** - * Discards the response body to free up resources. - * - * To learn why this is need, see the undici docs: - * https://undici.nodejs.org/#/?id=garbage-collection + * Uses various heurisitics to determine if an error is a timeout error. */ -export async function discardResponseBody(res: Response) { - const reader = res.body?.getReader(); - if (reader == null) { - return; - } +export function isTimeoutError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "TimeoutError"; + const isLegacyNative = "code" in err && err.code === 23; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; +} - try { - let done = false; - while (!done) { - const res = await reader.read(); - done = res.done; - } - } finally { - reader.releaseLock(); - } +/** + * Uses various heurisitics to determine if an error is a abort error. + */ +export function isAbortError(err: unknown): boolean { + if (typeof err !== "object" || err == null) { + return false; + } + + // Fetch in browser, Node.js, Bun, Deno + const isNative = "name" in err && err.name === "AbortError"; + const isLegacyNative = "code" in err && err.code === 20; + + // Node.js HTTP client and Axios + const isGenericErr = + "code" in err && + typeof err.code === "string" && + err.code.toLowerCase() === "econnaborted"; + + return isNative || isLegacyNative || isGenericErr; } diff --git a/src/lib/is-plain-object.ts b/src/lib/is-plain-object.ts index af0d6e7e..61070d3d 100644 --- a/src/lib/is-plain-object.ts +++ b/src/lib/is-plain-object.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ /* diff --git a/src/lib/logger.ts b/src/lib/logger.ts new file mode 100644 index 00000000..d181f293 --- /dev/null +++ b/src/lib/logger.ts @@ -0,0 +1,9 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export interface Logger { + group(label?: string): void; + groupEnd(): void; + log(message: any, ...args: any[]): void; +} diff --git a/src/lib/matchers.ts b/src/lib/matchers.ts new file mode 100644 index 00000000..1b7503e8 --- /dev/null +++ b/src/lib/matchers.ts @@ -0,0 +1,305 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { safeParse } from "./schemas.js"; +import { StatusCodePredicate, matchResponse, matchStatusCode } from "./http.js"; +import { isPlainObject } from "./is-plain-object.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import { Result } from "../types/fp.js"; + +export type Encoding = "json" | "text" | "bytes" | "stream" | "sse" | "nil" | "fail"; + +const DEFAULT_CONTENT_TYPES: Record = { + json: "application/json", + text: "text/plain", + bytes: "application/octet-stream", + stream: "application/octet-stream", + sse: "text/event-stream", + nil: "*", + fail: "*", +}; + +type Schema = { parse(raw: unknown): T }; + +type MatchOptions = { ctype?: string; hdrs?: boolean; key?: string; sseSentinel?: string }; + +export type ValueMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; +}; + +export type ErrorMatcher = MatchOptions & { + enc: Encoding; + codes: StatusCodePredicate; + schema: Schema; + err: true; +}; + +export type FailMatcher = { + enc: "fail"; + codes: StatusCodePredicate; +}; + +export type Matcher = ValueMatcher | ErrorMatcher | FailMatcher; + +export function jsonErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ErrorMatcher { + return { ...options, err: true, enc: "json", codes, schema }; +} +export function json( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ValueMatcher { + return { ...options, enc: "json", codes, schema }; +} + +export function textErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ErrorMatcher { + return { ...options, err: true, enc: "text", codes, schema }; +} +export function text( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ValueMatcher { + return { ...options, enc: "text", codes, schema }; +} + +export function bytesErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ErrorMatcher { + return { ...options, err: true, enc: "bytes", codes, schema }; +} +export function bytes( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ValueMatcher { + return { ...options, enc: "bytes", codes, schema }; +} + +export function streamErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ErrorMatcher { + return { ...options, err: true, enc: "stream", codes, schema }; +} +export function stream( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ValueMatcher { + return { ...options, enc: "stream", codes, schema }; +} + +export function sseErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ErrorMatcher { + return { ...options, err: true, enc: "sse", codes, schema }; +} +export function sse( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ValueMatcher { + return { ...options, enc: "sse", codes, schema }; +} + +export function nilErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ErrorMatcher { + return { ...options, err: true, enc: "nil", codes, schema }; +} +export function nil( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions +): ValueMatcher { + return { ...options, enc: "nil", codes, schema }; +} + +export function fail(codes: StatusCodePredicate): FailMatcher { + return { enc: "fail", codes }; +} + +export type MatchedValue = Matchers extends Matcher[] ? T : never; +export type MatchedError = Matchers extends Matcher[] ? E : never; +export type MatchFunc = ( + response: Response, + options?: { resultKey?: string; extraFields?: Record } +) => Promise<[result: Result, raw: unknown]>; + +export function match( + ...matchers: Array> +): MatchFunc { + return async function matchFunc( + response: Response, + options?: { resultKey?: string; extraFields?: Record } + ): Promise<[result: Result, raw: unknown]> { + let raw: unknown; + let matcher: Matcher | undefined; + for (const match of matchers) { + const { codes } = match; + const ctpattern = "ctype" in match ? match.ctype : DEFAULT_CONTENT_TYPES[match.enc]; + if (ctpattern && matchResponse(response, codes, ctpattern)) { + matcher = match; + break; + } else if (!ctpattern && matchStatusCode(response, codes)) { + matcher = match; + break; + } + } + + if (!matcher) { + const responseBody = await response.text(); + return [ + { + ok: false, + error: new SDKError( + "Unexpected API response status or content-type", + response, + responseBody + ), + }, + responseBody, + ]; + } + + const encoding = matcher.enc; + switch (encoding) { + case "json": + raw = await response.json(); + break; + case "bytes": + raw = await response.arrayBuffer(); + break; + case "stream": + raw = response.body; + break; + case "text": + raw = await response.text(); + break; + case "sse": + raw = response.body; + break; + case "nil": + raw = await discardResponseBody(response); + break; + case "fail": + raw = await response.text(); + break; + default: + encoding satisfies never; + throw new Error(`Unsupported response type: ${encoding}`); + } + + if (matcher.enc === "fail") { + return [ + { + ok: false, + error: new SDKError( + "API error occurred", + response, + typeof raw === "string" ? raw : "" + ), + }, + raw, + ]; + } + + const resultKey = matcher.key || options?.resultKey; + let data: unknown; + + if ("err" in matcher) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + ...(isPlainObject(raw) ? raw : null), + }; + } else if (resultKey) { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + [resultKey]: raw, + }; + } else { + data = { + ...options?.extraFields, + ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), + }; + } + + if ("err" in matcher) { + const result = safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed" + ); + return [result.ok ? { ok: false, error: result.value } : result, raw]; + } else { + return [ + safeParse( + data, + (v: unknown) => matcher.schema.parse(v), + "Response validation failed" + ), + raw, + ]; + } + }; +} + +const headerValRE = /, */; +/** + * Iterates over a Headers object and returns an object with all the header + * entries. Values are represented as an array to account for repeated headers. + */ +export function unpackHeaders(headers: Headers): Record { + const out: Record = {}; + + for (const [k, v] of headers.entries()) { + out[k] = v.split(headerValRE); + } + + return out; +} + +/** + * Discards the response body to free up resources. + * + * To learn why this is need, see the undici docs: + * https://undici.nodejs.org/#/?id=garbage-collection + */ +export async function discardResponseBody(res: Response) { + const reader = res.body?.getReader(); + if (reader == null) { + return; + } + + try { + let done = false; + while (!done) { + const res = await reader.read(); + done = res.done; + } + } finally { + reader.releaseLock(); + } +} diff --git a/src/lib/primitives.ts b/src/lib/primitives.ts index d3aae30b..23794a2b 100644 --- a/src/lib/primitives.ts +++ b/src/lib/primitives.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export type Remap = { diff --git a/src/lib/retries.ts b/src/lib/retries.ts index ed9b4959..df3e0bc2 100644 --- a/src/lib/retries.ts +++ b/src/lib/retries.ts @@ -1,7 +1,9 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { isConnectionError, isTimeoutError } from "./http.js"; + export type BackoffStrategy = { initialInterval: number; maxInterval: number; @@ -99,47 +101,6 @@ function wrapFetcher( }; } -function isConnectionError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Covers fetch in Deno as well - const isBrowserErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("failed to fetch"); - - const isNodeErr = - err instanceof TypeError && - err.message.toLowerCase().startsWith("fetch failed"); - - const isBunErr = "name" in err && err.name === "ConnectionError"; - - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnreset"; - - return isBrowserErr || isNodeErr || isGenericErr || isBunErr; -} - -function isTimeoutError(err: unknown) { - if (typeof err !== "object" || err == null) { - return false; - } - - // Fetch in browser, Node.js, Bun, Deno - const isNative = "name" in err && err.name === "TimeoutError"; - - // Node.js HTTP client and Axios - const isGenericErr = - "code" in err && - typeof err.code === "string" && - err.code.toLowerCase() === "econnaborted"; - - return isNative || isGenericErr; -} - const codeRangeRE = new RegExp("^[0-9]xx$", "i"); function isRetryableResponse(res: Response, statusCodes: string[]): boolean { diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts index 94b05354..37b0b131 100644 --- a/src/lib/schemas.ts +++ b/src/lib/schemas.ts @@ -1,9 +1,10 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { output, ZodEffects, ZodError, ZodObject, ZodRawShape, ZodTypeAny } from "zod"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import { ERR, OK, Result } from "../types/fp.js"; /** * Utility function that executes some code which may throw a ZodError. It @@ -21,6 +22,23 @@ export function parse(rawValue: Inp, fn: (value: Inp) => Out, errorMes } } +/** + * Utility function that executes some code which may result in a ZodError. It + * intercepts this error and converts it to an SDKValidationError so as to not + * leak Zod implementation details to user code. + */ +export function safeParse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string +): Result { + try { + return OK(fn(rawValue)); + } catch (err) { + return ERR(new SDKValidationError(errorMessage, err, rawValue)); + } +} + export function collectExtraKeys< Shape extends ZodRawShape, Catchall extends ZodTypeAny, diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index 6e43e8eb..f741c474 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -1,16 +1,31 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { ResponseMatcher, HTTPClient, matchStatusCode } from "./http.js"; -import { SecurityState, resolveSecurity, resolveGlobalSecurity } from "./security.js"; +import { + HTTPClient, + matchContentType, + matchStatusCode, + isAbortError, + isTimeoutError, + isConnectionError, +} from "./http.js"; +import { SecurityState } from "./security.js"; import { retry, RetryConfig } from "./retries.js"; -import { pathToFunc } from "./url.js"; +import { Logger } from "./logger.js"; import { encodeForm } from "./encodings.js"; import { stringToBase64 } from "./base64.js"; -import { SDK_METADATA } from "./config.js"; +import { SDKOptions, SDK_METADATA, serverURLFromOptions } from "./config.js"; import { SDKHooks } from "../hooks/hooks.js"; import { HookContext } from "../hooks/types.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import { ERR, OK, Result } from "../types/fp.js"; export type RequestOptions = { /** @@ -58,32 +73,49 @@ const isBrowserLike = (typeof window === "object" && typeof window.document !== "undefined"); export class ClientSDK { - private readonly client: HTTPClient; + private readonly httpClient: HTTPClient; protected readonly baseURL: URL | null; protected readonly hooks$: SDKHooks; + protected readonly logger?: Logger | undefined; + public readonly options$: SDKOptions & { hooks?: SDKHooks }; - constructor(init: { client: HTTPClient; baseURL: URL | null; hooks: SDKHooks }) { - const url = init.baseURL; + constructor(options: SDKOptions = {}) { + const opt = options as unknown; + if ( + typeof opt === "object" && + opt != null && + "hooks" in opt && + opt.hooks instanceof SDKHooks + ) { + this.hooks$ = opt.hooks; + } else { + this.hooks$ = new SDKHooks(); + } + this.options$ = { ...options, hooks: this.hooks$ }; + + const url = serverURLFromOptions(options); if (url) { url.pathname = url.pathname.replace(/\/+$/, "") + "/"; } - - this.hooks$ = init.hooks; - const { baseURL, client } = this.hooks$.sdkInit({ baseURL: url, client: init.client }); + const { baseURL, client } = this.hooks$.sdkInit({ + baseURL: url, + client: options.httpClient || new HTTPClient(), + }); this.baseURL = baseURL; - this.client = client; + this.httpClient = client; + this.logger = options.debugLogger; } - protected createRequest$( + public createRequest$( context: HookContext, conf: RequestConfig, options?: RequestOptions - ): Request { + ): Result { const { method, path, query, headers: opHeaders, security } = conf; const base = conf.baseURL ?? this.baseURL; if (!base) { - throw new TypeError("No base URL provided for operation"); + return ERR(new InvalidRequestError("No base URL provided for operation")); } const reqURL = new URL(base); const inputURL = new URL(path, reqURL); @@ -149,20 +181,39 @@ export class ClientSDK { } } - const input = this.hooks$.beforeCreateRequest(context, { - url: reqURL, - options: { - ...fetchOptions, - body: conf.body ?? null, - headers, - method, - }, - }); + if (conf.body instanceof ReadableStream) { + if (!fetchOptions) { + fetchOptions = { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + duplex: "half", + }; + } else { + // @ts-expect-error see https://github.com/node-fetch/node-fetch/issues/1769 + fetchOptions.duplex = "half"; + } + } - return new Request(input.url, input.options); + let input; + try { + input = this.hooks$.beforeCreateRequest(context, { + url: reqURL, + options: { + ...fetchOptions, + body: conf.body ?? null, + headers, + method, + }, + }); + } catch (err: unknown) { + return ERR( + new UnexpectedClientError("Create request hook failed to execute", { cause: err }) + ); + } + + return OK(new Request(input.url, input.options)); } - protected async do$( + public async do$( request: Request, options: { context: HookContext; @@ -170,19 +221,25 @@ export class ClientSDK { retryConfig?: RetryConfig | undefined; retryCodes?: string[] | undefined; } - ): Promise { + ): Promise< + Result< + Response, + RequestAbortedError | RequestTimeoutError | ConnectionError | UnexpectedClientError + > + > { const { context, errorCodes } = options; const retryConfig = options.retryConfig || { strategy: "none" }; const retryCodes = options.retryCodes || []; return retry( async () => { - const req = request.clone(); - - let response = await this.client.request( - await this.hooks$.beforeRequest(context, req) + const req = await this.hooks$.beforeRequest(context, request.clone()); + await logRequest(this.logger, req).catch((e) => + this.logger?.log("Failed to log request:", e) ); + let response = await this.httpClient.request(req); + if (matchStatusCode(response, errorCodes)) { const result = await this.hooks$.afterError(context, response, null); if (result.error) { @@ -193,18 +250,120 @@ export class ClientSDK { response = await this.hooks$.afterSuccess(context, response); } + await logResponse(this.logger, response, req).catch((e) => + this.logger?.log("Failed to log response:", e) + ); + return response; }, { config: retryConfig, statusCodes: retryCodes } + ).then( + (r) => OK(r), + (err) => { + switch (true) { + case isAbortError(err): + return ERR( + new RequestAbortedError("Request aborted by client", { cause: err }) + ); + case isTimeoutError(err): + return ERR(new RequestTimeoutError("Request timed out", { cause: err })); + case isConnectionError(err): + return ERR(new ConnectionError("Unable to make request", { cause: err })); + default: + return ERR( + new UnexpectedClientError("Unexpected HTTP client error", { + cause: err, + }) + ); + } + } ); } +} + +const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +async function logRequest(logger: Logger | undefined, req: Request) { + if (!logger) { + return; + } + + const contentType = req.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`> Request: ${req.method} ${req.url}`); + + logger.group("Headers:"); + for (const [k, v] of req.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); - protected matcher(): ResponseMatcher { - return new ResponseMatcher(); + logger.group("Body:"); + switch (true) { + case jsonLikeContentTypeRE.test(ct): + logger.log(await req.clone().json()); + break; + case ct.startsWith("text/"): + logger.log(await req.clone().text()); + break; + case ct === "multipart/form-data": { + const body = await req.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; } + logger.groupEnd(); + + logger.groupEnd(); +} - protected templateURLComponent = pathToFunc; +async function logResponse(logger: Logger | undefined, res: Response, req: Request) { + if (!logger) { + return; + } + + const contentType = res.headers.get("content-type"); + const ct = contentType?.split(";")[0] || ""; + + logger.group(`< Response: ${req.method} ${req.url}`); + logger.log("Status Code:", res.status, res.statusText); + + logger.group("Headers:"); + for (const [k, v] of res.headers.entries()) { + logger.log(`${k}: ${v}`); + } + logger.groupEnd(); + + logger.group("Body:"); + switch (true) { + case matchContentType(res, "application/json") || jsonLikeContentTypeRE.test(ct): + logger.log(await res.clone().json()); + break; + case matchContentType(res, "text/event-stream"): + logger.log(`<${contentType}>`); + break; + case matchContentType(res, "text/*"): + logger.log(await res.clone().text()); + break; + case matchContentType(res, "multipart/form-data"): { + const body = await res.clone().formData(); + for (const [k, v] of body) { + const vlabel = v instanceof Blob ? "" : v; + logger.log(`${k}: ${vlabel}`); + } + break; + } + default: + logger.log(`<${contentType}>`); + break; + } + logger.groupEnd(); - protected resolveSecurity = resolveSecurity; - protected resolveGlobalSecurity = resolveGlobalSecurity; + logger.groupEnd(); } diff --git a/src/lib/security.ts b/src/lib/security.ts index 5e9b23e4..0957cadc 100644 --- a/src/lib/security.ts +++ b/src/lib/security.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as components from "../models/components/index.js"; @@ -70,13 +70,20 @@ type SecurityInputOAuth2ClientCredentials = { value: { clientID?: string | undefined; clientSecret?: string | undefined } | null | undefined; }; +type SecurityInputCustom = { + type: "http:custom"; + value: any | null | undefined; + fieldName: string; +}; + export type SecurityInput = | SecurityInputBasic | SecurityInputBearer | SecurityInputAPIKey | SecurityInputOAuth2 | SecurityInputOAuth2ClientCredentials - | SecurityInputOIDC; + | SecurityInputOIDC + | SecurityInputCustom; export function resolveSecurity(...options: SecurityInput[][]): SecurityState | null { const state: SecurityState = { @@ -92,6 +99,8 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState | return false; } else if (o.type === "http:basic") { return o.value.username != null || o.value.password != null; + } else if (o.type === "http:custom") { + return null; } else if (o.type === "oauth2:client_credentials") { return o.value.clientID != null || o.value.clientSecret != null; } else if (typeof o.value === "string") { @@ -127,6 +136,8 @@ export function resolveSecurity(...options: SecurityInput[][]): SecurityState | case "http:basic": applyBasic(state, spec); break; + case "http:custom": + break; case "http:bearer": applyBearer(state, spec); break; @@ -186,3 +197,13 @@ export function resolveGlobalSecurity( }, ]); } + +export async function extractSecurity>( + sec: T | (() => Promise) | undefined +): Promise { + if (sec == null) { + return; + } + + return typeof sec === "function" ? sec() : sec; +} diff --git a/src/lib/url.ts b/src/lib/url.ts index df58acbb..6bc6356e 100644 --- a/src/lib/url.ts +++ b/src/lib/url.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const hasOwn = Object.prototype.hasOwnProperty; diff --git a/src/models/components/account.ts b/src/models/components/account.ts index bc031f61..b27b3740 100644 --- a/src/models/components/account.ts +++ b/src/models/components/account.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/accounttestcreationdataoutput.ts b/src/models/components/accounttestcreationdataoutput.ts index a9488ef3..e502f929 100644 --- a/src/models/components/accounttestcreationdataoutput.ts +++ b/src/models/components/accounttestcreationdataoutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/accounttestphonedata.ts b/src/models/components/accounttestphonedata.ts index 81c178b4..8d6d35b8 100644 --- a/src/models/components/accounttestphonedata.ts +++ b/src/models/components/accounttestphonedata.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/src/models/components/addresslisting.ts b/src/models/components/addresslisting.ts index 83f3a76b..3334dc15 100644 --- a/src/models/components/addresslisting.ts +++ b/src/models/components/addresslisting.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/addresslistinginput.ts b/src/models/components/addresslistinginput.ts index 1971da17..ff478067 100644 --- a/src/models/components/addresslistinginput.ts +++ b/src/models/components/addresslistinginput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/addressreference.ts b/src/models/components/addressreference.ts index 57ab1a5f..ee4c92f6 100644 --- a/src/models/components/addressreference.ts +++ b/src/models/components/addressreference.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/addressreferenceexplicit.ts b/src/models/components/addressreferenceexplicit.ts index 55b87487..55fb684b 100644 --- a/src/models/components/addressreferenceexplicit.ts +++ b/src/models/components/addressreferenceexplicit.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/addressreferenceid.ts b/src/models/components/addressreferenceid.ts index 3e106c00..21ec6930 100644 --- a/src/models/components/addressreferenceid.ts +++ b/src/models/components/addressreferenceid.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/addressreferenceinput.ts b/src/models/components/addressreferenceinput.ts index a4ac4988..d657ef37 100644 --- a/src/models/components/addressreferenceinput.ts +++ b/src/models/components/addressreferenceinput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/amount.ts b/src/models/components/amount.ts index 78408519..0f4a6207 100644 --- a/src/models/components/amount.ts +++ b/src/models/components/amount.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/src/models/components/authorizationcoderequest.ts b/src/models/components/authorizationcoderequest.ts index 8861f9f0..29f866c0 100644 --- a/src/models/components/authorizationcoderequest.ts +++ b/src/models/components/authorizationcoderequest.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/cart.ts b/src/models/components/cart.ts index b8e98bdf..60929122 100644 --- a/src/models/components/cart.ts +++ b/src/models/components/cart.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/cartdiscount.ts b/src/models/components/cartdiscount.ts index f3c2c07f..ef1aeb2d 100644 --- a/src/models/components/cartdiscount.ts +++ b/src/models/components/cartdiscount.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/cartitem.ts b/src/models/components/cartitem.ts index 5bb9b166..c7c85303 100644 --- a/src/models/components/cartitem.ts +++ b/src/models/components/cartitem.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/cartshipment.ts b/src/models/components/cartshipment.ts index 49f51ff3..75f77a6b 100644 --- a/src/models/components/cartshipment.ts +++ b/src/models/components/cartshipment.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/countrycode.ts b/src/models/components/countrycode.ts index 80d7e38b..05401b5c 100644 --- a/src/models/components/countrycode.ts +++ b/src/models/components/countrycode.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/src/models/components/creditcardnetwork.ts b/src/models/components/creditcardnetwork.ts index c15fc170..8e93f2e9 100644 --- a/src/models/components/creditcardnetwork.ts +++ b/src/models/components/creditcardnetwork.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/src/models/components/getaccesstokenresponse.ts b/src/models/components/getaccesstokenresponse.ts index 6d645057..e14d1de3 100644 --- a/src/models/components/getaccesstokenresponse.ts +++ b/src/models/components/getaccesstokenresponse.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/guestpaymentinitializerequest.ts b/src/models/components/guestpaymentinitializerequest.ts index a85c8b7a..e1c0323a 100644 --- a/src/models/components/guestpaymentinitializerequest.ts +++ b/src/models/components/guestpaymentinitializerequest.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/index.ts b/src/models/components/index.ts index 1f225f21..b363e03c 100644 --- a/src/models/components/index.ts +++ b/src/models/components/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./account.js"; @@ -46,3 +46,4 @@ export * from "./security.js"; export * from "./testcreditcard.js"; export * from "./tokenrequest.js"; export * from "./transaction.js"; +export * from "./transactionauthorization.js"; diff --git a/src/models/components/order.ts b/src/models/components/order.ts index 7286995f..3f7d9084 100644 --- a/src/models/components/order.ts +++ b/src/models/components/order.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { Cart, Cart$inboundSchema, Cart$Outbound, Cart$outboundSchema } from "./cart.js"; diff --git a/src/models/components/orderresponse.ts b/src/models/components/orderresponse.ts index 2624fc6e..17031d1a 100644 --- a/src/models/components/orderresponse.ts +++ b/src/models/components/orderresponse.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/paymentactionrequest.ts b/src/models/components/paymentactionrequest.ts index 15ce34f0..e141f876 100644 --- a/src/models/components/paymentactionrequest.ts +++ b/src/models/components/paymentactionrequest.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentinitializerequest.ts b/src/models/components/paymentinitializerequest.ts index 1d4bcd50..6ba988ae 100644 --- a/src/models/components/paymentinitializerequest.ts +++ b/src/models/components/paymentinitializerequest.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethod.ts b/src/models/components/paymentmethod.ts index ace3c51a..dfc4fcd3 100644 --- a/src/models/components/paymentmethod.ts +++ b/src/models/components/paymentmethod.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/paymentmethodaffirmoutput.ts b/src/models/components/paymentmethodaffirmoutput.ts index 2e9885b5..0f7b835d 100644 --- a/src/models/components/paymentmethodaffirmoutput.ts +++ b/src/models/components/paymentmethodaffirmoutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodafterpayoutput.ts b/src/models/components/paymentmethodafterpayoutput.ts index 79e1c251..22261819 100644 --- a/src/models/components/paymentmethodafterpayoutput.ts +++ b/src/models/components/paymentmethodafterpayoutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodcreditcard.ts b/src/models/components/paymentmethodcreditcard.ts index 50ff7267..3938cf31 100644 --- a/src/models/components/paymentmethodcreditcard.ts +++ b/src/models/components/paymentmethodcreditcard.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodextended.ts b/src/models/components/paymentmethodextended.ts index e49cadc0..f86c6edf 100644 --- a/src/models/components/paymentmethodextended.ts +++ b/src/models/components/paymentmethodextended.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/paymentmethodinput.ts b/src/models/components/paymentmethodinput.ts index c21544ad..3397bb1e 100644 --- a/src/models/components/paymentmethodinput.ts +++ b/src/models/components/paymentmethodinput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/paymentmethodklarnaaccountoutput.ts b/src/models/components/paymentmethodklarnaaccountoutput.ts index 2c3f35ab..e0c6b8fe 100644 --- a/src/models/components/paymentmethodklarnaaccountoutput.ts +++ b/src/models/components/paymentmethodklarnaaccountoutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodklarnaoutput.ts b/src/models/components/paymentmethodklarnaoutput.ts index d29b7f37..f08f381d 100644 --- a/src/models/components/paymentmethodklarnaoutput.ts +++ b/src/models/components/paymentmethodklarnaoutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodklarnapaynowoutput.ts b/src/models/components/paymentmethodklarnapaynowoutput.ts index 4536798f..3c3d6439 100644 --- a/src/models/components/paymentmethodklarnapaynowoutput.ts +++ b/src/models/components/paymentmethodklarnapaynowoutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodpaypaloutput.ts b/src/models/components/paymentmethodpaypaloutput.ts index f74274f2..731e0fc6 100644 --- a/src/models/components/paymentmethodpaypaloutput.ts +++ b/src/models/components/paymentmethodpaypaloutput.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentmethodreference.ts b/src/models/components/paymentmethodreference.ts index b0c1030d..dabe9fc1 100644 --- a/src/models/components/paymentmethodreference.ts +++ b/src/models/components/paymentmethodreference.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentresponse.ts b/src/models/components/paymentresponse.ts index 43a9f396..61a0ca5f 100644 --- a/src/models/components/paymentresponse.ts +++ b/src/models/components/paymentresponse.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/paymentresponsefinalized.ts b/src/models/components/paymentresponsefinalized.ts index 8e060719..b65d351e 100644 --- a/src/models/components/paymentresponsefinalized.ts +++ b/src/models/components/paymentresponsefinalized.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/paymentresponsepending.ts b/src/models/components/paymentresponsepending.ts index 630a3357..0bb57438 100644 --- a/src/models/components/paymentresponsepending.ts +++ b/src/models/components/paymentresponsepending.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/profile.ts b/src/models/components/profile.ts index abb8b2ca..0c0a2f81 100644 --- a/src/models/components/profile.ts +++ b/src/models/components/profile.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/profilecreationdata.ts b/src/models/components/profilecreationdata.ts index ad930986..b841db50 100644 --- a/src/models/components/profilecreationdata.ts +++ b/src/models/components/profilecreationdata.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/refreshtokenrequest.ts b/src/models/components/refreshtokenrequest.ts index de03ded9..53d1b1b6 100644 --- a/src/models/components/refreshtokenrequest.ts +++ b/src/models/components/refreshtokenrequest.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/security.ts b/src/models/components/security.ts index c1b38eb5..02a5b07a 100644 --- a/src/models/components/security.ts +++ b/src/models/components/security.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/components/testcreditcard.ts b/src/models/components/testcreditcard.ts index c02943ba..f833ccad 100644 --- a/src/models/components/testcreditcard.ts +++ b/src/models/components/testcreditcard.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/tokenrequest.ts b/src/models/components/tokenrequest.ts index 142f4249..3470edc2 100644 --- a/src/models/components/tokenrequest.ts +++ b/src/models/components/tokenrequest.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/components/transaction.ts b/src/models/components/transaction.ts index f0dc8c75..47d17c57 100644 --- a/src/models/components/transaction.ts +++ b/src/models/components/transaction.ts @@ -1,21 +1,33 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { + TransactionAuthorization, + TransactionAuthorization$inboundSchema, + TransactionAuthorization$Outbound, + TransactionAuthorization$outboundSchema, +} from "./transactionauthorization.js"; import * as z from "zod"; export type Transaction = { reference?: string | undefined; + /** + * Payment authorization events attached to a transaction + */ + authorizations?: Array | undefined; }; /** @internal */ export const Transaction$inboundSchema: z.ZodType = z.object({ reference: z.string().optional(), + authorizations: z.array(TransactionAuthorization$inboundSchema).optional(), }); /** @internal */ export type Transaction$Outbound = { reference?: string | undefined; + authorizations?: Array | undefined; }; /** @internal */ @@ -25,6 +37,7 @@ export const Transaction$outboundSchema: z.ZodType< Transaction > = z.object({ reference: z.string().optional(), + authorizations: z.array(TransactionAuthorization$outboundSchema).optional(), }); /** diff --git a/src/models/components/transactionauthorization.ts b/src/models/components/transactionauthorization.ts new file mode 100644 index 00000000..a01c95da --- /dev/null +++ b/src/models/components/transactionauthorization.ts @@ -0,0 +1,58 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { remap as remap$ } from "../../lib/primitives.js"; +import * as z from "zod"; + +export type TransactionAuthorization = { + processorReference?: string | undefined; +}; + +/** @internal */ +export const TransactionAuthorization$inboundSchema: z.ZodType< + TransactionAuthorization, + z.ZodTypeDef, + unknown +> = z + .object({ + processor_reference: z.string().optional(), + }) + .transform((v) => { + return remap$(v, { + processor_reference: "processorReference", + }); + }); + +/** @internal */ +export type TransactionAuthorization$Outbound = { + processor_reference?: string | undefined; +}; + +/** @internal */ +export const TransactionAuthorization$outboundSchema: z.ZodType< + TransactionAuthorization$Outbound, + z.ZodTypeDef, + TransactionAuthorization +> = z + .object({ + processorReference: z.string().optional(), + }) + .transform((v) => { + return remap$(v, { + processorReference: "processor_reference", + }); + }); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace TransactionAuthorization$ { + /** @deprecated use `TransactionAuthorization$inboundSchema` instead. */ + export const inboundSchema = TransactionAuthorization$inboundSchema; + /** @deprecated use `TransactionAuthorization$outboundSchema` instead. */ + export const outboundSchema = TransactionAuthorization$outboundSchema; + /** @deprecated use `TransactionAuthorization$Outbound` instead. */ + export type Outbound = TransactionAuthorization$Outbound; +} diff --git a/src/models/errors/accountaddpaymentmethod.ts b/src/models/errors/accountaddpaymentmethod.ts index b980bd99..a01b5046 100644 --- a/src/models/errors/accountaddpaymentmethod.ts +++ b/src/models/errors/accountaddpaymentmethod.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/errors/accountaddresscreate.ts b/src/models/errors/accountaddresscreate.ts index 77021266..0767cfb7 100644 --- a/src/models/errors/accountaddresscreate.ts +++ b/src/models/errors/accountaddresscreate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/accountaddressdelete.ts b/src/models/errors/accountaddressdelete.ts index dc6fa7de..7594259d 100644 --- a/src/models/errors/accountaddressdelete.ts +++ b/src/models/errors/accountaddressdelete.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/accountaddressedit.ts b/src/models/errors/accountaddressedit.ts index a47b8dae..69bbaee0 100644 --- a/src/models/errors/accountaddressedit.ts +++ b/src/models/errors/accountaddressedit.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/accountget.ts b/src/models/errors/accountget.ts index 37e4a041..bd589342 100644 --- a/src/models/errors/accountget.ts +++ b/src/models/errors/accountget.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/accountpaymentmethoddelete.ts b/src/models/errors/accountpaymentmethoddelete.ts index 03dd29af..a3a6d7cd 100644 --- a/src/models/errors/accountpaymentmethoddelete.ts +++ b/src/models/errors/accountpaymentmethoddelete.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/carterror.ts b/src/models/errors/carterror.ts index 418dd901..14950fe2 100644 --- a/src/models/errors/carterror.ts +++ b/src/models/errors/carterror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/errors/creditcarderror.ts b/src/models/errors/creditcarderror.ts index 61d77eed..a024530a 100644 --- a/src/models/errors/creditcarderror.ts +++ b/src/models/errors/creditcarderror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/errors/error.ts b/src/models/errors/error.ts index 3d5d76ab..fae13cae 100644 --- a/src/models/errors/error.ts +++ b/src/models/errors/error.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/errors/fielderror.ts b/src/models/errors/fielderror.ts index ce26d53f..22ac1917 100644 --- a/src/models/errors/fielderror.ts +++ b/src/models/errors/fielderror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/errors/guestpaymentsaction.ts b/src/models/errors/guestpaymentsaction.ts index 4960b5e3..6007e0f6 100644 --- a/src/models/errors/guestpaymentsaction.ts +++ b/src/models/errors/guestpaymentsaction.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/guestpaymentsinitialize.ts b/src/models/errors/guestpaymentsinitialize.ts index bd372bdc..c3881597 100644 --- a/src/models/errors/guestpaymentsinitialize.ts +++ b/src/models/errors/guestpaymentsinitialize.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/errors/httpclienterrors.ts b/src/models/errors/httpclienterrors.ts new file mode 100644 index 00000000..cdb2995f --- /dev/null +++ b/src/models/errors/httpclienterrors.ts @@ -0,0 +1,62 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * Base class for all HTTP errors. + */ +export class HTTPClientError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + override name = "HTTPClientError"; + constructor(message: string, opts?: { cause?: unknown }) { + let msg = message; + if (opts?.cause) { + msg += `: ${opts.cause}`; + } + + super(msg, opts); + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = opts?.cause; + } + } +} + +/** + * An error to capture unrecognised or unexpected errors when making HTTP calls. + */ +export class UnexpectedClientError extends HTTPClientError { + override name = "UnexpectedClientError"; +} + +/** + * An error that is raised when any inputs used to create a request are invalid. + */ +export class InvalidRequestError extends HTTPClientError { + override name = "InvalidRequestError"; +} + +/** + * An error that is raised when a HTTP request was aborted by the client error. + */ +export class RequestAbortedError extends HTTPClientError { + override readonly name = "RequestAbortedError"; +} + +/** + * An error that is raised when a HTTP request timed out due to an AbortSignal + * signal timeout. + */ +export class RequestTimeoutError extends HTTPClientError { + override readonly name = "RequestTimeoutError"; +} + +/** + * An error that is raised when a HTTP client is unable to make a request to + * a server. + */ +export class ConnectionError extends HTTPClientError { + override readonly name = "ConnectionError"; +} diff --git a/src/models/errors/index.ts b/src/models/errors/index.ts index d69062ca..688a4260 100644 --- a/src/models/errors/index.ts +++ b/src/models/errors/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./accountaddpaymentmethod.js"; @@ -14,6 +14,7 @@ export * from "./error.js"; export * from "./fielderror.js"; export * from "./guestpaymentsaction.js"; export * from "./guestpaymentsinitialize.js"; +export * from "./httpclienterrors.js"; export * from "./oauthgettoken.js"; export * from "./orderscreate.js"; export * from "./paymentsaction.js"; diff --git a/src/models/errors/oauthgettoken.ts b/src/models/errors/oauthgettoken.ts index 61457931..6683891f 100644 --- a/src/models/errors/oauthgettoken.ts +++ b/src/models/errors/oauthgettoken.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/orderscreate.ts b/src/models/errors/orderscreate.ts index 33f32b2c..fb008e1a 100644 --- a/src/models/errors/orderscreate.ts +++ b/src/models/errors/orderscreate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/paymentsaction.ts b/src/models/errors/paymentsaction.ts index f1ac529c..f154201a 100644 --- a/src/models/errors/paymentsaction.ts +++ b/src/models/errors/paymentsaction.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/paymentsinitialize.ts b/src/models/errors/paymentsinitialize.ts index 282f93fa..96709385 100644 --- a/src/models/errors/paymentsinitialize.ts +++ b/src/models/errors/paymentsinitialize.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { diff --git a/src/models/errors/sdkerror.ts b/src/models/errors/sdkerror.ts index 5a94e842..80e3aa42 100644 --- a/src/models/errors/sdkerror.ts +++ b/src/models/errors/sdkerror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export class SDKError extends Error { diff --git a/src/models/errors/sdkvalidationerror.ts b/src/models/errors/sdkvalidationerror.ts index 5eb92182..16929b9e 100644 --- a/src/models/errors/sdkvalidationerror.ts +++ b/src/models/errors/sdkvalidationerror.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; @@ -10,15 +10,17 @@ export class SDKValidationError extends Error { */ public readonly rawValue: unknown; + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + constructor(message: string, cause: unknown, rawValue: unknown) { - super(message); + super(`${message}: ${cause}`); this.name = "SDKValidationError"; this.cause = cause; this.rawValue = rawValue; - } - - public override toString(): string { - return `${this.message}: ${this.cause}`; + this.rawMessage = message; } /** @@ -28,7 +30,7 @@ export class SDKValidationError extends Error { */ public pretty(): string { if (this.cause instanceof z.ZodError) { - return `${this.message}\n${formatZodError(this.cause)}`; + return `${this.rawMessage}\n${formatZodError(this.cause)}`; } else { return this.toString(); } diff --git a/src/models/errors/testingaccountcreate.ts b/src/models/errors/testingaccountcreate.ts index f9591cf8..4725c553 100644 --- a/src/models/errors/testingaccountcreate.ts +++ b/src/models/errors/testingaccountcreate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/testingaccountphoneget.ts b/src/models/errors/testingaccountphoneget.ts index 07dbd6ec..9a945d35 100644 --- a/src/models/errors/testingaccountphoneget.ts +++ b/src/models/errors/testingaccountphoneget.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/errors/testingcreditcardget.ts b/src/models/errors/testingcreditcardget.ts index a7de07da..fc8f10ba 100644 --- a/src/models/errors/testingcreditcardget.ts +++ b/src/models/errors/testingcreditcardget.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { ErrorT, ErrorT$inboundSchema, ErrorT$Outbound, ErrorT$outboundSchema } from "./error.js"; diff --git a/src/models/operations/accountaddpaymentmethod.ts b/src/models/operations/accountaddpaymentmethod.ts index 8ffa4a63..0e539cfa 100644 --- a/src/models/operations/accountaddpaymentmethod.ts +++ b/src/models/operations/accountaddpaymentmethod.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/accountaddresscreate.ts b/src/models/operations/accountaddresscreate.ts index add02921..ce7cd069 100644 --- a/src/models/operations/accountaddresscreate.ts +++ b/src/models/operations/accountaddresscreate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/accountaddressdelete.ts b/src/models/operations/accountaddressdelete.ts index de9b6108..ccd08753 100644 --- a/src/models/operations/accountaddressdelete.ts +++ b/src/models/operations/accountaddressdelete.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/accountaddressedit.ts b/src/models/operations/accountaddressedit.ts index 048bb61c..489cb0bf 100644 --- a/src/models/operations/accountaddressedit.ts +++ b/src/models/operations/accountaddressedit.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/accountget.ts b/src/models/operations/accountget.ts index cf8cde8b..996f2e7b 100644 --- a/src/models/operations/accountget.ts +++ b/src/models/operations/accountget.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/accountpaymentmethoddelete.ts b/src/models/operations/accountpaymentmethoddelete.ts index 4fa8c193..0848450f 100644 --- a/src/models/operations/accountpaymentmethoddelete.ts +++ b/src/models/operations/accountpaymentmethoddelete.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/guestpaymentsaction.ts b/src/models/operations/guestpaymentsaction.ts index 6ca3a85a..2fc389ba 100644 --- a/src/models/operations/guestpaymentsaction.ts +++ b/src/models/operations/guestpaymentsaction.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/guestpaymentsinitialize.ts b/src/models/operations/guestpaymentsinitialize.ts index b8726d00..3bc3cb53 100644 --- a/src/models/operations/guestpaymentsinitialize.ts +++ b/src/models/operations/guestpaymentsinitialize.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/index.ts b/src/models/operations/index.ts index 491b8be3..5f722109 100644 --- a/src/models/operations/index.ts +++ b/src/models/operations/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./accountaddpaymentmethod.js"; diff --git a/src/models/operations/oauthgettoken.ts b/src/models/operations/oauthgettoken.ts index 34756a96..5a890261 100644 --- a/src/models/operations/oauthgettoken.ts +++ b/src/models/operations/oauthgettoken.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/orderscreate.ts b/src/models/operations/orderscreate.ts index 4ba2fdca..58c54dfa 100644 --- a/src/models/operations/orderscreate.ts +++ b/src/models/operations/orderscreate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/paymentsaction.ts b/src/models/operations/paymentsaction.ts index 5121a600..c9833ce8 100644 --- a/src/models/operations/paymentsaction.ts +++ b/src/models/operations/paymentsaction.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/paymentsinitialize.ts b/src/models/operations/paymentsinitialize.ts index 64bc2b46..c48410d5 100644 --- a/src/models/operations/paymentsinitialize.ts +++ b/src/models/operations/paymentsinitialize.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/testingaccountcreate.ts b/src/models/operations/testingaccountcreate.ts index e9bf3e5e..82524ff4 100644 --- a/src/models/operations/testingaccountcreate.ts +++ b/src/models/operations/testingaccountcreate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/testingaccountphoneget.ts b/src/models/operations/testingaccountphoneget.ts index c4a3742a..1f35f3f4 100644 --- a/src/models/operations/testingaccountphoneget.ts +++ b/src/models/operations/testingaccountphoneget.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/models/operations/testingcreditcardget.ts b/src/models/operations/testingcreditcardget.ts index a63ee89b..1ca03896 100644 --- a/src/models/operations/testingcreditcardget.ts +++ b/src/models/operations/testingcreditcardget.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { remap as remap$ } from "../../lib/primitives.js"; diff --git a/src/sdk/account.ts b/src/sdk/account.ts index 18d19e46..8e4940b9 100644 --- a/src/sdk/account.ts +++ b/src/sdk/account.ts @@ -1,44 +1,19 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { accountAddAddress } from "../funcs/accountAddAddress.js"; +import { accountAddPaymentMethod } from "../funcs/accountAddPaymentMethod.js"; +import { accountDeleteAddress } from "../funcs/accountDeleteAddress.js"; +import { accountDeletePaymentMethod } from "../funcs/accountDeletePaymentMethod.js"; +import { accountGetDetails } from "../funcs/accountGetDetails.js"; +import { accountUpdateAddress } from "../funcs/accountUpdateAddress.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; -import * as errors from "../models/errors/index.js"; import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class Account extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - /** * Retrieve account details * @@ -50,83 +25,7 @@ export class Account extends ClientSDK { xMerchantClientId: string, options?: RequestOptions ): Promise { - const input$: operations.AccountGetRequest = { - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.AccountGetRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const path$ = this.templateURLComponent("/account")(); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "accountGet", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.AccountGetResponse$inboundSchema, { key: "account" }) - .json("4XX", errors.AccountGetResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.AccountGetResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; + return unwrapAsync(accountGetDetails(this, xPublishableKey, xMerchantClientId, options)); } /** @@ -141,87 +40,9 @@ export class Account extends ClientSDK { addressListing: components.AddressListingInput, options?: RequestOptions ): Promise { - const input$: operations.AccountAddressCreateRequest = { - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - addressListing: addressListing, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.AccountAddressCreateRequest$outboundSchema.parse(value$), - "Input validation failed" + return unwrapAsync( + accountAddAddress(this, xPublishableKey, xMerchantClientId, addressListing, options) ); - const body$ = encodeJSON$("body", payload$["address-listing"], { explode: true }); - - const path$ = this.templateURLComponent("/account/addresses")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "accountAddressCreate", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.AccountAddressCreateResponse$inboundSchema, { - key: "address-listing", - }) - .json("4XX", errors.AccountAddressCreateResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.AccountAddressCreateResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -237,91 +58,16 @@ export class Account extends ClientSDK { addressListing: components.AddressListingInput, options?: RequestOptions ): Promise { - const input$: operations.AccountAddressEditRequest = { - id: id, - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - addressListing: addressListing, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.AccountAddressEditRequest$outboundSchema.parse(value$), - "Input validation failed" + return unwrapAsync( + accountUpdateAddress( + this, + id, + xPublishableKey, + xMerchantClientId, + addressListing, + options + ) ); - const body$ = encodeJSON$("body", payload$["address-listing"], { explode: true }); - - const pathParams$ = { - id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), - }; - const path$ = this.templateURLComponent("/account/addresses/{id}")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "accountAddressEdit", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "PUT", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.AccountAddressEditResponse$inboundSchema, { - key: "address-listing", - }) - .json("4XX", errors.AccountAddressEditResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.AccountAddressEditResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -336,86 +82,9 @@ export class Account extends ClientSDK { xMerchantClientId: string, options?: RequestOptions ): Promise { - const input$: operations.AccountAddressDeleteRequest = { - id: id, - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.AccountAddressDeleteRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const pathParams$ = { - id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), - }; - const path$ = this.templateURLComponent("/account/addresses/{id}")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "accountAddressDelete", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "DELETE", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options + return unwrapAsync( + accountDeleteAddress(this, id, xPublishableKey, xMerchantClientId, options) ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json("4XX", errors.AccountAddressDeleteResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void([200, "default"], operations.AccountAddressDeleteResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -430,87 +99,15 @@ export class Account extends ClientSDK { paymentMethod: components.PaymentMethodInput, options?: RequestOptions ): Promise { - const input$: operations.AccountAddPaymentMethodRequest = { - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - paymentMethod: paymentMethod, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.AccountAddPaymentMethodRequest$outboundSchema.parse(value$), - "Input validation failed" + return unwrapAsync( + accountAddPaymentMethod( + this, + xPublishableKey, + xMerchantClientId, + paymentMethod, + options + ) ); - const body$ = encodeJSON$("body", payload$["payment-method"], { explode: true }); - - const path$ = this.templateURLComponent("/account/payment-methods")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "accountAddPaymentMethod", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.AccountAddPaymentMethodResponse$inboundSchema, { - key: "payment-method", - }) - .json("4XX", errors.AccountAddPaymentMethodResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.AccountAddPaymentMethodResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -525,85 +122,8 @@ export class Account extends ClientSDK { xMerchantClientId: string, options?: RequestOptions ): Promise { - const input$: operations.AccountPaymentMethodDeleteRequest = { - id: id, - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.AccountPaymentMethodDeleteRequest$outboundSchema.parse(value$), - "Input validation failed" + return unwrapAsync( + accountDeletePaymentMethod(this, id, xPublishableKey, xMerchantClientId, options) ); - const body$ = null; - - const pathParams$ = { - id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), - }; - const path$ = this.templateURLComponent("/account/payment-methods/{id}")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "accountPaymentMethodDelete", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "DELETE", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json("4XX", errors.AccountPaymentMethodDeleteResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void([200, "default"], operations.AccountPaymentMethodDeleteResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } } diff --git a/src/sdk/guest.ts b/src/sdk/guest.ts index 94d62aa5..8a67a913 100644 --- a/src/sdk/guest.ts +++ b/src/sdk/guest.ts @@ -1,45 +1,15 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { paymentsGuestInitialize } from "../funcs/paymentsGuestInitialize.js"; +import { paymentsGuestPerformAction } from "../funcs/paymentsGuestPerformAction.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import { SecurityInput } from "../lib/security.js"; import * as components from "../models/components/index.js"; -import * as errors from "../models/errors/index.js"; import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class Guest extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - /** * Initialize a Bolt payment for guest shoppers * @@ -53,93 +23,16 @@ export class Guest extends ClientSDK { guestPaymentInitializeRequest: components.GuestPaymentInitializeRequest, options?: RequestOptions ): Promise { - const input$: operations.GuestPaymentsInitializeRequest = { - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - guestPaymentInitializeRequest: guestPaymentInitializeRequest, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GuestPaymentsInitializeRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$["guest-payment-initialize-request"], { - explode: true, - }); - - const path$ = this.templateURLComponent("/guest/payments")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$: SecurityInput[][] = [ - [ - { - fieldName: "X-API-Key", - type: "apiKey:header", - value: security?.apiKey, - }, - ], - ]; - const securitySettings$ = this.resolveSecurity(...security$); - const context = { - operationID: "guestPaymentsInitialize", - oAuth2Scopes: [], - securitySource: security$, - }; - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options + return unwrapAsync( + paymentsGuestInitialize( + this, + security, + xPublishableKey, + xMerchantClientId, + guestPaymentInitializeRequest, + options + ) ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.GuestPaymentsInitializeResponse$inboundSchema, { - key: "payment-response", - }) - .json("4XX", errors.GuestPaymentsInitializeResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.GuestPaymentsInitializeResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -156,94 +49,16 @@ export class Guest extends ClientSDK { paymentActionRequest: components.PaymentActionRequest, options?: RequestOptions ): Promise { - const input$: operations.GuestPaymentsActionRequest = { - id: id, - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - paymentActionRequest: paymentActionRequest, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.GuestPaymentsActionRequest$outboundSchema.parse(value$), - "Input validation failed" + return unwrapAsync( + paymentsGuestPerformAction( + this, + security, + id, + xPublishableKey, + xMerchantClientId, + paymentActionRequest, + options + ) ); - const body$ = encodeJSON$("body", payload$["payment-action-request"], { explode: true }); - - const pathParams$ = { - id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), - }; - const path$ = this.templateURLComponent("/guest/payments/{id}")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$: SecurityInput[][] = [ - [ - { - fieldName: "X-API-Key", - type: "apiKey:header", - value: security?.apiKey, - }, - ], - ]; - const securitySettings$ = this.resolveSecurity(...security$); - const context = { - operationID: "guestPaymentsAction", - oAuth2Scopes: [], - securitySource: security$, - }; - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.GuestPaymentsActionResponse$inboundSchema, { - key: "payment-response", - }) - .json("4XX", errors.GuestPaymentsActionResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.GuestPaymentsActionResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } } diff --git a/src/sdk/index.ts b/src/sdk/index.ts index 34a84fc2..ecac2264 100644 --- a/src/sdk/index.ts +++ b/src/sdk/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export * from "./sdk.js"; diff --git a/src/sdk/loggedin.ts b/src/sdk/loggedin.ts index 675193ee..b06ff9ec 100644 --- a/src/sdk/loggedin.ts +++ b/src/sdk/loggedin.ts @@ -1,44 +1,15 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { paymentsLoggedInInitialize } from "../funcs/paymentsLoggedInInitialize.js"; +import { paymentsLoggedInPerformAction } from "../funcs/paymentsLoggedInPerformAction.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; -import * as errors from "../models/errors/index.js"; import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class LoggedIn extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - /** * Initialize a Bolt payment for logged in shoppers * @@ -52,89 +23,15 @@ export class LoggedIn extends ClientSDK { paymentInitializeRequest: components.PaymentInitializeRequest, options?: RequestOptions ): Promise { - const input$: operations.PaymentsInitializeRequest = { - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - paymentInitializeRequest: paymentInitializeRequest, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.PaymentsInitializeRequest$outboundSchema.parse(value$), - "Input validation failed" + return unwrapAsync( + paymentsLoggedInInitialize( + this, + xPublishableKey, + xMerchantClientId, + paymentInitializeRequest, + options + ) ); - const body$ = encodeJSON$("body", payload$["payment-initialize-request"], { - explode: true, - }); - - const path$ = this.templateURLComponent("/payments")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "paymentsInitialize", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.PaymentsInitializeResponse$inboundSchema, { - key: "payment-response", - }) - .json("4XX", errors.PaymentsInitializeResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.PaymentsInitializeResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -150,88 +47,15 @@ export class LoggedIn extends ClientSDK { paymentActionRequest: components.PaymentActionRequest, options?: RequestOptions ): Promise { - const input$: operations.PaymentsActionRequest = { - id: id, - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - paymentActionRequest: paymentActionRequest, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.PaymentsActionRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$["payment-action-request"], { explode: true }); - - const pathParams$ = { - id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }), - }; - const path$ = this.templateURLComponent("/payments/{id}")(pathParams$); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$ = - typeof this.options$.security === "function" - ? await this.options$.security() - : this.options$.security; - - const context = { - operationID: "paymentsAction", - oAuth2Scopes: [], - securitySource: this.options$.security, - }; - const securitySettings$ = this.resolveGlobalSecurity(security$); - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options + return unwrapAsync( + paymentsLoggedInPerformAction( + this, + id, + xPublishableKey, + xMerchantClientId, + paymentActionRequest, + options + ) ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.PaymentsActionResponse$inboundSchema, { key: "payment-response" }) - .json("4XX", errors.PaymentsActionResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.PaymentsActionResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } } diff --git a/src/sdk/oauth.ts b/src/sdk/oauth.ts index 2730113a..c8e49a84 100644 --- a/src/sdk/oauth.ts +++ b/src/sdk/oauth.ts @@ -1,47 +1,14 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { - encodeBodyForm as encodeBodyForm$, - encodeSimple as encodeSimple$, -} from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { oAuthGetToken } from "../funcs/oAuthGetToken.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; -import * as errors from "../models/errors/index.js"; import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class OAuth extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - /** * Get OAuth token * @@ -53,74 +20,6 @@ export class OAuth extends ClientSDK { tokenRequest: components.TokenRequest, options?: RequestOptions ): Promise { - const input$: operations.OauthGetTokenRequest = { - xMerchantClientId: xMerchantClientId, - tokenRequest: tokenRequest, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.OauthGetTokenRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = Object.entries(payload$["token-request"] || {}) - .map(([k, v]) => { - return encodeBodyForm$(k, v, { charEncoding: "percent" }); - }) - .join("&"); - - const path$ = this.templateURLComponent("/oauth/token")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/x-www-form-urlencoded", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - }); - - const context = { operationID: "oauthGetToken", oAuth2Scopes: [], securitySource: null }; - - const request$ = this.createRequest$( - context, - { - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.OauthGetTokenResponse$inboundSchema, { - key: "get-access-token-response", - }) - .json("4XX", errors.OauthGetTokenResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.OauthGetTokenResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; + return unwrapAsync(oAuthGetToken(this, xMerchantClientId, tokenRequest, options)); } } diff --git a/src/sdk/orders.ts b/src/sdk/orders.ts index 7cf3eb3a..9133a8c2 100644 --- a/src/sdk/orders.ts +++ b/src/sdk/orders.ts @@ -1,45 +1,14 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { ordersOrdersCreate } from "../funcs/ordersOrdersCreate.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import { SecurityInput } from "../lib/security.js"; import * as components from "../models/components/index.js"; -import * as errors from "../models/errors/index.js"; import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class Orders extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - /** * Create an order that was prepared outside the Bolt ecosystem. * @@ -53,88 +22,8 @@ export class Orders extends ClientSDK { order: components.Order, options?: RequestOptions ): Promise { - const input$: operations.OrdersCreateRequest = { - xPublishableKey: xPublishableKey, - xMerchantClientId: xMerchantClientId, - order: order, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.OrdersCreateRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$.order, { explode: true }); - - const path$ = this.templateURLComponent("/orders")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Merchant-Client-Id": encodeSimple$( - "X-Merchant-Client-Id", - payload$["X-Merchant-Client-Id"], - { explode: false, charEncoding: "none" } - ), - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$: SecurityInput[][] = [ - [ - { - fieldName: "X-API-Key", - type: "apiKey:header", - value: security?.apiKey, - }, - ], - ]; - const securitySettings$ = this.resolveSecurity(...security$); - const context = { - operationID: "ordersCreate", - oAuth2Scopes: [], - securitySource: security$, - }; - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options + return unwrapAsync( + ordersOrdersCreate(this, security, xPublishableKey, xMerchantClientId, order, options) ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.OrdersCreateResponse$inboundSchema, { key: "order-response" }) - .json("4XX", errors.OrdersCreateResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.OrdersCreateResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } } diff --git a/src/sdk/payments.ts b/src/sdk/payments.ts index fe9deb41..dd89e350 100644 --- a/src/sdk/payments.ts +++ b/src/sdk/payments.ts @@ -1,41 +1,12 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { HTTPClient } from "../lib/http.js"; import { ClientSDK } from "../lib/sdks.js"; import { Guest } from "./guest.js"; import { LoggedIn } from "./loggedin.js"; export class Payments extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - private _loggedIn?: LoggedIn; get loggedIn(): LoggedIn { return (this._loggedIn ??= new LoggedIn(this.options$)); diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index 95eea608..90807fa5 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -1,10 +1,7 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { HTTPClient } from "../lib/http.js"; import { ClientSDK } from "../lib/sdks.js"; import { Account } from "./account.js"; import { OAuth } from "./oauth.js"; @@ -13,32 +10,6 @@ import { Payments } from "./payments.js"; import { Testing } from "./testing.js"; export class BoltTypescriptSDK extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - private _account?: Account; get account(): Account { return (this._account ??= new Account(this.options$)); diff --git a/src/sdk/testing.ts b/src/sdk/testing.ts index 03dc888f..8d2d1e11 100644 --- a/src/sdk/testing.ts +++ b/src/sdk/testing.ts @@ -1,45 +1,16 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -import { SDKHooks } from "../hooks/hooks.js"; -import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; -import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import { HTTPClient } from "../lib/http.js"; -import * as schemas$ from "../lib/schemas.js"; +import { testingCreateAccount } from "../funcs/testingCreateAccount.js"; +import { testingGetCreditCard } from "../funcs/testingGetCreditCard.js"; +import { testingTestingAccountPhoneGet } from "../funcs/testingTestingAccountPhoneGet.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; -import { SecurityInput } from "../lib/security.js"; import * as components from "../models/components/index.js"; -import * as errors from "../models/errors/index.js"; import * as operations from "../models/operations/index.js"; +import { unwrapAsync } from "../types/fp.js"; export class Testing extends ClientSDK { - private readonly options$: SDKOptions & { hooks?: SDKHooks }; - - constructor(options: SDKOptions = {}) { - const opt = options as unknown; - let hooks: SDKHooks; - if ( - typeof opt === "object" && - opt != null && - "hooks" in opt && - opt.hooks instanceof SDKHooks - ) { - hooks = opt.hooks; - } else { - hooks = new SDKHooks(); - } - - super({ - client: options.httpClient || new HTTPClient(), - baseURL: serverURLFromOptions(options), - hooks, - }); - - this.options$ = { ...options, hooks }; - void this.options$; - } - /** * Create a test account * @@ -52,87 +23,9 @@ export class Testing extends ClientSDK { accountTestCreationData: components.AccountTestCreationData, options?: RequestOptions ): Promise { - const input$: operations.TestingAccountCreateRequest = { - xPublishableKey: xPublishableKey, - accountTestCreationData: accountTestCreationData, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.TestingAccountCreateRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$["account-test-creation-data"], { - explode: true, - }); - - const path$ = this.templateURLComponent("/testing/accounts")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$: SecurityInput[][] = [ - [ - { - fieldName: "X-API-Key", - type: "apiKey:header", - value: security?.apiKey, - }, - ], - ]; - const securitySettings$ = this.resolveSecurity(...security$); - const context = { - operationID: "testingAccountCreate", - oAuth2Scopes: [], - securitySource: security$, - }; - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options + return unwrapAsync( + testingCreateAccount(this, security, xPublishableKey, accountTestCreationData, options) ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.TestingAccountCreateResponse$inboundSchema, { - key: "account-test-creation-data", - }) - .json("4XX", errors.TestingAccountCreateResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.TestingAccountCreateResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; } /** @@ -146,83 +39,7 @@ export class Testing extends ClientSDK { xPublishableKey: string, options?: RequestOptions ): Promise { - const input$: operations.TestingAccountPhoneGetRequest = { - xPublishableKey: xPublishableKey, - }; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.TestingAccountPhoneGetRequest$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = null; - - const path$ = this.templateURLComponent("/testing/accounts/phones")(); - - const query$ = ""; - - const headers$ = new Headers({ - Accept: "application/json", - "X-Publishable-Key": encodeSimple$("X-Publishable-Key", payload$["X-Publishable-Key"], { - explode: false, - charEncoding: "none", - }), - }); - - const security$: SecurityInput[][] = [ - [ - { - fieldName: "X-API-Key", - type: "apiKey:header", - value: security?.apiKey, - }, - ], - ]; - const securitySettings$ = this.resolveSecurity(...security$); - const context = { - operationID: "testingAccountPhoneGet", - oAuth2Scopes: [], - securitySource: security$, - }; - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "GET", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.TestingAccountPhoneGetResponse$inboundSchema, { - key: "account-test-phone-data", - }) - .json("4XX", errors.TestingAccountPhoneGetResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.TestingAccountPhoneGetResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; + return unwrapAsync(testingTestingAccountPhoneGet(this, security, xPublishableKey, options)); } /** @@ -236,77 +53,6 @@ export class Testing extends ClientSDK { security: operations.TestingCreditCardGetSecurity, options?: RequestOptions ): Promise { - const input$ = request; - - const payload$ = schemas$.parse( - input$, - (value$) => operations.TestingCreditCardGetRequestBody$outboundSchema.parse(value$), - "Input validation failed" - ); - const body$ = encodeJSON$("body", payload$, { explode: true }); - - const path$ = this.templateURLComponent("/testing/credit-cards")(); - - const query$ = ""; - - const headers$ = new Headers({ - "Content-Type": "application/json", - Accept: "application/json", - }); - - const security$: SecurityInput[][] = [ - [ - { - fieldName: "X-API-Key", - type: "apiKey:header", - value: security?.apiKey, - }, - ], - ]; - const securitySettings$ = this.resolveSecurity(...security$); - const context = { - operationID: "testingCreditCardGet", - oAuth2Scopes: [], - securitySource: security$, - }; - - const request$ = this.createRequest$( - context, - { - security: securitySettings$, - method: "POST", - path: path$, - headers: headers$, - query: query$, - body: body$, - timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, - }, - options - ); - - const response = await this.do$(request$, { - context, - errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries || this.options$.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], - }); - - const responseFields$ = { - ContentType: response.headers.get("content-type") ?? "application/octet-stream", - StatusCode: response.status, - RawResponse: response, - Headers: {}, - }; - - const [result$] = await this.matcher() - .json(200, operations.TestingCreditCardGetResponse$inboundSchema, { - key: "test-credit-card", - }) - .json("4XX", errors.TestingCreditCardGetResponseBody$inboundSchema, { err: true }) - .fail("5XX") - .void("default", operations.TestingCreditCardGetResponse$inboundSchema) - .match(response, { extraFields: responseFields$ }); - - return result$; + return unwrapAsync(testingGetCreditCard(this, request, security, options)); } } diff --git a/src/types/blobs.ts b/src/types/blobs.ts index cbb8a57f..4ce84602 100644 --- a/src/types/blobs.ts +++ b/src/types/blobs.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; diff --git a/src/types/constdatetime.ts b/src/types/constdatetime.ts new file mode 100644 index 00000000..c0a4409c --- /dev/null +++ b/src/types/constdatetime.ts @@ -0,0 +1,15 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +export function constDateTime( + val: string, +): z.ZodType { + return z.custom((v) => { + return ( + typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() + ); + }, `Value must be equivelant to ${val}`); +} diff --git a/src/types/enums.ts b/src/types/enums.ts index 4de0142b..6fb6d910 100644 --- a/src/types/enums.ts +++ b/src/types/enums.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ declare const __brand: unique symbol; diff --git a/src/types/fp.ts b/src/types/fp.ts new file mode 100644 index 00000000..ccbe51ea --- /dev/null +++ b/src/types/fp.ts @@ -0,0 +1,50 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** + * A monad that captures the result of a function call or an error if it was not + * successful. Railway programming, enabled by this type, can be a nicer + * alternative to traditional exception throwing because it allows functions to + * declare all _known_ errors with static types and then check for them + * exhaustively in application code. Thrown exception have a type of `unknown` + * and break out of regular control flow of programs making them harder to + * inspect and more verbose work with due to try-catch blocks. + */ +export type Result = + | { ok: true; value: T; error?: never } + | { ok: false; value?: never; error: E }; + +export function OK(value: V): Result { + return { ok: true, value }; +} + +export function ERR(error: E): Result { + return { ok: false, error }; +} + +/** + * unwrap is a convenience function for extracting a value from a result or + * throwing if there was an error. + */ +export function unwrap(r: Result): T { + if (!r.ok) { + throw r.error; + } + return r.value; +} + +/** + * unwrapAsync is a convenience function for resolving a value from a Promise + * of a result or rejecting if an error occurred. + */ +export async function unwrapAsync( + pr: Promise>, +): Promise { + const r = await pr; + if (!r.ok) { + throw r.error; + } + + return r.value; +} diff --git a/src/types/index.ts b/src/types/index.ts index 374373e9..dbaa5e6e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ export { RFCDate } from "./rfcdate.js"; @@ -8,3 +8,4 @@ export type { Paginator, PageIterator } from "./operations.js"; export { createPageIterator } from "./operations.js"; export { catchUnrecognizedEnum } from "./enums.js"; export type { OpenEnum, ClosedEnum, Unrecognized } from "./enums.js"; +export type { Result } from "./fp.js"; diff --git a/src/types/operations.ts b/src/types/operations.ts index 7f833514..0952f6f4 100644 --- a/src/types/operations.ts +++ b/src/types/operations.ts @@ -1,25 +1,99 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export type Paginator = () => Promise> | null; +import { Result } from "./fp.js"; -export type PageIterator = Result & { - next: Paginator; - [Symbol.asyncIterator]: () => AsyncIterableIterator; +export type Paginator = () => Promise }> | null; + +export type PageIterator = V & { + next: Paginator; + [Symbol.asyncIterator]: () => AsyncIterableIterator; }; -export function createPageIterator( - page: Result & { next: Paginator }, -): { [Symbol.asyncIterator]: () => AsyncIterableIterator } { +export function createPageIterator( + page: V & { next: Paginator }, + halt: (v: V) => boolean, +): { + [Symbol.asyncIterator]: () => AsyncIterableIterator; +} { return { [Symbol.asyncIterator]: async function* paginator() { yield page; + if (halt(page)) { + return; + } let p: typeof page | null = page; for (p = await p.next(); p != null; p = await p.next()) { yield p; + if (halt(p)) { + return; + } } }, }; } + +/** + * This utility create a special iterator that yields a single value and + * terminates. It is useful in paginated SDK functions that have early return + * paths when things go wrong. + */ +export function haltIterator(v: V): PageIterator { + return { + ...v, + next: () => null, + [Symbol.asyncIterator]: async function* paginator() { + yield v; + }, + }; +} + +/** + * Converts an async iterator of `Result` into an async iterator of `V`. + * When error results occur, the underlying error value is thrown. + */ +export async function unwrapResultIterator( + iteratorPromise: Promise>>, +): Promise> { + const resultIter = await iteratorPromise; + + if (!resultIter.ok) { + throw resultIter.error; + } + + return { + ...resultIter.value, + next: unwrapPaginator(resultIter.next), + [Symbol.asyncIterator]: async function* paginator() { + for await (const page of resultIter) { + if (!page.ok) { + throw page.error; + } + yield page.value; + } + }, + }; +} + +function unwrapPaginator( + paginator: Paginator>, +): Paginator { + return () => { + const nextResult = paginator(); + if (nextResult == null) { + return null; + } + return nextResult.then((res) => { + if (!res.ok) { + throw res.error; + } + const out = { + ...res.value, + next: unwrapPaginator(res.next), + }; + return out; + }); + }; +} diff --git a/src/types/rfcdate.ts b/src/types/rfcdate.ts index e80b6932..c79b3f53 100644 --- a/src/types/rfcdate.ts +++ b/src/types/rfcdate.ts @@ -1,5 +1,5 @@ /* - * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ const dateRE = /^\d{4}-\d{2}-\d{2}$/; diff --git a/src/types/streams.ts b/src/types/streams.ts new file mode 100644 index 00000000..a0163e7a --- /dev/null +++ b/src/types/streams.ts @@ -0,0 +1,21 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export function isReadableStream( + val: unknown, +): val is ReadableStream { + if (typeof val !== "object" || val === null) { + return false; + } + + // Check for the presence of methods specific to ReadableStream + const stream = val as ReadableStream; + + // ReadableStream has methods like getReader, cancel, and tee + return ( + typeof stream.getReader === "function" && + typeof stream.cancel === "function" && + typeof stream.tee === "function" + ); +}