11import { RequestTracingConfig , RequestConfig , inflightUrlWithQuery } from '../../../HttpClient'
22import { JanusClient } from '../JanusClient'
3+ import assertBindingInput from './assertBindingInput'
34import {
45 OptionsListBindings ,
56 APIBindingRes ,
@@ -112,41 +113,12 @@ export class LicenseManager extends JanusClient {
112113 } )
113114 }
114115
115- public createBinding = (
116- {
117- tenant,
118- adminUserAuthToken,
119- defaultLocale,
120- supportedLocales,
121- salesChannelId,
122- addrs,
123- canonicalAddr,
124- } : OptionsCreateBinding ,
125- config ?: RequestConfig
126- ) => {
127- const metric = 'lm-create-binding'
128-
129- if ( addrs . length === 0 ) {
130- throw new Error ( 'A binding must have at least one address' )
131- }
132-
133- const canonicalAddrExists = addrs . some (
134- ( addr ) => canonicalAddr . host === addr . host && canonicalAddr . path === addr . path
135- )
136-
137- if ( ! canonicalAddrExists ) {
138- throw new Error ( 'The canonical address must exist within the address list' )
139- }
140-
141- if ( supportedLocales . length === 0 ) {
142- throw new Error ( 'A binding must have at least one locale' )
143- }
144-
145- const defaultLocaleExists = supportedLocales . some ( ( locale ) => defaultLocale === locale )
116+ public createBinding = ( options : OptionsCreateBinding , config ?: RequestConfig ) => {
117+ assertBindingInput ( options )
146118
147- if ( ! defaultLocaleExists ) {
148- throw new Error ( 'The default locale must exist within the supported locales' )
149- }
119+ const metric = 'lm-create-binding'
120+ const { tenant , adminUserAuthToken , defaultLocale , supportedLocales , salesChannelId , addrs , canonicalAddr } =
121+ options
150122
151123 const bindingObj : APIBindingCreate = {
152124 SiteName : tenant ,
@@ -194,8 +166,11 @@ export class LicenseManager extends JanusClient {
194166 } )
195167 }
196168
197- public updateBinding = (
198- {
169+ public updateBinding = ( options : OptionsUpdateBinding , config ?: RequestConfig ) => {
170+ assertBindingInput ( options )
171+
172+ const metric = 'lm-update-binding'
173+ const {
199174 tenant,
200175 adminUserAuthToken,
201176 bindingId,
@@ -204,32 +179,7 @@ export class LicenseManager extends JanusClient {
204179 salesChannelId,
205180 addrs,
206181 canonicalAddr,
207- } : OptionsUpdateBinding ,
208- config ?: RequestConfig
209- ) => {
210- const metric = 'lm-update-binding'
211-
212- if ( addrs . length === 0 ) {
213- throw new Error ( 'A binding must have at least one address' )
214- }
215-
216- const canonicalAddrExists = addrs . some (
217- ( addr ) => canonicalAddr . host === addr . host && canonicalAddr . path === addr . path
218- )
219-
220- if ( ! canonicalAddrExists ) {
221- throw new Error ( 'The canonical address must exist within the address list' )
222- }
223-
224- if ( supportedLocales . length === 0 ) {
225- throw new Error ( 'A binding must have at least one locale' )
226- }
227-
228- const defaultLocaleExists = supportedLocales . some ( ( locale ) => defaultLocale === locale )
229-
230- if ( ! defaultLocaleExists ) {
231- throw new Error ( 'The default locale must exist within the supported locales' )
232- }
182+ } = options
233183
234184 const bindingObj : APIBindingUpdate = {
235185 Id : bindingId ,
0 commit comments