diff --git a/CHANGELOG.md b/CHANGELOG.md index 27fd0bb..055efaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ All notable changes to this project will be documented in this file. +## [0.17.0] - 2023-12-05 + +### Fixed +- [iOS] Issue with location of some SDK files in the Documents directory. The old location caused the SDK files to be visible in the shared documents directory if the host application file sharing was enabled. +- [iOS] Potential issue with native notification buttons when Simple Push campaign contained Rich Media (Single Media) or had a custom notification category identifier. + +### Added +- We added a new `Synerise.Content.generateDocument(slug:onSuccess:onError:)` method. It's analogous to `Synerise.Content.getDocument(slug:onSuccess:onError:)`. The old method is deprecated. The new method generates the document that is defined for the provided slug. +- We added a new `Synerise.Content.getRecommendationsV2(options:onSuccess:onError:)` method. It's analogous to `Synerise.Content.getRecommendations(options:onSuccess:onError:)`. The old method is deprecated. The new method gets recommendations that are defined for the options provided. +- We added a new `Synerise.Content.generateScreenView(feedSlug:onSuccess:onError:)` method. It's analogous to `Synerise.Content.getScreenView(onSuccess:onError:)`. The old method is deprecated. The new method generates a customer's highest-priority screen view campaign that is defined for the provided slug. +- We added models correlating with new methods: `ScreenView`, `Document`. + +### Changed +- `Synerise.Content.getDocument(slug:onSuccess:onError:)` is deprecated now. +- `Synerise.Content.getDocuments(apiQuery:onSuccess:onError:)` is deprecated now. +- `Synerise.Content.getRecommendations(options:onSuccess:onError:)` is deprecated now. +- `Synerise.Content.getScreenView(onSuccess:onError:)` is deprecated now. +- Update of native SDK's dependencies. + + ## [0.16.0] - 2023-10-30 ### Added diff --git a/README.md b/README.md index 3c5bcf9..d8fe268 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Synerise React Native SDK (react-native-synerise-sdk) (0.16.0) +# Synerise React Native SDK (react-native-synerise-sdk) (0.17.0) [![Platform](https://img.shields.io/badge/platform-ios%20%7C%20android-orange.svg)](https://github.com/synerise/react-native-synerise-sdk) [![Languages](https://img.shields.io/badge/language-TypeScript%20%7C%20Java%20%7C%20Objective--C-orange.svg)](https://github.com/synerise/react-native-synerise-sdk) diff --git a/android/build.gradle b/android/build.gradle index 0c0bf5b..b32789b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,8 +4,8 @@ ext.versions = [ 'minSdk' : 21, 'compileSdk' : 33, 'targetSdk' : 33, - 'versionCode': 30, - 'versionName': "0.16.0" + 'versionCode': 31, + 'versionName': "0.17.0" ] buildscript { @@ -57,7 +57,7 @@ repositories { dependencies { implementation 'com.facebook.react:react-native:+' implementation "com.squareup.okhttp3:logging-interceptor:4.9.1" - api 'com.synerise.sdk:synerise-mobile-sdk:5.11.0' + api 'com.synerise.sdk:synerise-mobile-sdk:5.12.0' } //apply from: 'publish.gradle' \ No newline at end of file diff --git a/android/src/main/java/com/synerise/sdk/react/RNContent.java b/android/src/main/java/com/synerise/sdk/react/RNContent.java index b652afe..fb51ab2 100644 --- a/android/src/main/java/com/synerise/sdk/react/RNContent.java +++ b/android/src/main/java/com/synerise/sdk/react/RNContent.java @@ -13,8 +13,10 @@ import com.synerise.sdk.content.model.DocumentsApiQuery; import com.synerise.sdk.content.model.DocumentsApiQueryType; import com.synerise.sdk.content.model.ScreenViewResponse; +import com.synerise.sdk.content.model.document.Document; import com.synerise.sdk.content.model.recommendation.RecommendationRequestBody; import com.synerise.sdk.content.model.recommendation.RecommendationResponse; +import com.synerise.sdk.content.model.screenview.ScreenView; import com.synerise.sdk.content.widgets.dataModel.Recommendation; import com.synerise.sdk.core.listeners.DataActionListener; import com.synerise.sdk.core.net.IDataApiCall; @@ -34,11 +36,13 @@ public class RNContent extends RNBaseModule { - IDataApiCall getDocumentApiCall; - IDataApiCall> getDocumentsApiCall; + private IDataApiCall getDocumentApiCall; + private IDataApiCall> getDocumentsApiCall; + private IDataApiCall generateDocumentApiCall; private final String ISO8601_FORMAT = "yyyy-MM-dd'T'kk:mm:ss.SSS'Z'"; private IDataApiCall getRecommendationsApiCall; private IDataApiCall getScreenViewApiCall; + private IDataApiCall generateScreenViewApiCall; private Gson gson = new Gson(); public RNContent(ReactApplicationContext reactApplicationContext) { @@ -185,6 +189,111 @@ public void onDataAction(ApiError apiError) { }); } + @ReactMethod + public void getRecommendationsV2(ReadableMap recommendationsOptions, Callback callback) { + String productId = recommendationsOptions.hasKey("productID") ? recommendationsOptions.getString("productID") : ""; + String slugName = recommendationsOptions.hasKey("slug") ? recommendationsOptions.getString("slug") : ""; + + if (getRecommendationsApiCall != null) getRecommendationsApiCall.cancel(); + + RecommendationRequestBody recommendationRequestBody = new RecommendationRequestBody(); + recommendationRequestBody.setProductId(productId); + + getRecommendationsApiCall = Content.getRecommendationsV2(slugName, recommendationRequestBody); + getRecommendationsApiCall.execute(new DataActionListener() { + @Override + public void onDataAction(RecommendationResponse responseBody) { + WritableMap recommendationMap = Arguments.createMap(); + + recommendationMap.putString("campaignHash", responseBody.getCampaignHash()); + recommendationMap.putString("campaignId", responseBody.getCampaignId()); + recommendationMap.putString("schema", responseBody.getSchema()); + recommendationMap.putString("slug", responseBody.getSlug()); + recommendationMap.putString("uuid", responseBody.getUuid()); + + recommendationMap.putArray("items", recommendationToWritableArray(responseBody.getRecommendations())); + executeSuccessCallbackResponse(callback, recommendationMap, null); + } + }, new DataActionListener() { + @Override + public void onDataAction(ApiError apiError) { + executeFailureCallbackResponse(callback, null, apiError); + } + }); + } + + @ReactMethod + public void generateDocument(String slug, Callback callback) { + if (generateDocumentApiCall != null) generateDocumentApiCall.cancel(); + + generateDocumentApiCall = Content.generateDocument(slug); + generateDocumentApiCall.execute(new DataActionListener() { + + @Override + public void onDataAction(Document document) { + WritableMap documentMap = Arguments.createMap(); + documentMap.putString("uuid", document.getUuid()); + documentMap.putString("slug", document.getSlug()); + documentMap.putString("schema", document.getSchema()); + try { + String jsonObject = gson.toJson(document); + WritableMap objectMap = convertJsonToMap(new JSONObject(jsonObject)); + documentMap.putMap("content", objectMap); + executeSuccessCallbackResponse(callback, documentMap, null); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, new DataActionListener() { + @Override + public void onDataAction(ApiError apiError) { + executeFailureCallbackResponse(callback, null, apiError); + } + }); + } + + @ReactMethod + public void generateScreenView(String feedSlug, Callback callback) { + if (generateScreenViewApiCall != null) generateScreenViewApiCall.cancel(); + generateScreenViewApiCall = Content.generateScreenView(feedSlug); + generateScreenViewApiCall.execute( + new DataActionListener() { + @Override + public void onDataAction(ScreenView data) { + WritableMap screenViewMap = Arguments.createMap(); + screenViewMap.putMap("audience", audienceNewScreenViewsToWritableMap(data.getAudience())); + screenViewMap.putString("identifier", data.getId()); + screenViewMap.putString("hash", data.getHash()); + screenViewMap.putString("path", data.getPath()); + screenViewMap.putString("name", data.getName()); + screenViewMap.putInt("priority", data.getPriority()); + screenViewMap.putMap("data", screenViewDataToWritableMap(data.getData())); + + try { + Date createdAtDate = new SimpleDateFormat(ISO8601_FORMAT, Locale.getDefault()).parse(data.getCreatedAt()); + Date updatedAtDate = new SimpleDateFormat(ISO8601_FORMAT, Locale.getDefault()).parse(data.getUpdatedAt()); + + if (createdAtDate != null) { + screenViewMap.putDouble("createdAt", createdAtDate.getTime()); + } + if (updatedAtDate != null) { + screenViewMap.putDouble("updatedAt", updatedAtDate.getTime()); + } + } catch (ParseException e) { + e.printStackTrace(); + } + + executeSuccessCallbackResponse(callback, screenViewMap, null); + } + }, new DataActionListener() { + @Override + public void onDataAction(ApiError apiError) { + executeFailureCallbackResponse(callback, null, apiError); + } + } + ); + } + private WritableArray recommendationToWritableArray(List array) { WritableArray writableArray = Arguments.createArray(); @@ -227,6 +336,16 @@ private WritableMap audienceToWritableMap(Audience audience) { return audienceMap; } + private WritableMap audienceNewScreenViewsToWritableMap(com.synerise.sdk.content.model.screenview.Audience audience) { + WritableMap audienceMap = Arguments.createMap(); + List segments = audience.getSegments(); + audienceMap.putArray("segments", segments != null ? listOfStringsIntoWritableArray(segments) : null); + audienceMap.putString("targetType", audience.getTargetType()); + audienceMap.putString("query", audience.getQuery()); + + return audienceMap; + } + private WritableMap screenViewDataToWritableMap(Object data) { WritableMap screenViewData = Arguments.createMap(); diff --git a/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java b/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java index 26ad687..55d049e 100644 --- a/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java +++ b/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java @@ -16,7 +16,7 @@ public class RNSyneriseInitializer { public Boolean isCrashHandlingEnabled; public static volatile boolean isInitialized = false; - public static final String SDK_PLUGIN_VERSION = "0.16.0"; + public static final String SDK_PLUGIN_VERSION = "0.17.0"; public void initialize(Application app) { if (isInitialized == false) { diff --git a/ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m b/ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m index 062bd68..b6126c7 100644 --- a/ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m +++ b/ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m @@ -8,7 +8,7 @@ #import "RNSyneriseInitializer.h" -NSString * const SNRSyneriseSDKPluginVersion = @"0.16.0"; +NSString * const SNRSyneriseSDKPluginVersion = @"0.17.0"; @implementation RNSyneriseInitializer diff --git a/ios/ReactNativeSynerise/Modules/RNContent.m b/ios/ReactNativeSynerise/Modules/RNContent.m index 8ca0878..1b391ac 100644 --- a/ios/ReactNativeSynerise/Modules/RNContent.m +++ b/ios/ReactNativeSynerise/Modules/RNContent.m @@ -66,6 +66,21 @@ - (SNRRecommendationOptions *)modelRecommendationOptionsWithDictionary:(NSDictio #pragma mark - JS Mapping +- (nullable NSDictionary *)dictionaryWithDocument:(SNRDocument *)model { + if (model != nil) { + NSMutableDictionary *dictionary = [@{} mutableCopy]; + + [dictionary setString:model.identifier forKey:@"uuid"]; + [dictionary setString:model.slug forKey:@"slug"]; + [dictionary setString:model.schema forKey:@"schema"]; + [dictionary setDictionary:model.content forKey:@"content"]; + + return dictionary; + } + + return nil; +} + - (nullable NSDictionary *)dictionaryWithRecommendationResponse:(SNRRecommendationResponse *)model { if (model != nil) { NSMutableDictionary *dictionary = [@{} mutableCopy]; @@ -128,6 +143,28 @@ - (nullable NSDictionary *)dictionaryWithScreenViewResponse:(SNRScreenViewRespon return nil; } +- (nullable NSDictionary *)dictionaryWithScreenView:(SNRScreenView *)model { + if (model != nil) { + NSMutableDictionary *dictionary = [@{} mutableCopy]; + + [dictionary setString:model.identifier forKey:@"identifier"]; + [dictionary setString:model.name forKey:@"name"]; + [dictionary setString:model.hashString forKey:@"hashString"]; + [dictionary setString:model.path forKey:@"path"]; + [dictionary setInteger:model.priority forKey:@"priority"]; + [dictionary setDictionary:[self dictionaryWithScreenViewAudienceInfo:model.audience] forKey:@"audience"]; + + [dictionary setGenericObject:model.data forKey:@"data"]; + + [dictionary setDate:model.createdAt forKey:@"createdAt"]; + [dictionary setDate:model.updatedAt forKey:@"updatedAt"]; + + return dictionary; + } + + return nil; +} + - (nullable NSDictionary *)dictionaryWithScreenViewAudience:(SNRScreenViewAudience *)model { if (model != nil) { NSMutableDictionary *dictionary = [@{} mutableCopy]; @@ -141,6 +178,20 @@ - (nullable NSDictionary *)dictionaryWithScreenViewAudience:(SNRScreenViewAudien return nil; } +- (nullable NSDictionary *)dictionaryWithScreenViewAudienceInfo:(SNRScreenViewAudienceInfo *)model { + if (model != nil) { + NSMutableDictionary *dictionary = [@{} mutableCopy]; + + [dictionary setArray:model.segments forKey:@"segments"]; + [dictionary setString:model.query forKey:@"query"]; + [dictionary setString:model.targetType forKey:@"targetType"]; + + return dictionary; + } + + return nil; +} + #pragma mark - JS Module //getDocument(slug: String, onSuccess: (documentResponse: Object) => void, onError: (error: Error) => void) @@ -158,6 +209,22 @@ - (nullable NSDictionary *)dictionaryWithScreenViewAudience:(SNRScreenViewAudien }]; } +//generateDocument(slug: string, onSuccess: (document: Document) => void, onError: (error: Error) => void) + +RCT_EXPORT_METHOD(generateDocument:(NSString *)slug response:(RCTResponseSenderBlock)response) +{ + [SNRContent generateDocument:slug success:^(SNRDocument *document) { + NSDictionary *documentDictionary = [self dictionaryWithDocument:document]; + if (documentDictionary != nil) { + [self executeSuccessCallbackResponse:response data:documentDictionary]; + } else { + [self executeDefaultFailureCallbackResponse:response]; + } + } failure:^(NSError *error) { + [self executeFailureCallbackResponse:response error:error]; + }]; +} + //getDocuments(documentsApiQuery: DocumentsApiQuery, onSuccess: (documentResponse: Object) => void, onError: (error: Error) => void) RCT_EXPORT_METHOD(getDocuments:(NSDictionary *)dictionary response:(RCTResponseSenderBlock)response) @@ -176,7 +243,7 @@ - (nullable NSDictionary *)dictionaryWithScreenViewAudience:(SNRScreenViewAudien } } -//getRecommendations(recommendationOptions: RecommendationOptions, onSuccess: (recommendationResponse: RecommendationResponse) => void, onError: (error: Error) => void) +//getRecommendations(options: RecommendationOptions, onSuccess: (recommendationResponse: RecommendationResponse) => void, onError: (error: Error) => void) RCT_EXPORT_METHOD(getRecommendations:(NSDictionary *)dictionary response:(RCTResponseSenderBlock)response) { @@ -199,6 +266,29 @@ - (nullable NSDictionary *)dictionaryWithScreenViewAudience:(SNRScreenViewAudien } } +//getRecommendationsV2(options: RecommendationOptions, onSuccess: (recommendationResponse: RecommendationResponse) + +RCT_EXPORT_METHOD(getRecommendationsV2:(NSDictionary *)dictionary response:(RCTResponseSenderBlock)response) +{ + SNRRecommendationOptions *recommendationOptions = [self modelRecommendationOptionsWithDictionary:dictionary]; + if (recommendationOptions != nil) { + [SNRContent getRecommendationsV2:recommendationOptions success:^(SNRRecommendationResponse *recommendationResponse) { + if (recommendationResponse != nil) { + NSDictionary *recommendationResponseDictionary = [self dictionaryWithRecommendationResponse:recommendationResponse]; + if (recommendationResponseDictionary != nil) { + [self executeSuccessCallbackResponse:response data:recommendationResponseDictionary]; + } else { + [self executeDefaultFailureCallbackResponse:response]; + } + } else { + [self executeDefaultFailureCallbackResponse:response]; + } + } failure:^(NSError *error) { + [self executeFailureCallbackResponse:response error:error]; + }]; + } +} + //getScreenView(onSuccess: (screenViewResponse: ScreenViewResponse) => void, onError: (error: Error) => void) RCT_REMAP_METHOD(getScreenView, getScreenViewWithResponse:(RCTResponseSenderBlock)response) @@ -217,6 +307,24 @@ - (nullable NSDictionary *)dictionaryWithScreenViewAudience:(SNRScreenViewAudien }]; } +//generateScreenView(feedSlug: string, onSuccess: (screenView: ScreenView) => void, onError: (error: Error) => void) + +RCT_EXPORT_METHOD(generateScreenView:(NSString *)feedSlug response:(RCTResponseSenderBlock)response) +{ + [SNRContent generateScreenView:feedSlug success:^(SNRScreenView *screenView) { + if (screenView != nil) { + NSDictionary *screenViewDictionary = [self dictionaryWithScreenView:screenView]; + if (screenViewDictionary != nil) { + [self executeSuccessCallbackResponse:response data:screenViewDictionary]; + } else { + [self executeDefaultFailureCallbackResponse:response]; + } + } + } failure:^(NSError *error) { + [self executeFailureCallbackResponse:response error:error]; + }]; +} + @end NS_ASSUME_NONNULL_END diff --git a/ios/react-native-synerise-sdk.podspec b/ios/react-native-synerise-sdk.podspec index 919c808..836fde6 100644 --- a/ios/react-native-synerise-sdk.podspec +++ b/ios/react-native-synerise-sdk.podspec @@ -2,7 +2,7 @@ require 'json' package = JSON.parse(File.read('./../package.json')) -SYNERISE_SDK_FRAMEWORK_VERSION = '4.14.7' +SYNERISE_SDK_FRAMEWORK_VERSION = '4.14.9' Pod::Spec.new do |s| s.name = package['name'] diff --git a/lib/classes/models/Content/Document.d.ts b/lib/classes/models/Content/Document.d.ts new file mode 100644 index 0000000..c7e96ca --- /dev/null +++ b/lib/classes/models/Content/Document.d.ts @@ -0,0 +1,15 @@ +import { BaseModel } from '../BaseModel'; +interface IDocument { + uuid: string; + slug: string; + schema: string; + content: object; +} +declare class Document extends BaseModel { + uuid: string; + slug: string; + schema: string; + content: object; + constructor(modelObject: IDocument); +} +export { IDocument, Document }; diff --git a/lib/classes/models/Content/Document.js b/lib/classes/models/Content/Document.js new file mode 100644 index 0000000..ace25f0 --- /dev/null +++ b/lib/classes/models/Content/Document.js @@ -0,0 +1,30 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Document = void 0; +var BaseModel_1 = require("../BaseModel"); +var Document = /** @class */ (function (_super) { + __extends(Document, _super); + function Document(modelObject) { + var _this = _super.call(this, modelObject) || this; + _this.uuid = modelObject.uuid; + _this.slug = modelObject.slug; + _this.schema = modelObject.schema; + _this.content = modelObject.content; + return _this; + } + return Document; +}(BaseModel_1.BaseModel)); +exports.Document = Document; diff --git a/lib/classes/models/Content/ScreenView.d.ts b/lib/classes/models/Content/ScreenView.d.ts new file mode 100644 index 0000000..584f9ac --- /dev/null +++ b/lib/classes/models/Content/ScreenView.d.ts @@ -0,0 +1,26 @@ +import { BaseModel } from '../BaseModel'; +import { IScreenViewAudienceInfo, ScreenViewAudienceInfo } from './ScreenViewAudienceInfo'; +interface IScreenView { + identifier: string; + name: string; + hash: string; + path: string; + priority: number; + audience: IScreenViewAudienceInfo; + data: any; + createdAt: number; + updatedAt: number; +} +declare class ScreenView extends BaseModel { + identifier: string; + name: string; + hash: string; + path: string; + priority: number; + audience: ScreenViewAudienceInfo; + data: any; + createdAt: Date; + updatedAt: Date; + constructor(modelObject: IScreenView); +} +export { IScreenView, ScreenView }; diff --git a/lib/classes/models/Content/ScreenView.js b/lib/classes/models/Content/ScreenView.js new file mode 100644 index 0000000..a6d8dd0 --- /dev/null +++ b/lib/classes/models/Content/ScreenView.js @@ -0,0 +1,36 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ScreenView = void 0; +var BaseModel_1 = require("../BaseModel"); +var ScreenViewAudienceInfo_1 = require("./ScreenViewAudienceInfo"); +var ScreenView = /** @class */ (function (_super) { + __extends(ScreenView, _super); + function ScreenView(modelObject) { + var _this = _super.call(this, modelObject) || this; + _this.identifier = modelObject.identifier; + _this.name = modelObject.name; + _this.hash = modelObject.hash; + _this.path = modelObject.path; + _this.priority = modelObject.priority; + _this.audience = new ScreenViewAudienceInfo_1.ScreenViewAudienceInfo(modelObject.audience); + _this.data = modelObject.data; + _this.createdAt = new Date(modelObject.createdAt * 1000); + _this.updatedAt = new Date(modelObject.updatedAt * 1000); + return _this; + } + return ScreenView; +}(BaseModel_1.BaseModel)); +exports.ScreenView = ScreenView; diff --git a/lib/classes/models/Content/ScreenViewAudienceInfo.d.ts b/lib/classes/models/Content/ScreenViewAudienceInfo.d.ts new file mode 100644 index 0000000..21e899f --- /dev/null +++ b/lib/classes/models/Content/ScreenViewAudienceInfo.d.ts @@ -0,0 +1,13 @@ +import { BaseModel } from '../BaseModel'; +interface IScreenViewAudienceInfo { + segments?: Array; + query?: string; + targetType?: string; +} +declare class ScreenViewAudienceInfo extends BaseModel { + segments?: Array; + query?: string; + targetType?: string; + constructor(modelObject: IScreenViewAudienceInfo); +} +export { IScreenViewAudienceInfo, ScreenViewAudienceInfo }; diff --git a/lib/classes/models/Content/ScreenViewAudienceInfo.js b/lib/classes/models/Content/ScreenViewAudienceInfo.js new file mode 100644 index 0000000..89a73e5 --- /dev/null +++ b/lib/classes/models/Content/ScreenViewAudienceInfo.js @@ -0,0 +1,35 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ScreenViewAudienceInfo = void 0; +var BaseModel_1 = require("../BaseModel"); +var ScreenViewAudienceInfo = /** @class */ (function (_super) { + __extends(ScreenViewAudienceInfo, _super); + function ScreenViewAudienceInfo(modelObject) { + var _this = _super.call(this, modelObject) || this; + if (modelObject.segments !== undefined && modelObject.segments !== null) { + _this.segments = modelObject.segments; + } + if (modelObject.query !== undefined && modelObject.query !== null) { + _this.query = modelObject.query; + } + if (modelObject.targetType !== undefined && modelObject.targetType !== null) { + _this.targetType = modelObject.targetType; + } + return _this; + } + return ScreenViewAudienceInfo; +}(BaseModel_1.BaseModel)); +exports.ScreenViewAudienceInfo = ScreenViewAudienceInfo; diff --git a/lib/config/import_models.d.ts b/lib/config/import_models.d.ts index 6d8f48a..9e674f5 100644 --- a/lib/config/import_models.d.ts +++ b/lib/config/import_models.d.ts @@ -33,11 +33,14 @@ export { VoucherCodesResponse } from './../classes/models/Vouchers/VoucherCodesR export { AssignVoucherData } from './../classes/models/Vouchers/AssignVoucherData'; export { VoucherCodesData } from './../classes/models/Vouchers/VoucherCodesData'; export { VoucherCodeStatus } from './../classes/models/Vouchers/VoucherCodeStatus'; +export { Document } from './../classes/models/Content/Document'; export { RecommendationOptions } from './../classes/models/Content/RecommendationOptions'; export { RecommendationResponse } from './../classes/models/Content/RecommendationResponse'; export { Recommendation } from './../classes/models/Content/Recommendation'; export { ScreenViewAudience } from './../classes/models/Content/ScreenViewAudience'; export { ScreenViewResponse } from './../classes/models/Content/ScreenViewResponse'; +export { ScreenView } from './../classes/models/Content/ScreenView'; +export { ScreenViewAudienceInfo } from '../classes/models/Content/ScreenViewAudienceInfo'; export { BaseApiQuery, IApiQuerySorting, ApiQuerySortingOrder } from './../classes/api_queries/BaseApiQuery'; export { PromotionsApiQuery } from './../classes/api_queries/PromotionsApiQuery'; export { DocumentsApiQuery } from './../classes/api_queries/DocumentsApiQuery'; diff --git a/lib/config/import_models.js b/lib/config/import_models.js index 0da9b57..5dec63a 100644 --- a/lib/config/import_models.js +++ b/lib/config/import_models.js @@ -82,6 +82,8 @@ Object.defineProperty(exports, "VoucherCodesData", { enumerable: true, get: func var VoucherCodeStatus_1 = require("./../classes/models/Vouchers/VoucherCodeStatus"); Object.defineProperty(exports, "VoucherCodeStatus", { enumerable: true, get: function () { return VoucherCodeStatus_1.VoucherCodeStatus; } }); // CONTENT +var Document_1 = require("./../classes/models/Content/Document"); +Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return Document_1.Document; } }); var RecommendationOptions_1 = require("./../classes/models/Content/RecommendationOptions"); Object.defineProperty(exports, "RecommendationOptions", { enumerable: true, get: function () { return RecommendationOptions_1.RecommendationOptions; } }); var RecommendationResponse_1 = require("./../classes/models/Content/RecommendationResponse"); @@ -92,6 +94,10 @@ var ScreenViewAudience_1 = require("./../classes/models/Content/ScreenViewAudien Object.defineProperty(exports, "ScreenViewAudience", { enumerable: true, get: function () { return ScreenViewAudience_1.ScreenViewAudience; } }); var ScreenViewResponse_1 = require("./../classes/models/Content/ScreenViewResponse"); Object.defineProperty(exports, "ScreenViewResponse", { enumerable: true, get: function () { return ScreenViewResponse_1.ScreenViewResponse; } }); +var ScreenView_1 = require("./../classes/models/Content/ScreenView"); +Object.defineProperty(exports, "ScreenView", { enumerable: true, get: function () { return ScreenView_1.ScreenView; } }); +var ScreenViewAudienceInfo_1 = require("../classes/models/Content/ScreenViewAudienceInfo"); +Object.defineProperty(exports, "ScreenViewAudienceInfo", { enumerable: true, get: function () { return ScreenViewAudienceInfo_1.ScreenViewAudienceInfo; } }); // API QUERIES var BaseApiQuery_1 = require("./../classes/api_queries/BaseApiQuery"); Object.defineProperty(exports, "BaseApiQuery", { enumerable: true, get: function () { return BaseApiQuery_1.BaseApiQuery; } }); diff --git a/lib/main/modules/ContentModule.d.ts b/lib/main/modules/ContentModule.d.ts index 3056717..acbabad 100644 --- a/lib/main/modules/ContentModule.d.ts +++ b/lib/main/modules/ContentModule.d.ts @@ -4,6 +4,8 @@ import { RecommendationOptions } from '../../classes/models/Content/Recommendati import { RecommendationResponse } from '../../classes/models/Content/RecommendationResponse'; import { Error } from '../..'; import { ScreenViewResponse } from '../../config/import_models'; +import { ScreenView } from '../../classes/models/Content/ScreenView'; +import { Document } from '../../classes/models/Content/Document'; declare class ContentModule extends Module { private static _instance; static instance(): ContentModule; @@ -15,8 +17,18 @@ declare class ContentModule extends Module { * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated Use the new `Content.generateDocument(slug:onSuccess:onError)` method instead. */ getDocument(slug: string, onSuccess: (document: object) => void, onError: (error: Error) => void): void; + /** + * This method generates the document that is defined for the provided slug. + * + * @param slug Identifies a specific document + * @param onSuccess Function to be executed when the operation finishes successfully + * @param onError Function to be executed when the operation finishes unsuccessfully + * + */ + generateDocument(slug: string, onSuccess: (document: Document) => void, onError: (error: Error) => void): void; /** * This method gets documents that are defined for parameters provided in the query object. * @@ -24,6 +36,7 @@ declare class ContentModule extends Module { * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated This method is deprecated. */ getDocuments(apiQuery: DocumentsApiQuery, onSuccess: (documents: Array) => void, onError: (error: Error) => void): void; /** @@ -33,15 +46,33 @@ declare class ContentModule extends Module { * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated Use the new `Content.getRecommendationsV2(options:onSuccess:onError)` method instead. */ getRecommendations(options: RecommendationOptions, onSuccess: (recommendationResponse: RecommendationResponse) => void, onError: (error: Error) => void): void; + /** + * This method gets recommendations that are defined for the options provided. + * + * @param options `RecommendationOptions` object providing parameters for recommendations + * @param onSuccess Function to be executed when the operation finishes successfully + * @param onError Function to be executed when the operation finishes unsuccessfully + */ + getRecommendationsV2(options: RecommendationOptions, onSuccess: (recommendationResponse: RecommendationResponse) => void, onError: (error: Error) => void): void; /** * This method gets customer's highest-priority screen view campaign. * * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated Use the new `Content.generateScreenView(feedSlug:onSuccess:onError)` method instead. */ getScreenView(onSuccess: (screenViewResponse: ScreenViewResponse) => void, onError: (error: Error) => void): void; + /** + * This method generates customer's highest-priority screen view campaign. + * + * @param onSuccess Function to be executed when the operation finishes successfully + * @param onError Function to be executed when the operation finishes unsuccessfully + * + */ + generateScreenView(feedSlug: string, onSuccess: (screenView: ScreenView) => void, onError: (error: Error) => void): void; } export { ContentModule }; diff --git a/lib/main/modules/ContentModule.js b/lib/main/modules/ContentModule.js index 9bef834..9c748bd 100644 --- a/lib/main/modules/ContentModule.js +++ b/lib/main/modules/ContentModule.js @@ -20,6 +20,8 @@ var BaseModule_1 = require("./BaseModule"); var BaseModel_1 = require("../../classes/models/BaseModel"); var RecommendationResponse_1 = require("../../classes/models/Content/RecommendationResponse"); var import_models_1 = require("../../config/import_models"); +var ScreenView_1 = require("../../classes/models/Content/ScreenView"); +var Document_1 = require("../../classes/models/Content/Document"); var RNContent = react_native_1.NativeModules.RNContent; var ContentModule = /** @class */ (function (_super) { __extends(ContentModule, _super); @@ -39,10 +41,22 @@ var ContentModule = /** @class */ (function (_super) { * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated Use the new `Content.generateDocument(slug:onSuccess:onError)` method instead. */ ContentModule.prototype.getDocument = function (slug, onSuccess, onError) { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.getDocument, [slug], onSuccess, onError); }; + /** + * This method generates the document that is defined for the provided slug. + * + * @param slug Identifies a specific document + * @param onSuccess Function to be executed when the operation finishes successfully + * @param onError Function to be executed when the operation finishes unsuccessfully + * + */ + ContentModule.prototype.generateDocument = function (slug, onSuccess, onError) { + SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.generateDocument, [slug], onSuccess, onError, BaseModel_1.ModelMapper.make(Document_1.Document)); + }; /** * This method gets documents that are defined for parameters provided in the query object. * @@ -50,6 +64,7 @@ var ContentModule = /** @class */ (function (_super) { * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated This method is deprecated. */ ContentModule.prototype.getDocuments = function (apiQuery, onSuccess, onError) { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.getDocuments, [apiQuery], onSuccess, onError); @@ -61,21 +76,44 @@ var ContentModule = /** @class */ (function (_super) { * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated Use the new `Content.getRecommendationsV2(options:onSuccess:onError)` method instead. */ ContentModule.prototype.getRecommendations = function (options, onSuccess, onError) { var optionsObject = options.toObject(); SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.getRecommendations, [optionsObject], onSuccess, onError, BaseModel_1.ModelMapper.make(RecommendationResponse_1.RecommendationResponse)); }; + /** + * This method gets recommendations that are defined for the options provided. + * + * @param options `RecommendationOptions` object providing parameters for recommendations + * @param onSuccess Function to be executed when the operation finishes successfully + * @param onError Function to be executed when the operation finishes unsuccessfully + */ + ContentModule.prototype.getRecommendationsV2 = function (options, onSuccess, onError) { + var optionsObject = options.toObject(); + SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.getRecommendationsV2, [optionsObject], onSuccess, onError, BaseModel_1.ModelMapper.make(RecommendationResponse_1.RecommendationResponse)); + }; /** * This method gets customer's highest-priority screen view campaign. * * @param onSuccess Function to be executed when the operation finishes successfully * @param onError Function to be executed when the operation finishes unsuccessfully * + * @deprecated Use the new `Content.generateScreenView(feedSlug:onSuccess:onError)` method instead. */ ContentModule.prototype.getScreenView = function (onSuccess, onError) { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.getScreenView, [], onSuccess, onError, BaseModel_1.ModelMapper.make(import_models_1.ScreenViewResponse)); }; + /** + * This method generates customer's highest-priority screen view campaign. + * + * @param onSuccess Function to be executed when the operation finishes successfully + * @param onError Function to be executed when the operation finishes unsuccessfully + * + */ + ContentModule.prototype.generateScreenView = function (feedSlug, onSuccess, onError) { + SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNContent.generateScreenView, [feedSlug], onSuccess, onError, BaseModel_1.ModelMapper.make(ScreenView_1.ScreenView)); + }; return ContentModule; }(BaseModule_1.BaseModule)); exports.ContentModule = ContentModule; diff --git a/package.json b/package.json index 6232bac..d5053ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-synerise-sdk", - "version": "0.16.0", + "version": "0.17.0", "description": "React Native wrapper for Synerise SDK", "author": { "name": "Synerise", @@ -37,6 +37,6 @@ }, "devDependencies": { "prettier": "^1.18.2", - "typescript": "^3.9.9" + "typescript": "^3.6.4" } }