Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Documented the test email SDK sample with a signed-in client
Damian Legawiec9a0f7672d663
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yamlindex c4b7fa2f74..79d2f60935 100644--- a/docs/api-reference/admin.yaml+++ b/docs/api-reference/admin.yaml@@ -8406,7 +8406,7 @@ paths:const client = createAdminClient({baseUrl: 'https://your-store.com',- secretKey: 'sk_xxx',+ jwtToken: 'eyJhbGciOi...',})// Sent to the signed-in admin, so this needs a client created with `jwtToken`;diff --git a/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rbindex 0a5be17995..41639687bf 100644--- a/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/admin/email_templates_spec.rb@@ -349,7 +349,7 @@ RSpec.describe 'Admin Email Templates API', type: :request, swagger_doc: 'api-refrom a real customer's records. Takes the same body as the preview.DESC- admin_sdk_example 'email-templates/send-test'+ admin_sdk_example 'email-templates/send-test', signed_in: trueinclude_context 'with admin auth parameters'parameter name: :body, in: :body, schema: {diff --git a/spree/api/spec/support/code_samples_helper.rb b/spree/api/spec/support/code_samples_helper.rbindex cd0ed7e4a2..dabd27b177 100644--- a/spree/api/spec/support/code_samples_helper.rb+++ b/spree/api/spec/support/code_samples_helper.rb@@ -21,6 +21,16 @@ module CodeSamplesHelper})JS+ # For endpoints only a signed-in admin can call (they act on that admin).+ ADMIN_SDK_JWT_CLIENT_INIT = <<~JS.strip+ import { createAdminClient } from '@spree/admin-sdk'++ const client = createAdminClient({+ baseUrl: 'https://your-store.com',+ jwtToken: 'eyJhbGciOi...',+ })+ JS+SDK_EXAMPLES_ROOT = File.expand_path('../../../../packages/sdk/examples', __dir__)ADMIN_SDK_EXAMPLES_ROOT = File.expand_path('../../../../packages/admin-sdk/examples', __dir__)@@ -66,13 +76,13 @@ module CodeSamplesHelper# `createAdminClient`. Also emits a matching `spree api` CLI sample, derived# from the operation's verb + path, so every documented Admin endpoint shows# SDK *and* CLI usage side by side (à la Stripe's per-endpoint CLI tab).- def admin_sdk_example(name)+ def admin_sdk_example(name, signed_in: false)source = EXAMPLE_CACHE[[:admin, name]] ||= load_example_body(ADMIN_SDK_EXAMPLES_ROOT, name, 'Admin SDK')code_samples({lang: 'javascript',label: 'Spree Admin SDK',- source: "#{ADMIN_SDK_CLIENT_INIT}\n\n#{source}\n"+ source: "#{signed_in ? ADMIN_SDK_JWT_CLIENT_INIT : ADMIN_SDK_CLIENT_INIT}\n\n#{source}\n"})admin_cli_example(sdk_body_json(source), sdk_call_has_args(source))