// Code generated by protoc-gen-twirp v8.1.3, DO NOT EDIT.
// source: livekit_phone_number.proto

package livekit

import context "context"
import fmt "fmt"
import http "net/http"
import io "io"
import json "encoding/json"
import strconv "strconv"
import strings "strings"

import protojson "google.golang.org/protobuf/encoding/protojson"
import proto "google.golang.org/protobuf/proto"
import twirp "github.com/twitchtv/twirp"
import ctxsetters "github.com/twitchtv/twirp/ctxsetters"

// Version compatibility assertion.
// If the constant is not defined in the package, that likely means
// the package needs to be updated to work with this generated code.
// See https://twitchtv.github.io/twirp/docs/version_matrix.html
const _ = twirp.TwirpPackageMinVersion_8_1_0

// ============================
// PhoneNumberService Interface
// ============================

// Public Phone Number Service - External API for phone number management
type PhoneNumberService interface {
	// Search available phone numbers in inventory
	SearchPhoneNumbers(context.Context, *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error)

	// Purchase a phone number from inventory
	PurchasePhoneNumber(context.Context, *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error)

	// List phone numbers for a project
	ListPhoneNumbers(context.Context, *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error)

	// Get a phone number from a project
	GetPhoneNumber(context.Context, *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error)

	// Update a phone number in a project
	UpdatePhoneNumber(context.Context, *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error)

	// Release phone numbers
	ReleasePhoneNumbers(context.Context, *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error)
}

// ==================================
// PhoneNumberService Protobuf Client
// ==================================

type phoneNumberServiceProtobufClient struct {
	client      HTTPClient
	urls        [6]string
	interceptor twirp.Interceptor
	opts        twirp.ClientOptions
}

// NewPhoneNumberServiceProtobufClient creates a Protobuf client that implements the PhoneNumberService interface.
// It communicates using Protobuf and can be configured with a custom HTTPClient.
func NewPhoneNumberServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PhoneNumberService {
	if c, ok := client.(*http.Client); ok {
		client = withoutRedirects(c)
	}

	clientOpts := twirp.ClientOptions{}
	for _, o := range opts {
		o(&clientOpts)
	}

	// Using ReadOpt allows backwards and forwards compatibility with new options in the future
	literalURLs := false
	_ = clientOpts.ReadOpt("literalURLs", &literalURLs)
	var pathPrefix string
	if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok {
		pathPrefix = "/twirp" // default prefix
	}

	// Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method>
	serviceURL := sanitizeBaseURL(baseURL)
	serviceURL += baseServicePath(pathPrefix, "livekit", "PhoneNumberService")
	urls := [6]string{
		serviceURL + "SearchPhoneNumbers",
		serviceURL + "PurchasePhoneNumber",
		serviceURL + "ListPhoneNumbers",
		serviceURL + "GetPhoneNumber",
		serviceURL + "UpdatePhoneNumber",
		serviceURL + "ReleasePhoneNumbers",
	}

	return &phoneNumberServiceProtobufClient{
		client:      client,
		urls:        urls,
		interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...),
		opts:        clientOpts,
	}
}

