fansunited-sdk-esm 1.20.1 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Core/Configurator/Enums/ErrorHandlingModeEnum.d.ts +4 -0
- package/Core/Configurator/Enums/ValidationMessageEnum.d.ts +2 -0
- package/Core/Configurator/Models/ConfigValidationModel.d.ts +1 -0
- package/Core/Configurator/Models/SDKConfiguraitonModel.d.ts +2 -1
- package/Core/Configurator/Types/ConfiguratorTypes.d.ts +1 -0
- package/Core/Configurator/Validators/ErrorHandlingModeValidator.d.ts +8 -0
- package/Core/Exception/ErrorCodes.d.ts +2 -1
- package/Core/Exception/ErrorStatuses.d.ts +3 -1
- package/Core/Exception/StandardFansUnitedException.d.ts +12 -0
- package/Core/Global/Constants/Tests/SDKConfigurationsTesting.d.ts +4 -0
- package/Core/Global/LocalStorage.d.ts +11 -3
- package/Core/Global/Messages/Messages.d.ts +3 -1
- package/Core/Https/ActivityHttps.d.ts +0 -1
- package/Core/Https/ClientHttps.d.ts +3 -1
- package/Core/Https/FootballHttps.d.ts +0 -2
- package/Core/Https/Https.d.ts +11 -1
- package/Core/Https/IdMappingHttps.d.ts +0 -1
- package/Core/Https/LoyaltyHttps.d.ts +1 -1
- package/Core/Https/PredictorHttps.d.ts +0 -1
- package/Core/Https/ProfileHttps.d.ts +0 -1
- package/Core/Namespaces/Loyalty/Facade/LoyaltyFacade.d.ts +1 -0
- package/Core/Namespaces/Loyalty/Validator/LoyaltyValidator.d.ts +2 -1
- package/Core/Namespaces/MatchQuiz/Facade/MatchQuizFacade.d.ts +1 -0
- package/Core/Namespaces/Predictor/Facade/PredictorFacade.d.ts +1 -0
- package/Core/Namespaces/Predictor/Validator/PredictorValidator.d.ts +3 -0
- package/Core/Namespaces/TopX/Facade/TopXFacade.d.ts +1 -0
- package/README.md +1 -0
- package/index.js +18 -18
- package/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ export declare enum ValidationMessageEnum {
|
|
|
7
7
|
ID_SCHEMA_INVALID = "This idSchema value is not supported, the default one will be set which is: native",
|
|
8
8
|
ENVIRONMENT_MISSING = "If no environment is passed the default one will be set which is: prod",
|
|
9
9
|
ENVIRONMENT_INVALID = "This environment value is not supported, the default one will be set which is: prod",
|
|
10
|
+
ERROR_HANDLING_MODE_MISSING = "If no errorHandlingMode is passed the default one will be set which is: default",
|
|
11
|
+
ERROR_HANDLING_MODE_INVALID = "This errorHandlingMode value is not supported, the default one will be set which is: default",
|
|
10
12
|
AUTH_PROVIDER_CONFIG_PROP_MISSING = "The following property is missing from the authProvider object:",
|
|
11
13
|
AUTH_PROVIDER_CONFIG_INVALID_PROP = "You have passed a property which is not supported for the authentication provider:",
|
|
12
14
|
AUTH_PROVIDER_CONFIG_MISSING = "The field authProvider must be provided to use this SDK",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvironmentType, IdSchemaType, LangType } from "../Types/ConfiguratorTypes";
|
|
1
|
+
import { EnvironmentType, ErrorHandlingModeType, IdSchemaType, LangType } from "../Types/ConfiguratorTypes";
|
|
2
2
|
import FansUnitedAuthInterface from "./FansUnitedAuthInterface";
|
|
3
3
|
export default class SDKConfigurationModel {
|
|
4
4
|
apiKey: string;
|
|
@@ -6,5 +6,6 @@ export default class SDKConfigurationModel {
|
|
|
6
6
|
environment?: EnvironmentType;
|
|
7
7
|
idSchema?: IdSchemaType;
|
|
8
8
|
lang?: LangType;
|
|
9
|
+
errorHandlingMode?: ErrorHandlingModeType;
|
|
9
10
|
authProvider: FansUnitedAuthInterface;
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare type LangType = 'bg' | 'en' | 'ro';
|
|
2
2
|
export declare type IdSchemaType = 'native' | 'enetpulse' | 'sportal365' | 'sportradar';
|
|
3
3
|
export declare type EnvironmentType = 'dev' | 'prod' | 'staging';
|
|
4
|
+
export declare type ErrorHandlingModeType = 'default' | 'standard';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import SDKConfigurationModel from "../Models/SDKConfiguraitonModel";
|
|
2
|
+
import ValidationItemModel from "../Models/ValidationItemModel";
|
|
3
|
+
import IValidator from "./IValidator";
|
|
4
|
+
export default class ErrorHandlingModeValidator implements IValidator {
|
|
5
|
+
validate: (config: SDKConfigurationModel) => ValidationItemModel;
|
|
6
|
+
private validateField;
|
|
7
|
+
private generateMessage;
|
|
8
|
+
}
|
|
@@ -4,5 +4,7 @@ export declare enum ErrorStatuses {
|
|
|
4
4
|
INVALID_MARKET = "INVALID_MARKET",
|
|
5
5
|
INVALID_FIELD = "INVALID_FIELD",
|
|
6
6
|
INVALID_TYPE = "INVALID_TYPE",
|
|
7
|
-
EXCEEDED_LENGTH = "EXCEEDED_LENGTH"
|
|
7
|
+
EXCEEDED_LENGTH = "EXCEEDED_LENGTH",
|
|
8
|
+
INVALID_TOKEN = "invalid_token",
|
|
9
|
+
UNAUTHORIZED = "unauthorized"
|
|
8
10
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface FansUnitedException {
|
|
2
|
+
error: {
|
|
3
|
+
code: number;
|
|
4
|
+
status: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export default class StandardFansUnitedException {
|
|
9
|
+
response: FansUnitedException;
|
|
10
|
+
constructor(code: number, status: string, message: string);
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -4,6 +4,7 @@ export declare const SDK_CONFIG_NATIVE: {
|
|
|
4
4
|
idSchema: string;
|
|
5
5
|
clientId: string;
|
|
6
6
|
lang: string;
|
|
7
|
+
errorHandlingMode: string;
|
|
7
8
|
authProvider: {
|
|
8
9
|
getIdToken: () => void;
|
|
9
10
|
};
|
|
@@ -14,6 +15,7 @@ export declare const SDK_CONFIG_ENETPULSE: {
|
|
|
14
15
|
idSchema: string;
|
|
15
16
|
clientId: string;
|
|
16
17
|
lang: string;
|
|
18
|
+
errorHandlingMode: string;
|
|
17
19
|
authProvider: {
|
|
18
20
|
getIdToken: () => void;
|
|
19
21
|
};
|
|
@@ -24,6 +26,7 @@ export declare const SDK_CONFIG_SPORTAL365: {
|
|
|
24
26
|
idSchema: string;
|
|
25
27
|
clientId: string;
|
|
26
28
|
lang: string;
|
|
29
|
+
errorHandlingMode: string;
|
|
27
30
|
authProvider: {
|
|
28
31
|
getIdToken: () => void;
|
|
29
32
|
};
|
|
@@ -34,6 +37,7 @@ export declare const SDK_CONFIG_SPORTRADAR: {
|
|
|
34
37
|
idSchema: string;
|
|
35
38
|
clientId: string;
|
|
36
39
|
lang: string;
|
|
40
|
+
errorHandlingMode: string;
|
|
37
41
|
authProvider: {
|
|
38
42
|
getIdToken: () => void;
|
|
39
43
|
};
|
|
@@ -5,11 +5,12 @@ import ProfileCountryModel from "../Namespaces/Profile/Models/ProfileCountryMode
|
|
|
5
5
|
import CompetitionBasicModel from "../Namespaces/Football/Models/Competition/CompetitionBasicModel";
|
|
6
6
|
import CompetitionFilters from "../Namespaces/Football/Models/Competition/CompetitionFilters";
|
|
7
7
|
import ProfileStatsModel from "../Namespaces/Profile/Models/Stats/ProfileStatsModel";
|
|
8
|
-
export declare type ExparationType = "profile" | "statistics" | "badges";
|
|
8
|
+
export declare type ExparationType = "profile" | "statistics" | "badges" | "features";
|
|
9
9
|
export default class LocalStorage {
|
|
10
10
|
private idSchema;
|
|
11
|
-
readonly
|
|
11
|
+
readonly expirationProfileTimeout: number;
|
|
12
12
|
readonly expirationBadgesTimeout: number;
|
|
13
|
+
readonly expirationClientFeaturesTimeout: number;
|
|
13
14
|
constructor(configuration: SDKConfigurationModel);
|
|
14
15
|
clearData: () => void;
|
|
15
16
|
getEntityById: (type?: string, id?: string) => any;
|
|
@@ -37,7 +38,11 @@ export default class LocalStorage {
|
|
|
37
38
|
getCompetitions: (filters?: CompetitionFilters) => any;
|
|
38
39
|
setCompetitions: (competitions: CompetitionBasicModel[]) => void;
|
|
39
40
|
getCompetitionsLength: () => number;
|
|
40
|
-
|
|
41
|
+
getClientFeatures: () => any;
|
|
42
|
+
setClientFeatures: (features: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}) => void;
|
|
45
|
+
getExpiration: (namespace: string, type: ExparationType) => number;
|
|
41
46
|
/**
|
|
42
47
|
* The purpose of this method is to avoid the posibility of having same competitions store in Local Storage.
|
|
43
48
|
* @param competitions Cached competitions.
|
|
@@ -46,5 +51,8 @@ export default class LocalStorage {
|
|
|
46
51
|
private makeCompetitionsUnique;
|
|
47
52
|
private getData;
|
|
48
53
|
private setData;
|
|
54
|
+
/**
|
|
55
|
+
* Guarantee that the new local storage schema is set
|
|
56
|
+
*/
|
|
49
57
|
private initialNewSchema;
|
|
50
58
|
}
|
|
@@ -5,7 +5,9 @@ export declare enum ErrorMessages {
|
|
|
5
5
|
INVALID_PLAYER_ID = "Player id is invalid!",
|
|
6
6
|
QUERY_PARAM_MATCH_IDS_EXCEEDED = "Maximum matchIds in PredictionFilters should be 10 or less.",
|
|
7
7
|
QUERY_PARAM_FILTERS_LIMIT_EXCEEDED = "Maximum limit for filtering games is 50 or less.",
|
|
8
|
-
INVALID_PREDICTION_FIELD = "Prediction field is invalid. For more information please visit our documentation"
|
|
8
|
+
INVALID_PREDICTION_FIELD = "Prediction field is invalid. For more information please visit our documentation",
|
|
9
|
+
INVALID_TOKEN = "Invalid JWT token is provided",
|
|
10
|
+
EXPIRED_TOKEN = "The provided JWT token is expired"
|
|
9
11
|
}
|
|
10
12
|
export declare const WarningMessages: {
|
|
11
13
|
UNEXPECTED_STATUS_PROP: string;
|
|
@@ -7,7 +7,6 @@ import ProfileStatsModel from "../Namespaces/Profile/Models/Stats/ProfileStatsMo
|
|
|
7
7
|
import Https from "./Https";
|
|
8
8
|
export default class ActivityHttps extends Https {
|
|
9
9
|
private activityRemapper;
|
|
10
|
-
private apiSignInUrl;
|
|
11
10
|
constructor(config: SDKConfiguraitonModel);
|
|
12
11
|
createActivity: (requestBody: CreateActivityRequestBody) => Promise<ActivityResponseBody>;
|
|
13
12
|
deleteActivity: (activityId: string) => Promise<boolean>;
|
|
@@ -8,8 +8,10 @@ export declare enum FeatureConfigType {
|
|
|
8
8
|
LOYALTY = "loyalty"
|
|
9
9
|
}
|
|
10
10
|
export default class ClientHttps extends Https {
|
|
11
|
-
private apiSignInUrl;
|
|
12
11
|
private featureConfigRemapper;
|
|
12
|
+
private localStorage;
|
|
13
13
|
constructor(config: SDKConfigurationModel);
|
|
14
14
|
getConfig: (feature: FeatureConfigType) => Promise<FeaturesConfigModels>;
|
|
15
|
+
private getCachedFeatures;
|
|
16
|
+
private getLocalStorageData;
|
|
15
17
|
}
|
|
@@ -16,8 +16,6 @@ import SearchModel from "../Namespaces/Football/Models/Search/SearchModel";
|
|
|
16
16
|
import FootballPaginationModel from "../Namespaces/Football/Models/Pagination/FootballPaginationModel";
|
|
17
17
|
import Https from "./Https";
|
|
18
18
|
export default class FootballHttps extends Https {
|
|
19
|
-
private apiSignInUrl;
|
|
20
|
-
private clientId;
|
|
21
19
|
private limitIds;
|
|
22
20
|
private countryRemapper;
|
|
23
21
|
private competitionBasicRemapper;
|
package/Core/Https/Https.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
1
|
+
import { AxiosError, AxiosInstance } from "axios";
|
|
2
2
|
import SDKConfigurationModel from "../Configurator/Models/SDKConfiguraitonModel";
|
|
3
|
+
import StandardFansUnitedException from "../Exception/StandardFansUnitedException";
|
|
3
4
|
export default class Https {
|
|
5
|
+
protected apiSignInUrl: string;
|
|
4
6
|
protected instanceAuth: AxiosInstance;
|
|
5
7
|
protected instance: AxiosInstance;
|
|
8
|
+
private errorHandlingMode;
|
|
6
9
|
constructor(configuration: SDKConfigurationModel, baseUrl: string);
|
|
10
|
+
/**
|
|
11
|
+
* Returns the axios error param when handling mode is set to default
|
|
12
|
+
* Otherwise returns a new StandardFansUnitedException from API's returned exception body.
|
|
13
|
+
* @param e Axios error. Catched from throwed CRUD operations.
|
|
14
|
+
* @returns Axios error or StandardFansUnitedException
|
|
15
|
+
*/
|
|
16
|
+
protected transformAxiosErrorToFansUnitedException: (e: AxiosError) => AxiosError | StandardFansUnitedException;
|
|
7
17
|
}
|
|
@@ -2,7 +2,6 @@ import { AxiosResponse } from "axios";
|
|
|
2
2
|
import SDKConfiguraitonModel from "../Configurator/Models/SDKConfiguraitonModel";
|
|
3
3
|
import Https from "./Https";
|
|
4
4
|
export default class IdMappingHttps extends Https {
|
|
5
|
-
private apiSignInUrl;
|
|
6
5
|
constructor(config: SDKConfiguraitonModel);
|
|
7
6
|
getEntityById: (type: string, id: string) => AxiosResponse<any>;
|
|
8
7
|
getEntityByIdAndSchema: (type: string, id: string, schemaId: string) => AxiosResponse<any>;
|
|
@@ -7,13 +7,13 @@ import TemplateModel from "../Namespaces/Loyalty/Models/Template/TemplateModel";
|
|
|
7
7
|
import HighestSuccessRateModel from "../Namespaces/Loyalty/Models/HighestSuccessRate/HighestSuccessRateModel";
|
|
8
8
|
import Https from "./Https";
|
|
9
9
|
export default class LoyaltyHttps extends Https {
|
|
10
|
-
private apiSignInUrl;
|
|
11
10
|
private templateRemapper;
|
|
12
11
|
private leaderboardRemapper;
|
|
13
12
|
private rankingsRemapper;
|
|
14
13
|
private highestSuccessRateRemapper;
|
|
15
14
|
constructor(config: SDKConfiguraitonModel);
|
|
16
15
|
getTemplates: (disableCache: boolean, isPaginated: boolean) => Promise<PaginationModel | TemplateModel[]>;
|
|
16
|
+
getTemplateById: (templateId: string, disableCache: boolean) => Promise<TemplateModel>;
|
|
17
17
|
getLeaderboard: (templateId: string, disableCache: boolean, filters: LoyaltyFilters) => Promise<PaginationModel>;
|
|
18
18
|
getLeaderboardForGame: (gameId: string, disableCache: boolean, filters: LoyaltyFilters) => Promise<PaginationModel>;
|
|
19
19
|
getUserRankings: (userId: string, filters: RankingsFilters, disableCache: boolean) => Promise<FootballPaginationModel>;
|
|
@@ -12,7 +12,6 @@ import MainFiltersBQ from "../Global/Models/Filters/MainFiltersBQ";
|
|
|
12
12
|
import Https from "./Https";
|
|
13
13
|
import ContestWinners from "../Namespaces/TopX/Models/Games/Winners/ContestWinners";
|
|
14
14
|
export default class PredictorHttps extends Https {
|
|
15
|
-
private apiSignInUrl;
|
|
16
15
|
private predictionRemapper;
|
|
17
16
|
private matchSummaryRemapper;
|
|
18
17
|
private gamesRemapper;
|
|
@@ -6,7 +6,6 @@ import FollowFilters from "../Namespaces/Profile/Models/FollowFilters";
|
|
|
6
6
|
import PaginationModel from "../Global/Models/Pagination/PaginationModel";
|
|
7
7
|
import Https from "./Https";
|
|
8
8
|
export default class ProfileHttps extends Https {
|
|
9
|
-
private apiSignInUrl;
|
|
10
9
|
private profileRemapper;
|
|
11
10
|
private followingRemapper;
|
|
12
11
|
private followersRemapper;
|
|
@@ -23,6 +23,7 @@ export default class LoyaltyFacade {
|
|
|
23
23
|
private topXFacade;
|
|
24
24
|
private matchQuizFacade;
|
|
25
25
|
private predictorHttps;
|
|
26
|
+
private errorHandlingMode;
|
|
26
27
|
constructor(config: SDKConfigurationModel, clientHttps: ClientHttps, loyaltyHttps: LoyaltyHttps, profileHttps: ProfileHttps, localStorage: LocalStorage);
|
|
27
28
|
getConfig: () => Promise<FeaturesConfigModels>;
|
|
28
29
|
getClientBadges: () => Promise<ClientBadges>;
|
|
@@ -16,6 +16,7 @@ export default class MatchQuizFacade {
|
|
|
16
16
|
private idMapping;
|
|
17
17
|
private clientHttps;
|
|
18
18
|
private predictorValidator;
|
|
19
|
+
private errorHandlingMode;
|
|
19
20
|
constructor(config: SDKConfigurationModel);
|
|
20
21
|
getConfig: () => Promise<FeaturesConfigModels>;
|
|
21
22
|
play: (matchQuizPrediction: PredictionRequestModel) => Promise<PredictionResponseModel>;
|
|
@@ -14,6 +14,7 @@ export default class PredictorFacade {
|
|
|
14
14
|
readonly idMapping: IdMappingService;
|
|
15
15
|
readonly predictorService: PredictorService;
|
|
16
16
|
private predictorValidator;
|
|
17
|
+
private errorHandlingMode;
|
|
17
18
|
constructor(config: SDKConfigurationModel, predictorHttps: PredictorHttps, clientHttps: ClientHttps, idMapping: IdMappingService);
|
|
18
19
|
/**
|
|
19
20
|
* Exposing PredictorService for two operations:
|
|
@@ -13,7 +13,10 @@ import RedCardFixtureModel from "../Models/Fixtures/Markets/RedCardFixtureModel"
|
|
|
13
13
|
import PredictionRequestModel from "../Models/Predictions/PredictionRequestModel";
|
|
14
14
|
import { TypeGames } from "../../TopX/types/types";
|
|
15
15
|
import TopXPredictionRequestModel from "../../TopX/Models/Prediction/TopXPredictionRequestModel";
|
|
16
|
+
import { ErrorHandlingModeType } from "../../../Configurator/Types/ConfiguratorTypes";
|
|
16
17
|
export default class PredictorValidator {
|
|
18
|
+
private errorHandlingMode;
|
|
19
|
+
constructor(errorHandlingMode: ErrorHandlingModeType);
|
|
17
20
|
/**
|
|
18
21
|
* Validate all field for game prediction (Top X and Match Quiz). The following cases are covered:
|
|
19
22
|
* 1. Unsupported field is provided (Top X and Match Quiz)
|
|
@@ -19,6 +19,7 @@ export default class TopXFacade {
|
|
|
19
19
|
readonly predictorService: PredictorService;
|
|
20
20
|
readonly predictorValidator: PredictorValidator;
|
|
21
21
|
private clientHttps;
|
|
22
|
+
private errorHandlingMode;
|
|
22
23
|
constructor(config: SDKConfigurationModel, idMapping: IdMappingService);
|
|
23
24
|
getConfig: () => Promise<FeaturesConfigModels>;
|
|
24
25
|
getGames: (filters?: GamesFilters, disableCache?: boolean) => Promise<PaginationModel>;
|
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ const fansUnitedSdk = FansUnitedSDK({
|
|
|
46
46
|
"clientId": "your-client-id-here",
|
|
47
47
|
"lang": "BG|EN|RO", // default: EN
|
|
48
48
|
"idSchema": "native|enetpulse|sportradar|sportal365", // default: native
|
|
49
|
+
"errorHandlingMode": "default|standard", // default: default
|
|
49
50
|
"authProvider": new myTokenProvider()
|
|
50
51
|
});
|
|
51
52
|
```
|