( config: ProConfig, pluginVersion: string, saveUpdatedConfigFunc: () => Promise<any> | undefined )
| 192 | }; |
| 193 | |
| 194 | export const getAndSaveProEmail = async ( |
| 195 | config: ProConfig, |
| 196 | pluginVersion: string, |
| 197 | saveUpdatedConfigFunc: () => Promise<any> | undefined |
| 198 | ) => { |
| 199 | const access = await getAccessToken(config, saveUpdatedConfigFunc); |
| 200 | |
| 201 | const resp1 = await fetch(`${site}/api/v1/profile/list`, { |
| 202 | method: "GET", |
| 203 | headers: { |
| 204 | Authorization: `Bearer ${access}`, |
| 205 | "REMOTELYSAVE-API-Plugin-Ver": pluginVersion, |
| 206 | }, |
| 207 | }); |
| 208 | const rsp2: { |
| 209 | email: string; |
| 210 | } = await resp1.json(); |
| 211 | |
| 212 | config.email = rsp2.email; |
| 213 | await saveUpdatedConfigFunc?.(); |
| 214 | return rsp2; |
| 215 | }; |
| 216 | |
| 217 | /** |
| 218 | * If the check doesn't pass, the function should throw the error |
no test coverage detected