| 133 | } |
| 134 | |
| 135 | export class Functions implements IFunctions { |
| 136 | _native: FIRFunctions; |
| 137 | _app: FirebaseApp; |
| 138 | |
| 139 | constructor(app?: FirebaseApp) { |
| 140 | if (app?.native) { |
| 141 | if (defaultRegionOrCustomDomain) { |
| 142 | this._native = isRegion(defaultRegionOrCustomDomain) // Check whether a Region has been set |
| 143 | ? FIRFunctions.functionsForAppRegion(app.native, defaultRegionOrCustomDomain) // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functionsforapp:region: |
| 144 | : isCustomDomain(defaultRegionOrCustomDomain) // Check whether using a Custom Domain has been set |
| 145 | ? FIRFunctions.functionsForAppCustomDomain(app.native, defaultRegionOrCustomDomain) // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functionsforapp:customdomain: |
| 146 | : FIRFunctions.functionsForApp(app.native); // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functionsforapp: |
| 147 | } else { |
| 148 | this._native = FIRFunctions.functionsForApp(app.native); // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functionsforapp: |
| 149 | } |
| 150 | } else { |
| 151 | if (defaultFunctions) { |
| 152 | return defaultFunctions; |
| 153 | } |
| 154 | defaultFunctions = this; |
| 155 | if (defaultRegionOrCustomDomain) { |
| 156 | this._native = isRegion(defaultRegionOrCustomDomain) // Check whether a Region has been set |
| 157 | ? FIRFunctions.functionsForRegion(defaultRegionOrCustomDomain) // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functionsforregion: |
| 158 | : isCustomDomain(defaultRegionOrCustomDomain) // Check whether using a Custom Domain has been set |
| 159 | ? FIRFunctions.functionsForCustomDomain(defaultRegionOrCustomDomain) // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functionsforcustomdomain: |
| 160 | : FIRFunctions.functions(); // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functions |
| 161 | } else { |
| 162 | this._native = FIRFunctions.functions(); // @see https://firebase.google.com/docs/reference/ios/firebasefunctions/api/reference/Classes/FIRFunctions_+functions |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | httpsCallable(name: string, options?: HttpsCallableOptions): HttpsCallable { |
| 168 | const callable = this.native.HTTPSCallableWithName(name); |
| 169 | if (typeof options?.timeout === 'number') { |
| 170 | callable.timeoutInterval = options.timeout; |
| 171 | } |
| 172 | return (data: any) => { |
| 173 | return new Promise((resolve, reject) => { |
| 174 | if (data) { |
| 175 | callable.callWithObjectCompletion(serialize(data), (result, error) => { |
| 176 | if (error) { |
| 177 | reject(toHttpsError(error)); |
| 178 | } else { |
| 179 | resolve(deserialize(result.data)); |
| 180 | } |
| 181 | }); |
| 182 | } else { |
| 183 | callable.callWithCompletion((result, error) => { |
| 184 | if (error) { |
| 185 | reject(toHttpsError(error)); |
| 186 | } else { |
| 187 | resolve(deserialize(result.data)); |
| 188 | } |
| 189 | }); |
| 190 | } |
| 191 | }); |
| 192 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected