diff --git a/AGENTS.md b/AGENTS.md index bb3317a..bf03cd3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -420,7 +420,7 @@ agent with email/web access) to finish. ```bash band account register --phone +15555550100 --email you@example.com --first-name Jane --last-name Doe --accept-tos -# → registration submitted (POST /v1/express/registration) +# → registration submitted (POST /v1/build/registrations) band account send-code --phone +15555550100 --email you@example.com --delivery-channel sms # or "voice" # → verification code sent. Choosing "sms" IS the customer's consent to diff --git a/cmd/account/golden_test.go b/cmd/account/golden_test.go index f6e457a..7dec6e0 100644 --- a/cmd/account/golden_test.go +++ b/cmd/account/golden_test.go @@ -22,7 +22,7 @@ func TestRegisterPlainOutput(t *testing.T) { "links": []interface{}{}, "data": map[string]interface{}{ "message": "Onboarding request received successfully", - "status": "USER_CREATION_PENDING", + "status": "USER_CREATION_INITIATED", "registrationId": "reg-123", }, "errors": []interface{}{}, @@ -47,13 +47,13 @@ func TestRegisterPlainOutput(t *testing.T) { } }) - want := "{\n \"message\": \"Onboarding request received successfully\",\n \"registrationId\": \"reg-123\",\n \"status\": \"USER_CREATION_PENDING\"\n}\n" + want := "{\n \"message\": \"Onboarding request received successfully\",\n \"registrationId\": \"reg-123\",\n \"status\": \"USER_CREATION_INITIATED\"\n}\n" if out != want { t.Fatalf("golden mismatch:\n got: %q\nwant: %q", out, want) } - if fake.PostPath != "/registration" { - t.Errorf("PostPath = %q, want %q", fake.PostPath, "/registration") + if fake.PostPath != "/registrations" { + t.Errorf("PostPath = %q, want %q", fake.PostPath, "/registrations") } body, ok := fake.PostBody.(map[string]interface{}) if !ok { @@ -101,8 +101,8 @@ func TestSendCodePlainOutput(t *testing.T) { t.Fatalf("golden mismatch:\n got: %q\nwant: %q", out, want) } - if fake.PostPath != "/registration/code" { - t.Errorf("PostPath = %q, want %q", fake.PostPath, "/registration/code") + if fake.PostPath != "/registrations/code" { + t.Errorf("PostPath = %q, want %q", fake.PostPath, "/registrations/code") } body, ok := fake.PostBody.(map[string]interface{}) if !ok { @@ -145,8 +145,8 @@ func TestVerifyPlainOutput(t *testing.T) { t.Fatalf("golden mismatch:\n got: %q\nwant: %q", out, want) } - if fake.PostPath != "/registration/code/verify" { - t.Errorf("PostPath = %q, want %q", fake.PostPath, "/registration/code/verify") + if fake.PostPath != "/registrations/code/verify" { + t.Errorf("PostPath = %q, want %q", fake.PostPath, "/registrations/code/verify") } body, ok := fake.PostBody.(map[string]interface{}) if !ok { diff --git a/cmd/account/register.go b/cmd/account/register.go index fffeef3..e195aac 100644 --- a/cmd/account/register.go +++ b/cmd/account/register.go @@ -110,7 +110,7 @@ func runRegister(cmd *cobra.Command, args []string) error { } var result interface{} - if err := client.Post(cmd.Context(), "/registration", reqBody, &result); err != nil { + if err := client.Post(cmd.Context(), "/registrations", reqBody, &result); err != nil { return fmt.Errorf("registering account: %w", err) } diff --git a/cmd/account/send_code.go b/cmd/account/send_code.go index fba8a94..ab1b16d 100644 --- a/cmd/account/send_code.go +++ b/cmd/account/send_code.go @@ -71,7 +71,7 @@ func runSendCode(cmd *cobra.Command, args []string) error { } var result interface{} - if err := client.Post(cmd.Context(), "/registration/code", reqBody, &result); err != nil { + if err := client.Post(cmd.Context(), "/registrations/code", reqBody, &result); err != nil { return fmt.Errorf("sending verification code: %w", err) } diff --git a/cmd/account/verify.go b/cmd/account/verify.go index 57bf2a8..1396dd6 100644 --- a/cmd/account/verify.go +++ b/cmd/account/verify.go @@ -53,7 +53,7 @@ func runVerify(cmd *cobra.Command, args []string) error { } var result interface{} - if err := client.Post(cmd.Context(), "/registration/code/verify", reqBody, &result); err != nil { + if err := client.Post(cmd.Context(), "/registrations/code/verify", reqBody, &result); err != nil { return fmt.Errorf("verifying phone number: %w", err) } diff --git a/internal/cmdutil/helpers.go b/internal/cmdutil/helpers.go index ae1213f..95cef4d 100644 --- a/internal/cmdutil/helpers.go +++ b/internal/cmdutil/helpers.go @@ -78,7 +78,7 @@ func apiHostForEnvironment(env string) string { // RegistrationHost returns the Build registration API base URL, honoring BW_API_URL like every other client in this file. func RegistrationHost() string { - return apiHostForEnvironment("") + "/v1/express" + return apiHostForEnvironment("") + "/v1/build" } // voiceHostForEnvironment maps an environment name to its Voice API host. diff --git a/internal/cmdutil/helpers_test.go b/internal/cmdutil/helpers_test.go index b225048..99ce1b1 100644 --- a/internal/cmdutil/helpers_test.go +++ b/internal/cmdutil/helpers_test.go @@ -133,6 +133,20 @@ func TestMessagingHost_BW_MESSAGING_URL_TrailingSlash(t *testing.T) { } } +func TestRegistrationHost(t *testing.T) { + t.Setenv("BW_API_URL", "") + if got := RegistrationHost(); got != "https://api.bandwidth.com/v1/build" { + t.Errorf("RegistrationHost() = %q, want https://api.bandwidth.com/v1/build", got) + } +} + +func TestRegistrationHost_BW_API_URL(t *testing.T) { + t.Setenv("BW_API_URL", "https://custom.example.com/") + if got := RegistrationHost(); got != "https://custom.example.com/v1/build" { + t.Errorf("RegistrationHost() with BW_API_URL = %q, want https://custom.example.com/v1/build", got) + } +} + func TestResolveEnvironment(t *testing.T) { t.Run("no override returns profile env", func(t *testing.T) { EnvironmentOverride = ""