func (c *phoneNumberServiceProtobufClient) SearchPhoneNumbers(ctx context.Context, in *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "SearchPhoneNumbers")
	caller := c.callSearchPhoneNumbers
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*SearchPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*SearchPhoneNumbersRequest) when calling interceptor")
					}
					return c.callSearchPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*SearchPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*SearchPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceProtobufClient) callSearchPhoneNumbers(ctx context.Context, in *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
	out := new(SearchPhoneNumbersResponse)
	ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceProtobufClient) PurchasePhoneNumber(ctx context.Context, in *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "PurchasePhoneNumber")
	caller := c.callPurchasePhoneNumber
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*PurchasePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*PurchasePhoneNumberRequest) when calling interceptor")
					}
					return c.callPurchasePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*PurchasePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*PurchasePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceProtobufClient) callPurchasePhoneNumber(ctx context.Context, in *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
	out := new(PurchasePhoneNumberResponse)
	ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceProtobufClient) ListPhoneNumbers(ctx context.Context, in *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "ListPhoneNumbers")
	caller := c.callListPhoneNumbers
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ListPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ListPhoneNumbersRequest) when calling interceptor")
					}
					return c.callListPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ListPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ListPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceProtobufClient) callListPhoneNumbers(ctx context.Context, in *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
	out := new(ListPhoneNumbersResponse)
	ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceProtobufClient) GetPhoneNumber(ctx context.Context, in *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "GetPhoneNumber")
	caller := c.callGetPhoneNumber
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*GetPhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*GetPhoneNumberRequest) when calling interceptor")
					}
					return c.callGetPhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*GetPhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*GetPhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceProtobufClient) callGetPhoneNumber(ctx context.Context, in *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
	out := new(GetPhoneNumberResponse)
	ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceProtobufClient) UpdatePhoneNumber(ctx context.Context, in *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "UpdatePhoneNumber")
	caller := c.callUpdatePhoneNumber
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*UpdatePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*UpdatePhoneNumberRequest) when calling interceptor")
					}
					return c.callUpdatePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*UpdatePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*UpdatePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceProtobufClient) callUpdatePhoneNumber(ctx context.Context, in *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
	out := new(UpdatePhoneNumberResponse)
	ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceProtobufClient) ReleasePhoneNumbers(ctx context.Context, in *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "ReleasePhoneNumbers")
	caller := c.callReleasePhoneNumbers
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ReleasePhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ReleasePhoneNumbersRequest) when calling interceptor")
					}
					return c.callReleasePhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ReleasePhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ReleasePhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceProtobufClient) callReleasePhoneNumbers(ctx context.Context, in *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
	out := new(ReleasePhoneNumbersResponse)
	ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

// ==============================
// PhoneNumberService JSON Client
// ==============================

type phoneNumberServiceJSONClient struct {
	client      HTTPClient
	urls        [6]string
	interceptor twirp.Interceptor
	opts        twirp.ClientOptions
}

// NewPhoneNumberServiceJSONClient creates a JSON client that implements the PhoneNumberService interface.
// It communicates using JSON and can be configured with a custom HTTPClient.
func NewPhoneNumberServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PhoneNumberService {
	if c, ok := client.(*http.Client); ok {
		client = withoutRedirects(c)
	}

	clientOpts := twirp.ClientOptions{}
	for _, o := range opts {
		o(&clientOpts)
	}

	// Using ReadOpt allows backwards and forwards compatibility with new options in the future
	literalURLs := false
	_ = clientOpts.ReadOpt("literalURLs", &literalURLs)
	var pathPrefix string
	if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok {
		pathPrefix = "/twirp" // default prefix
	}

	// Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method>
	serviceURL := sanitizeBaseURL(baseURL)
	serviceURL += baseServicePath(pathPrefix, "livekit", "PhoneNumberService")
	urls := [6]string{
		serviceURL + "SearchPhoneNumbers",
		serviceURL + "PurchasePhoneNumber",
		serviceURL + "ListPhoneNumbers",
		serviceURL + "GetPhoneNumber",
		serviceURL + "UpdatePhoneNumber",
		serviceURL + "ReleasePhoneNumbers",
	}

	return &phoneNumberServiceJSONClient{
		client:      client,
		urls:        urls,
		interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...),
		opts:        clientOpts,
	}
}

