Skip to content

Commit a654ef3

Browse files
adding branding ID for different branding themes support
1 parent 038c027 commit a654ef3

File tree

5 files changed

+85
-11
lines changed

5 files changed

+85
-11
lines changed

Source/Core/API/Account/INPAccountService.swift

+44-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class INPAccountService {
88
email: String,
99
password: String,
1010
passwordConfirmation: String,
11+
brandingId: Int?,
1112
metadata: [String: Any]?,
1213
completion: @escaping RequestCompletion<InPlayerAuthorization>) {
1314
var params: [String: Any] = [
@@ -25,6 +26,10 @@ class INPAccountService {
2526
if let metadata = metadata {
2627
params[AccountParameters.metadata] = metadata
2728
}
29+
30+
if let brandingID = brandingId {
31+
params[AccountParameters.brandingID] = brandingID
32+
}
2833

2934
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
3035
route: AccountAPIRouter.createAccount(parameters: params),
@@ -96,20 +101,34 @@ class INPAccountService {
96101
static func changePassword(oldPassword: String,
97102
newPassword: String,
98103
newPasswordConfirmation: String,
104+
brandingId: Int?,
99105
completion: @escaping RequestCompletion<Empty>) {
100-
let params: [String: Any] = [
106+
var params: [String: Any] = [
101107
AccountParameters.oldPassword: oldPassword,
102108
AccountParameters.password: newPassword,
103-
AccountParameters.passwordConfirmation: newPasswordConfirmation
109+
AccountParameters.passwordConfirmation: newPasswordConfirmation,
104110
]
111+
112+
if let brandingID = brandingId {
113+
params[AccountParameters.brandingID] = brandingID
114+
}
115+
105116
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
106117
route: AccountAPIRouter.changePassword(parameters: params),
107118
completion: completion)
108119
}
109120

110121
static func deleteAccount(password: String,
122+
brandingId: Int?,
111123
completion: @escaping RequestCompletion<Empty>) {
112-
let params = [AccountParameters.password: password]
124+
var params : [String: Any] = [
125+
AccountParameters.password: password
126+
]
127+
128+
if let brandingID = brandingId {
129+
params[AccountParameters.brandingID] = brandingID
130+
}
131+
113132
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
114133
route: AccountAPIRouter.eraseAccount(parameters: params),
115134
completion: { (empty: Empty?, error: InPlayerError?) in
@@ -122,23 +141,35 @@ class INPAccountService {
122141
static func setNewPassword(token: String,
123142
password: String,
124143
passwordConfirmation: String,
144+
brandingId: Int?,
125145
completion: @escaping RequestCompletion<Empty>) {
126-
let params = [
146+
var params : [String: Any] = [
127147
AccountParameters.password: password,
128148
AccountParameters.passwordConfirmation: passwordConfirmation
129149
]
150+
151+
if let brandingID = brandingId {
152+
params[AccountParameters.brandingID] = brandingID
153+
}
154+
130155
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
131156
route: AccountAPIRouter.setNewPassword(token: token,
132157
parameters: params),
133158
completion: completion)
134159
}
135160

136161
static func requestNewPassword(email: String,
162+
brandingId: Int?,
137163
completion: @escaping RequestCompletion<Empty>) {
138-
let params = [
164+
var params : [String: Any] = [
139165
AccountParameters.merchantUUID: InPlayer.clientId,
140166
AccountParameters.email: email
141167
]
168+
169+
if let brandingID = brandingId {
170+
params[AccountParameters.brandingID] = brandingID
171+
}
172+
142173
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
143174
route: AccountAPIRouter.forgotPassword(parameters: params),
144175
completion: completion)
@@ -176,8 +207,14 @@ class INPAccountService {
176207
})
177208
}
178209

179-
static func exportData(password: String, completion: @escaping RequestCompletion<Empty>) {
180-
let params = [AccountParameters.password: password]
210+
static func exportData(password: String, brandingId: Int?, completion: @escaping RequestCompletion<Empty>) {
211+
212+
var params : [String: Any] = [AccountParameters.password: password]
213+
214+
if let brandingID = brandingId {
215+
params[AccountParameters.brandingID] = brandingID
216+
}
217+
181218
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
182219
route: AccountAPIRouter.exportData(parameters: params),
183220
completion: completion)

Source/Core/Account.swift

+18-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public extension InPlayer {
6161
- password: Password containing minimum 8 characters
6262
- passwordConfirmation: The same password with minimum 8 characters
6363
- metadata: Additional information about the account that can be attached to the account object
64+
- brandingID: Optional parameter - system branding theme ID
6465
- success: A closure to be executed once the request has finished successfully.
6566
- authorization: Authorization model containing info regarding token and account
6667
- failure: A closure to be executed once the request has finished with error.
@@ -70,13 +71,15 @@ public extension InPlayer {
7071
email: String,
7172
password: String,
7273
passwordConfirmation: String,
74+
brandingID: Int? = nil,
7375
metadata: [String: Any]? = nil,
7476
success: @escaping (_ authorization: InPlayerAuthorization) -> Void,
7577
failure: @escaping (_ error: InPlayerError) -> Void) {
7678
INPAccountService.signUp(fullName: fullName,
7779
email: email,
7880
password: password,
7981
passwordConfirmation: passwordConfirmation,
82+
brandingId: brandingID,
8083
metadata: metadata,
8184
completion: { (authorization, error) in
8285
if let error = error {
@@ -180,18 +183,21 @@ public extension InPlayer {
180183
- oldPassword: Account's old password.
181184
- newPassword: The account's new password
182185
- newPasswordConfirmation: The account's new password for confirmation.
186+
- brandingID: Optional parameter - system branding theme ID
183187
- success: A closure to be executed once the request has finished successfully.
184188
- failure: A closure to be executed once the request has finished with error.
185189
- error: Containing information about the error that occurred.
186190
*/
187191
public static func changePassword(oldPassword: String,
188192
newPassword: String,
189193
newPasswordConfirmation: String,
194+
brandingID: Int? = nil,
190195
success: @escaping () -> Void,
191196
failure: @escaping (_ error: InPlayerError) -> Void) {
192197
INPAccountService.changePassword(oldPassword: oldPassword,
193198
newPassword: newPassword,
194199
newPasswordConfirmation: newPasswordConfirmation,
200+
brandingId: brandingID,
195201
completion: { (_, error) in
196202
if let error = error {
197203
failure(error)
@@ -205,14 +211,16 @@ public extension InPlayer {
205211
Deletes account and all information stored with it.
206212
- Parameters:
207213
- password: Password confirmation.
214+
- brandingID: Optional parameter - system branding theme ID
208215
- success: A closure to be executed once the request has finished successfully.
209216
- failure: A closure to be executed once the request has finished with error.
210217
- error: Containing information about the error that occurred.
211218
*/
212219
public static func deleteAccount(password: String,
220+
brandingID: Int? = nil,
213221
success: @escaping () -> Void,
214222
failure: @escaping (_ error: InPlayerError) -> Void) {
215-
INPAccountService.deleteAccount(password: password, completion: { (_, error) in
223+
INPAccountService.deleteAccount(password: password, brandingId: brandingID, completion: { (_, error) in
216224
if let error = error {
217225
failure(error)
218226
} else {
@@ -227,18 +235,21 @@ public extension InPlayer {
227235
- token: The forgot password token sent to your email address.
228236
- password: The account’s new password.
229237
- passwordConfirmation: The password confirmation.
238+
- brandingID: Optional parameter - system branding theme ID
230239
- success: A closure to be executed once the request has finished successfully.
231240
- failure: A closure to be executed once the request has finished with error.
232241
- error: Containing information about the error that occurred.
233242
*/
234243
public static func setNewPassword(token: String,
235244
password: String,
236245
passwordConfirmation: String,
246+
brandingID: Int? = nil,
237247
success: @escaping () -> Void,
238248
failure: @escaping (_ error: InPlayerError) -> Void) {
239249
INPAccountService.setNewPassword(token: token,
240250
password: password,
241251
passwordConfirmation: passwordConfirmation,
252+
brandingId: brandingID,
242253
completion: { (_, error) in
243254
if let error = error {
244255
failure(error)
@@ -252,14 +263,16 @@ public extension InPlayer {
252263
Sends forgot password instructions on specified email.
253264
- Parameters:
254265
- email: Account’s email address.
266+
- brandingID: Optional parameter - system branding theme ID
255267
- success: A closure to be executed once the request has finished successfully.
256268
- failure: A closure to be executed once the request has finished with error.
257269
- error: Containing information about the error that occurred.
258270
*/
259271
public static func requestNewPassword(email: String,
272+
brandingID: Int? = nil,
260273
success: @escaping () -> Void,
261274
failure: @escaping (_ error: InPlayerError) -> Void) {
262-
INPAccountService.requestNewPassword(email: email, completion: { (_, error) in
275+
INPAccountService.requestNewPassword(email: email, brandingId: brandingID, completion: { (_, error) in
263276
if let error = error {
264277
failure(error)
265278
} else {
@@ -295,14 +308,16 @@ public extension InPlayer {
295308
Exports account data such as logins, payments, subscriptions, access to assets etc. After invoking the request the account will receive the data in a json format via e-mail.
296309
- Parameters:
297310
- password: Password of the current logged user
311+
- brandingID: Optional parameter - system branding theme ID
298312
- success: A closure to be executed once the request has finished successfully.
299313
- failure: A closure to be executed once the request has finished with error.
300314
- error: Containing information about the error that occurred.
301315
*/
302316
public static func exportData(password: String,
317+
brandingID: Int? = nil,
303318
success: @escaping () -> Void,
304319
failure: @escaping (_ error: InPlayerError) -> Void) {
305-
INPAccountService.exportData(password: password) { (_, error) in
320+
INPAccountService.exportData(password: password, brandingId: brandingID) { (_, error) in
306321
if let error = error {
307322
failure(error)
308323
} else {

Source/Payment/API/INPPaymentService.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class INPPaymentService {
66

77
static func validate(receiptString: String,
88
productIdentifier: String,
9+
brandingId: Int?,
910
completion: @escaping RequestCompletion<Empty>) {
1011

1112
let productComponents = productIdentifier.components(separatedBy: "_")
@@ -27,11 +28,16 @@ class INPPaymentService {
2728
let accessFeeId = Int(productComponents[1]) else {
2829
return completion(nil, inpError)
2930
}
30-
let params: [String: Any] = [
31+
var params: [String: Any] = [
3132
PaymentParameters.receipt: receiptString,
3233
PaymentParameters.itemId: itemId,
3334
PaymentParameters.accessFeeId: accessFeeId
3435
]
36+
37+
if let brandingID = brandingId {
38+
params[PaymentParameters.brandingID] = brandingID
39+
}
40+
3541
NetworkDataSource.performRequest(session: InPlayerSessionAPIManager.default.session,
3642
route: PaymentAPIRouter.validatePayment(parameters: params),
3743
completion: completion)
@@ -135,4 +141,5 @@ private struct PaymentParameters {
135141
static let type = "type"
136142
static let customerId = "customerID"
137143
static let productName = "product_name"
144+
static let brandingID = "branding_id"
138145
}

Source/Payment/Payment.swift

+3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ public extension InPlayer {
1313
- Parameters:
1414
- receiptString: Base64EncodedString of the recept data stored on device after successfull in-app purchase.
1515
- productIdentifier: String combination of `itemId` and `accessFeeId`, connected with `_`
16+
- brandingID: Optional parameter - system branding theme ID
1617
- success: A closure to be executed once the request has finished successfully.
1718
- failure: A closure to be executed once the request has finished with error.
1819
- error: Containing information about the error that occurred.
1920
*/
2021
public static func validate(receiptString: String,
2122
productIdentifier: String,
23+
brandingID: Int? = nil,
2224
success: @escaping ()-> Void,
2325
failure: @escaping (_ error: InPlayerError) -> Void) {
2426
INPPaymentService.validate(receiptString: receiptString,
2527
productIdentifier: productIdentifier,
28+
brandingId: brandingID,
2629
completion: { (_, error) in
2730
if let error = error {
2831
failure(error)

docs/docsets/InPlayerSDK.docset/Contents/Resources/Documents/Classes/InPlayer/Account.html

+12
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,18 @@ <h4>Parameters</h4>
550550
</div>
551551
</td>
552552
</tr>
553+
<tr>
554+
<td>
555+
<code>
556+
<em>brandingID</em>
557+
</code>
558+
</td>
559+
<td>
560+
<div>
561+
<p>Optional parameter</p>
562+
</div>
563+
</td>
564+
</tr>
553565
<tr>
554566
<td>
555567
<code>

0 commit comments

Comments
 (0)