@emergentmethods/asknews-typescript-sdk
Version:
Typescript SDK for AskNews API
74 lines (65 loc) • 2.35 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.19.10
* Contact: contact@emergentmethods.ai
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { ServiceAccountProfile } from './ServiceAccountProfile';
import {
instanceOfServiceAccountProfile,
ServiceAccountProfileFromJSON,
ServiceAccountProfileFromJSONTyped,
ServiceAccountProfileToJSON,
} from './ServiceAccountProfile';
import type { UserProfile } from './UserProfile';
import {
instanceOfUserProfile,
UserProfileFromJSON,
UserProfileFromJSONTyped,
UserProfileToJSON,
} from './UserProfile';
/**
* @type Profile
*
* @export
*/
export type Profile = { identityType: 'service_account' } & ServiceAccountProfile | { identityType: 'user' } & UserProfile;
export function ProfileFromJSON(json: any): Profile {
return ProfileFromJSONTyped(json, false);
}
export function ProfileFromJSONTyped(json: any, ignoreDiscriminator: boolean): Profile {
if (json == null) {
return json;
}
switch (json['identity_type']) {
case 'service_account':
return Object.assign({}, ServiceAccountProfileFromJSONTyped(json, true), { identityType: 'service_account' } as const);
case 'user':
return Object.assign({}, UserProfileFromJSONTyped(json, true), { identityType: 'user' } as const);
default:
throw new Error(`No variant of Profile exists with 'identityType=${json['identityType']}'`);
}
}
export function ProfileToJSON(json: any): any {
return ProfileToJSONTyped(json, false);
}
export function ProfileToJSONTyped(value?: Profile | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
switch (value['identityType']) {
case 'service_account':
return Object.assign({}, ServiceAccountProfileToJSON(value), { identityType: 'service_account' } as const);
case 'user':
return Object.assign({}, UserProfileToJSON(value), { identityType: 'user' } as const);
default:
throw new Error(`No variant of Profile exists with 'identityType=${value['identityType']}'`);
}
}