func (c *phoneNumberServiceJSONClient) SearchPhoneNumbers(ctx context.Context, in *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "SearchPhoneNumbers")
	caller := c.callSearchPhoneNumbers
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*SearchPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*SearchPhoneNumbersRequest) when calling interceptor")
					}
					return c.callSearchPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*SearchPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*SearchPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceJSONClient) callSearchPhoneNumbers(ctx context.Context, in *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
	out := new(SearchPhoneNumbersResponse)
	ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceJSONClient) PurchasePhoneNumber(ctx context.Context, in *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "PurchasePhoneNumber")
	caller := c.callPurchasePhoneNumber
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*PurchasePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*PurchasePhoneNumberRequest) when calling interceptor")
					}
					return c.callPurchasePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*PurchasePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*PurchasePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceJSONClient) callPurchasePhoneNumber(ctx context.Context, in *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
	out := new(PurchasePhoneNumberResponse)
	ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceJSONClient) ListPhoneNumbers(ctx context.Context, in *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "ListPhoneNumbers")
	caller := c.callListPhoneNumbers
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ListPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ListPhoneNumbersRequest) when calling interceptor")
					}
					return c.callListPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ListPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ListPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceJSONClient) callListPhoneNumbers(ctx context.Context, in *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
	out := new(ListPhoneNumbersResponse)
	ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceJSONClient) GetPhoneNumber(ctx context.Context, in *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "GetPhoneNumber")
	caller := c.callGetPhoneNumber
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*GetPhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*GetPhoneNumberRequest) when calling interceptor")
					}
					return c.callGetPhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*GetPhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*GetPhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceJSONClient) callGetPhoneNumber(ctx context.Context, in *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
	out := new(GetPhoneNumberResponse)
	ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceJSONClient) UpdatePhoneNumber(ctx context.Context, in *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "UpdatePhoneNumber")
	caller := c.callUpdatePhoneNumber
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*UpdatePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*UpdatePhoneNumberRequest) when calling interceptor")
					}
					return c.callUpdatePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*UpdatePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*UpdatePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceJSONClient) callUpdatePhoneNumber(ctx context.Context, in *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
	out := new(UpdatePhoneNumberResponse)
	ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

func (c *phoneNumberServiceJSONClient) ReleasePhoneNumbers(ctx context.Context, in *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithMethodName(ctx, "ReleasePhoneNumbers")
	caller := c.callReleasePhoneNumbers
	if c.interceptor != nil {
		caller = func(ctx context.Context, req *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
			resp, err := c.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ReleasePhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ReleasePhoneNumbersRequest) when calling interceptor")
					}
					return c.callReleasePhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ReleasePhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ReleasePhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}
	return caller(ctx, in)
}

func (c *phoneNumberServiceJSONClient) callReleasePhoneNumbers(ctx context.Context, in *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
	out := new(ReleasePhoneNumbersResponse)
	ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out)
	if err != nil {
		twerr, ok := err.(twirp.Error)
		if !ok {
			twerr = twirp.InternalErrorWith(err)
		}
		callClientError(ctx, c.opts.Hooks, twerr)
		return nil, err
	}

	callClientResponseReceived(ctx, c.opts.Hooks)

	return out, nil
}

// =================================
// PhoneNumberService Server Handler
// =================================

type phoneNumberServiceServer struct {
	PhoneNumberService
	interceptor      twirp.Interceptor
	hooks            *twirp.ServerHooks
	pathPrefix       string // prefix for routing
	jsonSkipDefaults bool   // do not include unpopulated fields (default values) in the response
	jsonCamelCase    bool   // JSON fields are serialized as lowerCamelCase rather than keeping the original proto names
}

// NewPhoneNumberServiceServer builds a TwirpServer that can be used as an http.Handler to handle
// HTTP requests that are routed to the right method in the provided svc implementation.
// The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).
func NewPhoneNumberServiceServer(svc PhoneNumberService, opts ...interface{}) TwirpServer {
	serverOpts := newServerOpts(opts)

	// Using ReadOpt allows backwards and forwards compatibility with new options in the future
	jsonSkipDefaults := false
	_ = serverOpts.ReadOpt("jsonSkipDefaults", &jsonSkipDefaults)
	jsonCamelCase := false
	_ = serverOpts.ReadOpt("jsonCamelCase", &jsonCamelCase)
	var pathPrefix string
	if ok := serverOpts.ReadOpt("pathPrefix", &pathPrefix); !ok {
		pathPrefix = "/twirp" // default prefix
	}

	return &phoneNumberServiceServer{
		PhoneNumberService: svc,
		hooks:              serverOpts.Hooks,
		interceptor:        twirp.ChainInterceptors(serverOpts.Interceptors...),
		pathPrefix:         pathPrefix,
		jsonSkipDefaults:   jsonSkipDefaults,
		jsonCamelCase:      jsonCamelCase,
	}
}

// writeError writes an HTTP response with a valid Twirp error format, and triggers hooks.
// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
func (s *phoneNumberServiceServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) {
	writeError(ctx, resp, err, s.hooks)
}

// handleRequestBodyError is used to handle error when the twirp server cannot read request
func (s *phoneNumberServiceServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) {
	if context.Canceled == ctx.Err() {
		s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled"))
		return
	}
	if context.DeadlineExceeded == ctx.Err() {
		s.writeError(ctx, resp, twirp.NewError(twirp.DeadlineExceeded, "failed to read request: deadline exceeded"))
		return
	}
	s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err))
}

