Skip to content

Commit

Permalink
Release of version 0.10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Kurzawa committed Jul 26, 2022
1 parent c5cfc05 commit 2c63c07
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 101 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [0.10.5] - 2022-07-26

### Fixed
- Fix issue with `ClientAgreements` model with conversion for native modules communication.


## [0.10.4] - 2022-07-15

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ext.versions = [
'minSdk' : 21,
'compileSdk' : 31,
'targetSdk' : 31,
'versionCode': 21,
'versionName': "0.10.4"
'versionCode': 22,
'versionName': "0.10.5"
]

buildscript {
Expand Down
12 changes: 6 additions & 6 deletions android/src/main/java/com/synerise/sdk/react/RNClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,12 @@ private Attributes attributesMapper(HashMap<String, Object> map) {
private Agreements agreementsMapper(ReadableMap map) {
if (map != null) {
Agreements agreements = new Agreements();
agreements.setBluetooth(map.getBoolean("bluetooth"));
agreements.setEmail(map.getBoolean("email"));
agreements.setPush(map.getBoolean("push"));
agreements.setRfid(map.getBoolean("rfid"));
agreements.setWifi(map.getBoolean("wifi"));
agreements.setSms(map.getBoolean("sms"));
if (map.hasKey("bluetooth")) agreements.setBluetooth(map.getBoolean("bluetooth"));
if (map.hasKey("email")) agreements.setEmail(map.getBoolean("email"));
if (map.hasKey("push")) agreements.setPush(map.getBoolean("push"));
if (map.hasKey("rfid")) agreements.setRfid(map.getBoolean("rfid"));
if (map.hasKey("wifi")) agreements.setWifi(map.getBoolean("wifi"));
if (map.hasKey("sms")) agreements.setSms(map.getBoolean("sms"));

return agreements;
} else {
Expand Down
2 changes: 2 additions & 0 deletions ios/ReactNativeSynerise/Categories/NSDictionary+ReactNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface NSDictionary (ReactNative)

- (BOOL)isValueNotNilForKey:(NSString *)key;

- (nullable NSString *)getStringForKey:(NSString *)key;
- (nullable NSNumber *)getNumberForKey:(NSString *)key;
- (nullable NSArray *)getArrayForKey:(NSString *)key;
Expand Down
4 changes: 4 additions & 0 deletions ios/ReactNativeSynerise/Categories/NSDictionary+ReactNative.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ @implementation NSDictionary (ReactNative)

#pragma mark - Public

- (BOOL)isValueNotNilForKey:(NSString *)key {
return [self objectForKey:key] != nil;
}

- (nullable NSString *)getStringForKey:(NSString *)key {
return [self getObjectForKey:key properClass:NSString.class];
}
Expand Down
30 changes: 24 additions & 6 deletions ios/ReactNativeSynerise/Modules/RNClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,30 @@ - (nullable SNRClientUpdateAccountContext *)modelClientUpdateAccountContextWithD
- (nullable SNRClientAgreements *)modelClientAgreementsWithDictionary:(nullable NSDictionary *)dictionary {
if (dictionary != nil) {
SNRClientAgreements *model = [SNRClientAgreements new];
model.email = [dictionary getBoolForKey:@"email"];
model.sms = [dictionary getBoolForKey:@"sms"];
model.push = [dictionary getBoolForKey:@"push"];
model.bluetooth = [dictionary getBoolForKey:@"bluetooth"];
model.rfid = [dictionary getBoolForKey:@"rfid"];
model.wifi = [dictionary getBoolForKey:@"wifi"];

if ([dictionary isValueNotNilForKey:@"email"] == YES) {
model.email = [dictionary getBoolForKey:@"email"];
}

if ([dictionary isValueNotNilForKey:@"sms"] == YES) {
model.sms = [dictionary getBoolForKey:@"sms"];
}

if ([dictionary isValueNotNilForKey:@"push"] == YES) {
model.push = [dictionary getBoolForKey:@"push"];
}

if ([dictionary isValueNotNilForKey:@"bluetooth"] == YES) {
model.bluetooth = [dictionary getBoolForKey:@"bluetooth"];
}

if ([dictionary isValueNotNilForKey:@"rfid"] == YES) {
model.rfid = [dictionary getBoolForKey:@"rfid"];
}

if ([dictionary isValueNotNilForKey:@"wifi"] == YES) {
model.wifi = [dictionary getBoolForKey:@"wifi"];
}

return model;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/classes/models/BaseModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ interface ModelMappableConstructor<M> {
}
interface ModelMappable {
toObject(): object;
toObjectIfNotEmpty(): object | undefined;
}
declare abstract class BaseModel implements ModelMappable {
constructor();
constructor(modelObject: object);
toObject(): object;
toObjectIfNotEmpty(): object | undefined;
}
declare type ModelMappingFunction = (modelObject: object) => BaseModel | null;
declare class ModelMapper {
Expand Down
14 changes: 14 additions & 0 deletions lib/classes/models/BaseModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ var BaseModel = /** @class */ (function () {
BaseModel.prototype.toObject = function () {
return {};
};
BaseModel.prototype.toObjectIfNotEmpty = function () {
var object = this.toObject();
var filteredObject = Object.entries(Object.entries(object)
.filter(function (_a) {
var key = _a[0], value = _a[1];
return value !== undefined;
}));
if (Object.keys(filteredObject).length > 0) {
return object;
}
else {
return undefined;
}
};
return BaseModel;
}());
exports.BaseModel = BaseModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ declare class ClientAccountRegisterContext extends BaseModel {
province?: string;
zipCode?: string;
countryCode?: string;
agreements?: ClientAgreements;
agreements: ClientAgreements;
attributes?: object;
constructor(email: string, password: string, modelObject?: IClientAccountRegisterContext);
toObject(): object;
Expand Down
29 changes: 14 additions & 15 deletions lib/classes/models/Client/ClientAccountRegisterContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@ var ClientAgreements_1 = require("./../Client/ClientAgreements");
var ClientAccountRegisterContext = /** @class */ (function (_super) {
__extends(ClientAccountRegisterContext, _super);
function ClientAccountRegisterContext(email, password, modelObject) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var _this = _super.call(this) || this;
_this.email = email;
_this.password = password;
if (modelObject != undefined) {
_this.phone = modelObject.phone;
_this.customId = modelObject.customId;
_this.firstName = modelObject.firstName;
_this.lastName = modelObject.lastName;
_this.sex = modelObject.sex;
_this.company = modelObject.company;
_this.address = modelObject.address;
_this.province = modelObject.province;
_this.zipCode = modelObject.zipCode;
_this.countryCode = modelObject.countryCode;
_this.agreements = new ClientAgreements_1.ClientAgreements(modelObject.agreements);
_this.attributes = modelObject.attributes;
}
_this.phone = (_a = modelObject) === null || _a === void 0 ? void 0 : _a.phone;
_this.customId = (_b = modelObject) === null || _b === void 0 ? void 0 : _b.customId;
_this.firstName = (_c = modelObject) === null || _c === void 0 ? void 0 : _c.firstName;
_this.lastName = (_d = modelObject) === null || _d === void 0 ? void 0 : _d.lastName;
_this.sex = (_e = modelObject) === null || _e === void 0 ? void 0 : _e.sex;
_this.company = (_f = modelObject) === null || _f === void 0 ? void 0 : _f.company;
_this.address = (_g = modelObject) === null || _g === void 0 ? void 0 : _g.address;
_this.province = (_h = modelObject) === null || _h === void 0 ? void 0 : _h.province;
_this.zipCode = (_j = modelObject) === null || _j === void 0 ? void 0 : _j.zipCode;
_this.countryCode = (_k = modelObject) === null || _k === void 0 ? void 0 : _k.countryCode;
_this.agreements = new ClientAgreements_1.ClientAgreements((_l = modelObject) === null || _l === void 0 ? void 0 : _l.agreements);
_this.attributes = (_m = modelObject) === null || _m === void 0 ? void 0 : _m.attributes;
return _this;
}
ClientAccountRegisterContext.prototype.toObject = function () {
Expand All @@ -52,7 +51,7 @@ var ClientAccountRegisterContext = /** @class */ (function (_super) {
province: this.province,
zipCode: this.zipCode,
countryCode: this.countryCode,
agreements: this.agreements,
agreements: this.agreements.toObjectIfNotEmpty(),
attributes: this.attributes,
};
};
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/models/Client/ClientAccountUpdateContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ declare class ClientAccountUpdateContext extends BaseModel {
province?: string;
zipCode?: string;
countryCode?: string;
agreements?: ClientAgreements;
agreements: ClientAgreements;
attributes?: object;
constructor(modelObject?: IClientAccountUpdateContext);
toObject(): object;
Expand Down
39 changes: 19 additions & 20 deletions lib/classes/models/Client/ClientAccountUpdateContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,25 @@ var ClientAgreements_1 = require("./../Client/ClientAgreements");
var ClientAccountUpdateContext = /** @class */ (function (_super) {
__extends(ClientAccountUpdateContext, _super);
function ClientAccountUpdateContext(modelObject) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
var _this = _super.call(this) || this;
if (modelObject != undefined) {
_this.email = modelObject.email;
_this.phone = modelObject.phone;
_this.customId = modelObject.customId;
_this.uuid = modelObject.uuid;
_this.firstName = modelObject.firstName;
_this.lastName = modelObject.lastName;
_this.displayName = modelObject.displayName;
_this.sex = modelObject.sex;
_this.birthDate = modelObject.birthDate;
_this.avatarUrl = modelObject.avatarUrl;
_this.company = modelObject.company;
_this.address = modelObject.address;
_this.province = modelObject.province;
_this.zipCode = modelObject.zipCode;
_this.countryCode = modelObject.countryCode;
_this.agreements = new ClientAgreements_1.ClientAgreements(modelObject.agreements);
_this.attributes = modelObject.attributes;
}
_this.email = (_a = modelObject) === null || _a === void 0 ? void 0 : _a.email;
_this.phone = (_b = modelObject) === null || _b === void 0 ? void 0 : _b.phone;
_this.customId = (_c = modelObject) === null || _c === void 0 ? void 0 : _c.customId;
_this.uuid = (_d = modelObject) === null || _d === void 0 ? void 0 : _d.uuid;
_this.firstName = (_e = modelObject) === null || _e === void 0 ? void 0 : _e.firstName;
_this.lastName = (_f = modelObject) === null || _f === void 0 ? void 0 : _f.lastName;
_this.displayName = (_g = modelObject) === null || _g === void 0 ? void 0 : _g.displayName;
_this.sex = (_h = modelObject) === null || _h === void 0 ? void 0 : _h.sex;
_this.birthDate = (_j = modelObject) === null || _j === void 0 ? void 0 : _j.birthDate;
_this.avatarUrl = (_k = modelObject) === null || _k === void 0 ? void 0 : _k.avatarUrl;
_this.company = (_l = modelObject) === null || _l === void 0 ? void 0 : _l.company;
_this.address = (_m = modelObject) === null || _m === void 0 ? void 0 : _m.address;
_this.province = (_o = modelObject) === null || _o === void 0 ? void 0 : _o.province;
_this.zipCode = (_p = modelObject) === null || _p === void 0 ? void 0 : _p.zipCode;
_this.countryCode = (_q = modelObject) === null || _q === void 0 ? void 0 : _q.countryCode;
_this.agreements = new ClientAgreements_1.ClientAgreements((_r = modelObject) === null || _r === void 0 ? void 0 : _r.agreements);
_this.attributes = (_s = modelObject) === null || _s === void 0 ? void 0 : _s.attributes;
return _this;
}
ClientAccountUpdateContext.prototype.toObject = function () {
Expand All @@ -58,7 +57,7 @@ var ClientAccountUpdateContext = /** @class */ (function (_super) {
province: this.province,
zipCode: this.zipCode,
countryCode: this.countryCode,
agreements: this.agreements,
agreements: this.agreements.toObjectIfNotEmpty(),
attributes: this.attributes,
};
};
Expand Down
13 changes: 7 additions & 6 deletions lib/classes/models/Client/ClientAgreements.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ interface IClientAgreements {
wifi?: boolean;
}
declare class ClientAgreements extends BaseModel {
email: boolean;
sms: boolean;
push: boolean;
bluetooth: boolean;
rfid: boolean;
wifi: boolean;
email?: boolean;
sms?: boolean;
push?: boolean;
bluetooth?: boolean;
rfid?: boolean;
wifi?: boolean;
constructor(modelObject?: IClientAgreements);
toObject(): object;
}
export { IClientAgreements, ClientAgreements };
31 changes: 17 additions & 14 deletions lib/classes/models/Client/ClientAgreements.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@ var BaseModel_1 = require("./../BaseModel");
var ClientAgreements = /** @class */ (function (_super) {
__extends(ClientAgreements, _super);
function ClientAgreements(modelObject) {
var _a, _b, _c, _d, _e, _f;
var _this = _super.call(this, modelObject || {}) || this;
_this.email = false;
_this.sms = false;
_this.push = false;
_this.bluetooth = false;
_this.rfid = false;
_this.wifi = false;
if (modelObject != undefined) {
_this.email = modelObject.email || false;
_this.sms = modelObject.sms || false;
_this.push = modelObject.push || false;
_this.bluetooth = modelObject.bluetooth || false;
_this.rfid = modelObject.rfid || false;
_this.wifi = modelObject.wifi || false;
}
_this.email = (_a = modelObject) === null || _a === void 0 ? void 0 : _a.email;
_this.sms = (_b = modelObject) === null || _b === void 0 ? void 0 : _b.sms;
_this.push = (_c = modelObject) === null || _c === void 0 ? void 0 : _c.push;
_this.bluetooth = (_d = modelObject) === null || _d === void 0 ? void 0 : _d.bluetooth;
_this.rfid = (_e = modelObject) === null || _e === void 0 ? void 0 : _e.rfid;
_this.wifi = (_f = modelObject) === null || _f === void 0 ? void 0 : _f.wifi;
return _this;
}
ClientAgreements.prototype.toObject = function () {
return {
email: this.email,
sms: this.sms,
push: this.push,
bluetooth: this.bluetooth,
rfid: this.rfid,
wifi: this.wifi
};
};
return ClientAgreements;
}(BaseModel_1.BaseModel));
exports.ClientAgreements = ClientAgreements;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface IClientAppleSignInAuthenticationContext {
}
declare class ClientAppleSignInAuthenticationContext extends BaseModel {
authID?: string;
agreements?: ClientAgreements;
agreements: ClientAgreements;
attributes?: object;
constructor(modelObject?: IClientAppleSignInAuthenticationContext);
toObject(): object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ var ClientAgreements_1 = require("./ClientAgreements");
var ClientAppleSignInAuthenticationContext = /** @class */ (function (_super) {
__extends(ClientAppleSignInAuthenticationContext, _super);
function ClientAppleSignInAuthenticationContext(modelObject) {
var _a, _b, _c;
var _this = _super.call(this) || this;
if (modelObject != undefined) {
_this.authID = modelObject.authID;
_this.agreements = new ClientAgreements_1.ClientAgreements(modelObject.agreements);
_this.attributes = modelObject.attributes;
}
_this.authID = (_a = modelObject) === null || _a === void 0 ? void 0 : _a.authID;
_this.agreements = new ClientAgreements_1.ClientAgreements((_b = modelObject) === null || _b === void 0 ? void 0 : _b.agreements);
_this.attributes = (_c = modelObject) === null || _c === void 0 ? void 0 : _c.attributes;
return _this;
}
ClientAppleSignInAuthenticationContext.prototype.toObject = function () {
return {
authID: this.authID,
agreements: this.agreements,
agreements: this.agreements.toObjectIfNotEmpty(),
attributes: this.attributes,
};
};
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/models/Client/ClientAuthContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface IClientAuthContext {
}
declare class ClientAuthContext extends BaseModel {
authID?: string;
agreements?: ClientAgreements;
agreements: ClientAgreements;
attributes?: object;
constructor(modelObject?: IClientAuthContext);
toObject(): object;
Expand Down
11 changes: 5 additions & 6 deletions lib/classes/models/Client/ClientAuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ var ClientAgreements_1 = require("./ClientAgreements");
var ClientAuthContext = /** @class */ (function (_super) {
__extends(ClientAuthContext, _super);
function ClientAuthContext(modelObject) {
var _a, _b, _c;
var _this = _super.call(this) || this;
if (modelObject != undefined) {
_this.authID = modelObject.authID;
_this.agreements = new ClientAgreements_1.ClientAgreements(modelObject.agreements);
_this.attributes = modelObject.attributes;
}
_this.authID = (_a = modelObject) === null || _a === void 0 ? void 0 : _a.authID;
_this.agreements = new ClientAgreements_1.ClientAgreements((_b = modelObject) === null || _b === void 0 ? void 0 : _b.agreements);
_this.attributes = (_c = modelObject) === null || _c === void 0 ? void 0 : _c.attributes;
return _this;
}
ClientAuthContext.prototype.toObject = function () {
return {
authID: this.authID,
agreements: this.agreements,
agreements: this.agreements.toObjectIfNotEmpty(),
attributes: this.attributes,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface IClientFacebookAuthenticationContext {
}
declare class ClientFacebookAuthenticationContext extends BaseModel {
authID?: string;
agreements?: ClientAgreements;
agreements: ClientAgreements;
attributes?: object;
constructor(modelObject?: IClientFacebookAuthenticationContext);
toObject(): object;
Expand Down
Loading

0 comments on commit 2c63c07

Please sign in to comment.