From b0221c0a37b010545608bd8255a54e55156263c9 Mon Sep 17 00:00:00 2001 From: sahani-deriv <125638269+sahani-deriv@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:04:19 +0800 Subject: [PATCH] feat: add freshchat api changes (#347) --- .../service_token_response_result.dart | 194 ++++++++---------- .../generated/service_token_send.dart | 12 +- 2 files changed, 101 insertions(+), 105 deletions(-) diff --git a/lib/api/response/service_token_response_result.dart b/lib/api/response/service_token_response_result.dart index 3c75573cb6..83f5bc8865 100644 --- a/lib/api/response/service_token_response_result.dart +++ b/lib/api/response/service_token_response_result.dart @@ -92,7 +92,6 @@ class ServiceTokenResponse extends ServiceTokenResponseModel { serviceToken: serviceToken ?? this.serviceToken, ); } - /// Service token model class. abstract class ServiceTokenModel { /// Initializes Service token model class . @@ -100,10 +99,10 @@ abstract class ServiceTokenModel { this.banxa, this.ctrader, this.dxtrade, + this.freshworksAuthJwt, + this.freshworksUserJwt, this.onfido, - this.pandats, this.sendbird, - this.wyre, }); /// Banxa order data. @@ -115,17 +114,17 @@ abstract class ServiceTokenModel { /// Deriv X data. final Dxtrade? dxtrade; + /// Freshchat data. + final FreshworksAuthJwt? freshworksAuthJwt; + + /// Freshchat data. + final FreshworksUserJwt? freshworksUserJwt; + /// Onfido data. final Onfido? onfido; - /// Deriv EZ data. - final Pandats? pandats; - /// Sendbird data. final Sendbird? sendbird; - - /// Wyre reservation data. - final Wyre? wyre; } /// Service token class. @@ -135,10 +134,10 @@ class ServiceToken extends ServiceTokenModel { super.banxa, super.ctrader, super.dxtrade, + super.freshworksAuthJwt, + super.freshworksUserJwt, super.onfido, - super.pandats, super.sendbird, - super.wyre, }); /// Creates an instance from JSON. @@ -148,13 +147,16 @@ class ServiceToken extends ServiceTokenModel { json['ctrader'] == null ? null : Ctrader.fromJson(json['ctrader']), dxtrade: json['dxtrade'] == null ? null : Dxtrade.fromJson(json['dxtrade']), + freshworksAuthJwt: json['freshworks_auth_jwt'] == null + ? null + : FreshworksAuthJwt.fromJson(json['freshworks_auth_jwt']), + freshworksUserJwt: json['freshworks_user_jwt'] == null + ? null + : FreshworksUserJwt.fromJson(json['freshworks_user_jwt']), onfido: json['onfido'] == null ? null : Onfido.fromJson(json['onfido']), - pandats: - json['pandats'] == null ? null : Pandats.fromJson(json['pandats']), sendbird: json['sendbird'] == null ? null : Sendbird.fromJson(json['sendbird']), - wyre: json['wyre'] == null ? null : Wyre.fromJson(json['wyre']), ); /// Converts an instance to JSON. @@ -170,18 +172,18 @@ class ServiceToken extends ServiceTokenModel { if (dxtrade != null) { resultMap['dxtrade'] = dxtrade!.toJson(); } + if (freshworksAuthJwt != null) { + resultMap['freshworks_auth_jwt'] = freshworksAuthJwt!.toJson(); + } + if (freshworksUserJwt != null) { + resultMap['freshworks_user_jwt'] = freshworksUserJwt!.toJson(); + } if (onfido != null) { resultMap['onfido'] = onfido!.toJson(); } - if (pandats != null) { - resultMap['pandats'] = pandats!.toJson(); - } if (sendbird != null) { resultMap['sendbird'] = sendbird!.toJson(); } - if (wyre != null) { - resultMap['wyre'] = wyre!.toJson(); - } return resultMap; } @@ -191,22 +193,21 @@ class ServiceToken extends ServiceTokenModel { Banxa? banxa, Ctrader? ctrader, Dxtrade? dxtrade, + FreshworksAuthJwt? freshworksAuthJwt, + FreshworksUserJwt? freshworksUserJwt, Onfido? onfido, - Pandats? pandats, Sendbird? sendbird, - Wyre? wyre, }) => ServiceToken( banxa: banxa ?? this.banxa, ctrader: ctrader ?? this.ctrader, dxtrade: dxtrade ?? this.dxtrade, + freshworksAuthJwt: freshworksAuthJwt ?? this.freshworksAuthJwt, + freshworksUserJwt: freshworksUserJwt ?? this.freshworksUserJwt, onfido: onfido ?? this.onfido, - pandats: pandats ?? this.pandats, sendbird: sendbird ?? this.sendbird, - wyre: wyre ?? this.wyre, ); } - /// Banxa model class. abstract class BanxaModel { /// Initializes Banxa model class . @@ -265,7 +266,6 @@ class Banxa extends BanxaModel { urlIframe: urlIframe ?? this.urlIframe, ); } - /// Ctrader model class. abstract class CtraderModel { /// Initializes Ctrader model class . @@ -306,7 +306,6 @@ class Ctrader extends CtraderModel { token: token ?? this.token, ); } - /// Dxtrade model class. abstract class DxtradeModel { /// Initializes Dxtrade model class . @@ -347,27 +346,27 @@ class Dxtrade extends DxtradeModel { token: token ?? this.token, ); } - -/// Onfido model class. -abstract class OnfidoModel { - /// Initializes Onfido model class . - const OnfidoModel({ +/// Freshworks auth jwt model class. +abstract class FreshworksAuthJwtModel { + /// Initializes Freshworks auth jwt model class . + const FreshworksAuthJwtModel({ this.token, }); - /// Onfido token. + /// Freshchat auth JWT token. final String? token; } -/// Onfido class. -class Onfido extends OnfidoModel { - /// Initializes Onfido class. - const Onfido({ +/// Freshworks auth jwt class. +class FreshworksAuthJwt extends FreshworksAuthJwtModel { + /// Initializes Freshworks auth jwt class. + const FreshworksAuthJwt({ super.token, }); /// Creates an instance from JSON. - factory Onfido.fromJson(Map json) => Onfido( + factory FreshworksAuthJwt.fromJson(Map json) => + FreshworksAuthJwt( token: json['token'], ); @@ -381,34 +380,34 @@ class Onfido extends OnfidoModel { } /// Creates a copy of instance with given parameters. - Onfido copyWith({ + FreshworksAuthJwt copyWith({ String? token, }) => - Onfido( + FreshworksAuthJwt( token: token ?? this.token, ); } - -/// Pandats model class. -abstract class PandatsModel { - /// Initializes Pandats model class . - const PandatsModel({ +/// Freshworks user jwt model class. +abstract class FreshworksUserJwtModel { + /// Initializes Freshworks user jwt model class . + const FreshworksUserJwtModel({ this.token, }); - /// Deriv EZ SSO token + /// Freshchat user JWT token. final String? token; } -/// Pandats class. -class Pandats extends PandatsModel { - /// Initializes Pandats class. - const Pandats({ +/// Freshworks user jwt class. +class FreshworksUserJwt extends FreshworksUserJwtModel { + /// Initializes Freshworks user jwt class. + const FreshworksUserJwt({ super.token, }); /// Creates an instance from JSON. - factory Pandats.fromJson(Map json) => Pandats( + factory FreshworksUserJwt.fromJson(Map json) => + FreshworksUserJwt( token: json['token'], ); @@ -422,14 +421,53 @@ class Pandats extends PandatsModel { } /// Creates a copy of instance with given parameters. - Pandats copyWith({ + FreshworksUserJwt copyWith({ String? token, }) => - Pandats( + FreshworksUserJwt( token: token ?? this.token, ); } +/// Onfido model class. +abstract class OnfidoModel { + /// Initializes Onfido model class . + const OnfidoModel({ + this.token, + }); + + /// Onfido token. + final String? token; +} + +/// Onfido class. +class Onfido extends OnfidoModel { + /// Initializes Onfido class. + const Onfido({ + super.token, + }); + + /// Creates an instance from JSON. + factory Onfido.fromJson(Map json) => Onfido( + token: json['token'], + ); + + /// Converts an instance to JSON. + Map toJson() { + final Map resultMap = {}; + + resultMap['token'] = token; + + return resultMap; + } + /// Creates a copy of instance with given parameters. + Onfido copyWith({ + String? token, + }) => + Onfido( + token: token ?? this.token, + ); +} /// Sendbird model class. abstract class SendbirdModel { /// Initializes Sendbird model class . @@ -488,53 +526,3 @@ class Sendbird extends SendbirdModel { token: token ?? this.token, ); } - -/// Wyre model class. -abstract class WyreModel { - /// Initializes Wyre model class . - const WyreModel({ - this.token, - this.url, - }); - - /// Wyre reservation id token - final String? token; - - /// Wyre reservation URL - final String? url; -} - -/// Wyre class. -class Wyre extends WyreModel { - /// Initializes Wyre class. - const Wyre({ - super.token, - super.url, - }); - - /// Creates an instance from JSON. - factory Wyre.fromJson(Map json) => Wyre( - token: json['token'], - url: json['url'], - ); - - /// Converts an instance to JSON. - Map toJson() { - final Map resultMap = {}; - - resultMap['token'] = token; - resultMap['url'] = url; - - return resultMap; - } - - /// Creates a copy of instance with given parameters. - Wyre copyWith({ - String? token, - String? url, - }) => - Wyre( - token: token ?? this.token, - url: url ?? this.url, - ); -} diff --git a/lib/basic_api/generated/service_token_send.dart b/lib/basic_api/generated/service_token_send.dart index 3e7945c98b..01aa672cee 100644 --- a/lib/basic_api/generated/service_token_send.dart +++ b/lib/basic_api/generated/service_token_send.dart @@ -9,6 +9,7 @@ class ServiceTokenRequest extends Request { /// Initialize ServiceTokenRequest. const ServiceTokenRequest({ this.country, + this.extraFields, this.loginid, this.referrer, required this.server, @@ -23,6 +24,7 @@ class ServiceTokenRequest extends Request { factory ServiceTokenRequest.fromJson(Map json) => ServiceTokenRequest( country: json['country'] as String?, + extraFields: json['extra_fields'] as Map?, loginid: json['loginid'] as String?, referrer: json['referrer'] as String?, server: json['server'] as String?, @@ -36,13 +38,16 @@ class ServiceTokenRequest extends Request { /// [Optional] The 2-letter country code. final String? country; - /// [Optional] The login id of the user. If left unspecified, it defaults to the initial authorized token's login id. + /// [Optional] Valid fields depend on the service type. + final Map? extraFields; + + /// [Optional] The login id of the user. Mandatory when multiple tokens were provided during authorize. final String? loginid; /// [Optional] The URL of the web page where the Web SDK will be used. final String? referrer; - /// Server (dxtrade and derivez). + /// Server (dxtrade). final String? server; /// The service(s) to retrieve token(s) for. @@ -55,6 +60,7 @@ class ServiceTokenRequest extends Request { @override Map toJson() => { 'country': country, + 'extra_fields': extraFields, 'loginid': loginid, 'referrer': referrer, 'server': server, @@ -72,6 +78,7 @@ class ServiceTokenRequest extends Request { @override ServiceTokenRequest copyWith({ String? country, + Map? extraFields, String? loginid, String? referrer, String? server, @@ -82,6 +89,7 @@ class ServiceTokenRequest extends Request { }) => ServiceTokenRequest( country: country ?? this.country, + extraFields: extraFields ?? this.extraFields, loginid: loginid ?? this.loginid, referrer: referrer ?? this.referrer, server: server ?? this.server,