// PhoneNumberServicePathPrefix is a convenience constant that may identify URL paths.
// Should be used with caution, it only matches routes generated by Twirp Go clients,
// with the default "/twirp" prefix and default CamelCase service and method names.
// More info: https://twitchtv.github.io/twirp/docs/routing.html
const PhoneNumberServicePathPrefix = "/twirp/livekit.PhoneNumberService/"

func (s *phoneNumberServiceServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
	ctx := req.Context()
	ctx = ctxsetters.WithPackageName(ctx, "livekit")
	ctx = ctxsetters.WithServiceName(ctx, "PhoneNumberService")
	ctx = ctxsetters.WithResponseWriter(ctx, resp)

	var err error
	ctx, err = callRequestReceived(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	if req.Method != "POST" {
		msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method)
		s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
		return
	}

	// Verify path format: [<prefix>]/<package>.<Service>/<Method>
	prefix, pkgService, method := parseTwirpPath(req.URL.Path)
	if pkgService != "livekit.PhoneNumberService" {
		msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
		s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
		return
	}
	if prefix != s.pathPrefix {
		msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path)
		s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
		return
	}

	switch method {
	case "SearchPhoneNumbers":
		s.serveSearchPhoneNumbers(ctx, resp, req)
		return
	case "PurchasePhoneNumber":
		s.servePurchasePhoneNumber(ctx, resp, req)
		return
	case "ListPhoneNumbers":
		s.serveListPhoneNumbers(ctx, resp, req)
		return
	case "GetPhoneNumber":
		s.serveGetPhoneNumber(ctx, resp, req)
		return
	case "UpdatePhoneNumber":
		s.serveUpdatePhoneNumber(ctx, resp, req)
		return
	case "ReleasePhoneNumbers":
		s.serveReleasePhoneNumbers(ctx, resp, req)
		return
	default:
		msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
		s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
		return
	}
}

func (s *phoneNumberServiceServer) serveSearchPhoneNumbers(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	header := req.Header.Get("Content-Type")
	i := strings.Index(header, ";")
	if i == -1 {
		i = len(header)
	}
	switch strings.TrimSpace(strings.ToLower(header[:i])) {
	case "application/json":
		s.serveSearchPhoneNumbersJSON(ctx, resp, req)
	case "application/protobuf":
		s.serveSearchPhoneNumbersProtobuf(ctx, resp, req)
	default:
		msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
		twerr := badRouteError(msg, req.Method, req.URL.Path)
		s.writeError(ctx, resp, twerr)
	}
}

func (s *phoneNumberServiceServer) serveSearchPhoneNumbersJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "SearchPhoneNumbers")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	d := json.NewDecoder(req.Body)
	rawReqBody := json.RawMessage{}
	if err := d.Decode(&rawReqBody); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}
	reqContent := new(SearchPhoneNumbersRequest)
	unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
	if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}

	handler := s.PhoneNumberService.SearchPhoneNumbers
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*SearchPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*SearchPhoneNumbersRequest) when calling interceptor")
					}
					return s.PhoneNumberService.SearchPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*SearchPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*SearchPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *SearchPhoneNumbersResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *SearchPhoneNumbersResponse and nil error while calling SearchPhoneNumbers. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
	respBytes, err := marshaler.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveSearchPhoneNumbersProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "SearchPhoneNumbers")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	buf, err := io.ReadAll(req.Body)
	if err != nil {
		s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
		return
	}
	reqContent := new(SearchPhoneNumbersRequest)
	if err = proto.Unmarshal(buf, reqContent); err != nil {
		s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
		return
	}

	handler := s.PhoneNumberService.SearchPhoneNumbers
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *SearchPhoneNumbersRequest) (*SearchPhoneNumbersResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*SearchPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*SearchPhoneNumbersRequest) when calling interceptor")
					}
					return s.PhoneNumberService.SearchPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*SearchPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*SearchPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *SearchPhoneNumbersResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *SearchPhoneNumbersResponse and nil error while calling SearchPhoneNumbers. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	respBytes, err := proto.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/protobuf")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)
	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) servePurchasePhoneNumber(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	header := req.Header.Get("Content-Type")
	i := strings.Index(header, ";")
	if i == -1 {
		i = len(header)
	}
	switch strings.TrimSpace(strings.ToLower(header[:i])) {
	case "application/json":
		s.servePurchasePhoneNumberJSON(ctx, resp, req)
	case "application/protobuf":
		s.servePurchasePhoneNumberProtobuf(ctx, resp, req)
	default:
		msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
		twerr := badRouteError(msg, req.Method, req.URL.Path)
		s.writeError(ctx, resp, twerr)
	}
}

func (s *phoneNumberServiceServer) servePurchasePhoneNumberJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "PurchasePhoneNumber")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	d := json.NewDecoder(req.Body)
	rawReqBody := json.RawMessage{}
	if err := d.Decode(&rawReqBody); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}
	reqContent := new(PurchasePhoneNumberRequest)
	unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
	if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}

	handler := s.PhoneNumberService.PurchasePhoneNumber
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*PurchasePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*PurchasePhoneNumberRequest) when calling interceptor")
					}
					return s.PhoneNumberService.PurchasePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*PurchasePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*PurchasePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *PurchasePhoneNumberResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *PurchasePhoneNumberResponse and nil error while calling PurchasePhoneNumber. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
	respBytes, err := marshaler.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) servePurchasePhoneNumberProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "PurchasePhoneNumber")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	buf, err := io.ReadAll(req.Body)
	if err != nil {
		s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
		return
	}
	reqContent := new(PurchasePhoneNumberRequest)
	if err = proto.Unmarshal(buf, reqContent); err != nil {
		s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
		return
	}

	handler := s.PhoneNumberService.PurchasePhoneNumber
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *PurchasePhoneNumberRequest) (*PurchasePhoneNumberResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*PurchasePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*PurchasePhoneNumberRequest) when calling interceptor")
					}
					return s.PhoneNumberService.PurchasePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*PurchasePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*PurchasePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *PurchasePhoneNumberResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *PurchasePhoneNumberResponse and nil error while calling PurchasePhoneNumber. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	respBytes, err := proto.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/protobuf")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)
	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveListPhoneNumbers(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	header := req.Header.Get("Content-Type")
	i := strings.Index(header, ";")
	if i == -1 {
		i = len(header)
	}
	switch strings.TrimSpace(strings.ToLower(header[:i])) {
	case "application/json":
		s.serveListPhoneNumbersJSON(ctx, resp, req)
	case "application/protobuf":
		s.serveListPhoneNumbersProtobuf(ctx, resp, req)
	default:
		msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
		twerr := badRouteError(msg, req.Method, req.URL.Path)
		s.writeError(ctx, resp, twerr)
	}
}

func (s *phoneNumberServiceServer) serveListPhoneNumbersJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "ListPhoneNumbers")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	d := json.NewDecoder(req.Body)
	rawReqBody := json.RawMessage{}
	if err := d.Decode(&rawReqBody); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}
	reqContent := new(ListPhoneNumbersRequest)
	unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
	if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}

	handler := s.PhoneNumberService.ListPhoneNumbers
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ListPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ListPhoneNumbersRequest) when calling interceptor")
					}
					return s.PhoneNumberService.ListPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ListPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ListPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *ListPhoneNumbersResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *ListPhoneNumbersResponse and nil error while calling ListPhoneNumbers. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
	respBytes, err := marshaler.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveListPhoneNumbersProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "ListPhoneNumbers")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	buf, err := io.ReadAll(req.Body)
	if err != nil {
		s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
		return
	}
	reqContent := new(ListPhoneNumbersRequest)
	if err = proto.Unmarshal(buf, reqContent); err != nil {
		s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
		return
	}

	handler := s.PhoneNumberService.ListPhoneNumbers
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *ListPhoneNumbersRequest) (*ListPhoneNumbersResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ListPhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ListPhoneNumbersRequest) when calling interceptor")
					}
					return s.PhoneNumberService.ListPhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ListPhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ListPhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *ListPhoneNumbersResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *ListPhoneNumbersResponse and nil error while calling ListPhoneNumbers. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	respBytes, err := proto.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/protobuf")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)
	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveGetPhoneNumber(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	header := req.Header.Get("Content-Type")
	i := strings.Index(header, ";")
	if i == -1 {
		i = len(header)
	}
	switch strings.TrimSpace(strings.ToLower(header[:i])) {
	case "application/json":
		s.serveGetPhoneNumberJSON(ctx, resp, req)
	case "application/protobuf":
		s.serveGetPhoneNumberProtobuf(ctx, resp, req)
	default:
		msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
		twerr := badRouteError(msg, req.Method, req.URL.Path)
		s.writeError(ctx, resp, twerr)
	}
}

func (s *phoneNumberServiceServer) serveGetPhoneNumberJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "GetPhoneNumber")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	d := json.NewDecoder(req.Body)
	rawReqBody := json.RawMessage{}
	if err := d.Decode(&rawReqBody); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}
	reqContent := new(GetPhoneNumberRequest)
	unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
	if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}

	handler := s.PhoneNumberService.GetPhoneNumber
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*GetPhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*GetPhoneNumberRequest) when calling interceptor")
					}
					return s.PhoneNumberService.GetPhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*GetPhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*GetPhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *GetPhoneNumberResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *GetPhoneNumberResponse and nil error while calling GetPhoneNumber. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
	respBytes, err := marshaler.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveGetPhoneNumberProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "GetPhoneNumber")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	buf, err := io.ReadAll(req.Body)
	if err != nil {
		s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
		return
	}
	reqContent := new(GetPhoneNumberRequest)
	if err = proto.Unmarshal(buf, reqContent); err != nil {
		s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
		return
	}

	handler := s.PhoneNumberService.GetPhoneNumber
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *GetPhoneNumberRequest) (*GetPhoneNumberResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*GetPhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*GetPhoneNumberRequest) when calling interceptor")
					}
					return s.PhoneNumberService.GetPhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*GetPhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*GetPhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *GetPhoneNumberResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *GetPhoneNumberResponse and nil error while calling GetPhoneNumber. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	respBytes, err := proto.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/protobuf")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)
	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveUpdatePhoneNumber(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	header := req.Header.Get("Content-Type")
	i := strings.Index(header, ";")
	if i == -1 {
		i = len(header)
	}
	switch strings.TrimSpace(strings.ToLower(header[:i])) {
	case "application/json":
		s.serveUpdatePhoneNumberJSON(ctx, resp, req)
	case "application/protobuf":
		s.serveUpdatePhoneNumberProtobuf(ctx, resp, req)
	default:
		msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
		twerr := badRouteError(msg, req.Method, req.URL.Path)
		s.writeError(ctx, resp, twerr)
	}
}

func (s *phoneNumberServiceServer) serveUpdatePhoneNumberJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "UpdatePhoneNumber")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	d := json.NewDecoder(req.Body)
	rawReqBody := json.RawMessage{}
	if err := d.Decode(&rawReqBody); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}
	reqContent := new(UpdatePhoneNumberRequest)
	unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
	if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}

	handler := s.PhoneNumberService.UpdatePhoneNumber
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*UpdatePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*UpdatePhoneNumberRequest) when calling interceptor")
					}
					return s.PhoneNumberService.UpdatePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*UpdatePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*UpdatePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *UpdatePhoneNumberResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *UpdatePhoneNumberResponse and nil error while calling UpdatePhoneNumber. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
	respBytes, err := marshaler.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveUpdatePhoneNumberProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "UpdatePhoneNumber")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	buf, err := io.ReadAll(req.Body)
	if err != nil {
		s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
		return
	}
	reqContent := new(UpdatePhoneNumberRequest)
	if err = proto.Unmarshal(buf, reqContent); err != nil {
		s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
		return
	}

	handler := s.PhoneNumberService.UpdatePhoneNumber
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *UpdatePhoneNumberRequest) (*UpdatePhoneNumberResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*UpdatePhoneNumberRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*UpdatePhoneNumberRequest) when calling interceptor")
					}
					return s.PhoneNumberService.UpdatePhoneNumber(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*UpdatePhoneNumberResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*UpdatePhoneNumberResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *UpdatePhoneNumberResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *UpdatePhoneNumberResponse and nil error while calling UpdatePhoneNumber. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	respBytes, err := proto.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/protobuf")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)
	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveReleasePhoneNumbers(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	header := req.Header.Get("Content-Type")
	i := strings.Index(header, ";")
	if i == -1 {
		i = len(header)
	}
	switch strings.TrimSpace(strings.ToLower(header[:i])) {
	case "application/json":
		s.serveReleasePhoneNumbersJSON(ctx, resp, req)
	case "application/protobuf":
		s.serveReleasePhoneNumbersProtobuf(ctx, resp, req)
	default:
		msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
		twerr := badRouteError(msg, req.Method, req.URL.Path)
		s.writeError(ctx, resp, twerr)
	}
}

func (s *phoneNumberServiceServer) serveReleasePhoneNumbersJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "ReleasePhoneNumbers")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	d := json.NewDecoder(req.Body)
	rawReqBody := json.RawMessage{}
	if err := d.Decode(&rawReqBody); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}
	reqContent := new(ReleasePhoneNumbersRequest)
	unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
	if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
		s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
		return
	}

	handler := s.PhoneNumberService.ReleasePhoneNumbers
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ReleasePhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ReleasePhoneNumbersRequest) when calling interceptor")
					}
					return s.PhoneNumberService.ReleasePhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ReleasePhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ReleasePhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *ReleasePhoneNumbersResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *ReleasePhoneNumbersResponse and nil error while calling ReleasePhoneNumbers. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
	respBytes, err := marshaler.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/json")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) serveReleasePhoneNumbersProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
	var err error
	ctx = ctxsetters.WithMethodName(ctx, "ReleasePhoneNumbers")
	ctx, err = callRequestRouted(ctx, s.hooks)
	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}

	buf, err := io.ReadAll(req.Body)
	if err != nil {
		s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
		return
	}
	reqContent := new(ReleasePhoneNumbersRequest)
	if err = proto.Unmarshal(buf, reqContent); err != nil {
		s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
		return
	}

	handler := s.PhoneNumberService.ReleasePhoneNumbers
	if s.interceptor != nil {
		handler = func(ctx context.Context, req *ReleasePhoneNumbersRequest) (*ReleasePhoneNumbersResponse, error) {
			resp, err := s.interceptor(
				func(ctx context.Context, req interface{}) (interface{}, error) {
					typedReq, ok := req.(*ReleasePhoneNumbersRequest)
					if !ok {
						return nil, twirp.InternalError("failed type assertion req.(*ReleasePhoneNumbersRequest) when calling interceptor")
					}
					return s.PhoneNumberService.ReleasePhoneNumbers(ctx, typedReq)
				},
			)(ctx, req)
			if resp != nil {
				typedResp, ok := resp.(*ReleasePhoneNumbersResponse)
				if !ok {
					return nil, twirp.InternalError("failed type assertion resp.(*ReleasePhoneNumbersResponse) when calling interceptor")
				}
				return typedResp, err
			}
			return nil, err
		}
	}

	// Call service method
	var respContent *ReleasePhoneNumbersResponse
	func() {
		defer ensurePanicResponses(ctx, resp, s.hooks)
		respContent, err = handler(ctx, reqContent)
	}()

	if err != nil {
		s.writeError(ctx, resp, err)
		return
	}
	if respContent == nil {
		s.writeError(ctx, resp, twirp.InternalError("received a nil *ReleasePhoneNumbersResponse and nil error while calling ReleasePhoneNumbers. nil responses are not supported"))
		return
	}

	ctx = callResponsePrepared(ctx, s.hooks)

	respBytes, err := proto.Marshal(respContent)
	if err != nil {
		s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
		return
	}

	ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
	resp.Header().Set("Content-Type", "application/protobuf")
	resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
	resp.WriteHeader(http.StatusOK)
	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
		twerr := twirp.NewError(twirp.Unknown, msg)
		ctx = callError(ctx, s.hooks, twerr)
	}
	callResponseSent(ctx, s.hooks)
}

func (s *phoneNumberServiceServer) ServiceDescriptor() ([]byte, int) {
	return twirpFileDescriptor6, 0
}

func (s *phoneNumberServiceServer) ProtocGenTwirpVersion() string {
	return "v8.1.3"
}

// PathPrefix returns the base service path, in the form: "/<prefix>/<package>.<Service>/"
// that is everything in a Twirp route except for the <Method>. This can be used for routing,
// for example to identify the requests that are targeted to this service in a mux.
func (s *phoneNumberServiceServer) PathPrefix() string {
	return baseServicePath(s.pathPrefix, "livekit", "PhoneNumberService")
}

var twirpFileDescriptor6 = []byte{
	// 1190 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xdd, 0x6e, 0xe2, 0x46,
	0x14, 0x66, 0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