@pensasystems/pensa-react-native 0.1.0-beta-14 → 0.1.0-beta-15

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.
@@ -7,15 +7,7 @@ buildscript {
7
7
  google()
8
8
  mavenCentral()
9
9
  maven {
10
- //url = uri("https://sdk.pensasystems.net/pensa-sdk-android")
11
- url = uri("https://pensasystems.jfrog.io/artifactory/pensa-dev-maven-sdk-android-virtual/")
12
- credentials {
13
- username = "ci-cd-service"
14
- password = "GChhw(Ywq&-qu1@@"
15
- }
16
- authentication {
17
- basic(BasicAuthentication)
18
- }
10
+ url = uri("https://sdk.pensasystems.net/pensa-sdk-android")
19
11
  }
20
12
  }
21
13
 
@@ -83,15 +75,7 @@ repositories {
83
75
  mavenCentral()
84
76
  google()
85
77
  maven {
86
- //url = uri("https://sdk.pensasystems.net/pensa-sdk-android")
87
- url = uri("https://pensasystems.jfrog.io/artifactory/pensa-dev-maven-sdk-android-virtual/")
88
- credentials {
89
- username = "ci-cd-service"
90
- password = "GChhw(Ywq&-qu1@@"
91
- }
92
- authentication {
93
- basic(BasicAuthentication)
94
- }
78
+ url = uri("https://sdk.pensasystems.net/pensa-sdk-android")
95
79
  }
96
80
  }
97
81
 
@@ -99,7 +83,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
99
83
 
100
84
  dependencies {
101
85
  coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
102
- implementation "com.pensasystems:pensasdk:1.0.19"
86
+ implementation "com.pensasystems:pensasdk:1.0.20"
103
87
  implementation "com.facebook.react:react-android"
104
88
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
105
89
  }
@@ -215,9 +215,13 @@ class PensaSdkReactNativeModule(reactContext: ReactApplicationContext) :
215
215
  }
216
216
 
217
217
  @ReactMethod
218
- fun fetchOnDemandReports(scanId: Int, projectId: Int?, reportTypes: ReadableArray?, promise: Promise) {
218
+ fun fetchOnDemandReports(
219
+ scanId: Int,
220
+ projectId: Int?,
221
+ reportTypes: ReadableArray?,
222
+ promise: Promise
223
+ ) {
219
224
  try {
220
-
221
225
  val finalReportTypes = parseReportTypes(reportTypes)
222
226
 
223
227
  PensaSdk.fetchOnDemandReports(
@@ -225,98 +229,65 @@ class PensaSdkReactNativeModule(reactContext: ReactApplicationContext) :
225
229
  projectId = projectId,
226
230
  reportTypes = finalReportTypes,
227
231
  onSuccess = { report ->
228
-
229
232
  val result = Arguments.createMap()
230
233
 
231
- report.facingsSeen?.let { bucket ->
232
- val productsArray = Arguments.createArray()
233
- bucket.productList.forEach { product ->
234
- val p = Arguments.createMap()
235
- p.putString("brand", product.brand)
236
-
237
- val brandId = product.brandId
238
- if (brandId != null) p.putInt("brandId", brandId) else p.putNull("brandId")
239
-
240
- p.putString("category", product.category)
241
-
242
- val categoryId = product.categoryId
243
- if (categoryId != null) p.putInt("categoryId", categoryId) else p.putNull("categoryId")
244
-
245
- val expectedFacings = product.expectedFacings
246
- if (expectedFacings != null) p.putInt("expectedFacings", expectedFacings) else p.putNull("expectedFacings")
234
+ fun toProductMap(p: com.pensasystems.pensasdk.model.PensaOnDemandProduct) =
235
+ Arguments.createMap().apply {
236
+ putString("brand", p.brand)
237
+ p.brandId?.let { putInt("brandId", it) } ?: putNull("brandId")
247
238
 
248
- val facings = product.facings
249
- if (facings != null) p.putInt("facings", facings) else p.putNull("facings")
239
+ putString("category", p.category)
240
+ p.categoryId?.let { putInt("categoryId", it) } ?: putNull("categoryId")
250
241
 
251
- p.putString("manufacturer", product.manufacturer)
242
+ p.expectedFacings?.let { putInt("expectedFacings", it) } ?: putNull("expectedFacings")
243
+ p.facings?.let { putInt("facings", it) } ?: putNull("facings")
252
244
 
253
- val manufacturerId = product.manufacturerId
254
- if (manufacturerId != null) p.putInt("manufacturerId", manufacturerId) else p.putNull("manufacturerId")
245
+ putString("manufacturer", p.manufacturer)
246
+ p.manufacturerId?.let { putInt("manufacturerId", it) } ?: putNull("manufacturerId")
255
247
 
256
- p.putString("product", product.product)
248
+ putString("product", p.product)
249
+ p.productId?.let { putInt("productId", it) } ?: putNull("productId")
257
250
 
258
- val productId = product.productId
259
- if (productId != null) p.putInt("productId", productId) else p.putNull("productId")
260
-
261
- p.putString("upc", product.upc)
262
-
263
- productsArray.pushMap(p)
251
+ putString("upc", p.upc)
264
252
  }
265
- val bucketMap = Arguments.createMap()
266
- bucketMap.putArray("productList", productsArray)
267
- result.putMap("facingsSeen", bucketMap)
268
- } ?: result.putNull("facingsSeen")
269
-
270
- report.itemsSeen?.let { bucket ->
271
- val productsArray = Arguments.createArray()
272
- bucket.productList.forEach { product ->
273
- val p = Arguments.createMap()
274
- p.putString("brand", product.brand)
275
-
276
- val brandId = product.brandId
277
- if (brandId != null) p.putInt("brandId", brandId) else p.putNull("brandId")
278
-
279
- p.putString("category", product.category)
280
-
281
- val categoryId = product.categoryId
282
- if (categoryId != null) p.putInt("categoryId", categoryId) else p.putNull("categoryId")
283
253
 
284
- val facings = product.facings
285
- if (facings != null) p.putInt("facings", facings) else p.putNull("facings")
286
-
287
- p.putString("manufacturer", product.manufacturer)
288
-
289
- val manufacturerId = product.manufacturerId
290
- if (manufacturerId != null) p.putInt("manufacturerId", manufacturerId) else p.putNull("manufacturerId")
291
-
292
- p.putString("product", product.product)
293
-
294
- val productId = product.productId
295
- if (productId != null) p.putInt("productId", productId) else p.putNull("productId")
254
+ fun toBucketMap(b: com.pensasystems.pensasdk.model.PensaOnDemandReportBucket) =
255
+ Arguments.createMap().apply {
256
+ val arr = Arguments.createArray()
257
+ b.productList.forEach { arr.pushMap(toProductMap(it)) }
258
+ putArray("productList", arr)
259
+ }
296
260
 
297
- p.putString("upc", product.upc)
261
+ fun putBucket(key: String, bucket: com.pensasystems.pensasdk.model.PensaOnDemandReportBucket?) {
262
+ if (bucket == null) result.putNull(key) else result.putMap(key, toBucketMap(bucket))
263
+ }
298
264
 
299
- productsArray.pushMap(p)
265
+ // Fill only requested
266
+ finalReportTypes.distinct().forEach { t ->
267
+ when (t) {
268
+ PensaReportType.FACINGS_SEEN -> putBucket("facingsSeen", report.facingsSeen)
269
+ PensaReportType.FULL_FACINGS -> putBucket("fullFacings", report.fullFacings)
270
+ PensaReportType.FULL_FACINGS_AND_PRODUCT_POSITIONS ->
271
+ putBucket("fullFacingsAndProductPositions", report.fullFacingsAndProductPositions)
272
+ PensaReportType.ITEMS_SEEN -> putBucket("itemsSeen", report.itemsSeen)
273
+ PensaReportType.NEW_PRODUCTS -> putBucket("newProducts", report.newProducts)
274
+ PensaReportType.NEW_PRODUCT_PACKAGING -> putBucket("newProductPackaging", report.newProductPackaging)
275
+ PensaReportType.NO_OOS -> putBucket("noOos", report.noOos)
276
+ PensaReportType.OOS -> putBucket("oos", report.oos)
277
+ PensaReportType.PRODUCT_POSITIONS -> putBucket("productPositions", report.productPositions)
278
+ PensaReportType.SCAN_FAILED -> putBucket("scanFailed", report.scanFailed)
279
+ PensaReportType.SCAN_REJECTED -> putBucket("scanRejected", report.scanRejected)
280
+ PensaReportType.SCAN_SKIPPED -> putBucket("scanSkipped", report.scanSkipped)
300
281
  }
301
- val bucketMap = Arguments.createMap()
302
- bucketMap.putArray("productList", productsArray)
303
- result.putMap("itemsSeen", bucketMap)
304
- } ?: result.putNull("itemsSeen")
305
-
306
- val projectIdVal = report.projectId
307
- if (projectIdVal != null) result.putInt("projectId", projectIdVal) else result.putNull("projectId")
282
+ }
308
283
 
284
+ // Other fields
285
+ report.projectId?.let { result.putInt("projectId", it) } ?: result.putNull("projectId")
309
286
  result.putString("projectName", report.projectName)
310
-
311
- val projectReportIdVal = report.projectReportId
312
- if (projectReportIdVal != null) result.putInt("projectReportId", projectReportIdVal) else result.putNull("projectReportId")
313
-
287
+ report.projectReportId?.let { result.putInt("projectReportId", it) } ?: result.putNull("projectReportId")
314
288
  result.putString("projectReportName", report.projectReportName)
315
289
  result.putString("realogramSignedUrl", report.realogramSignedUrl)
316
-
317
- val shelfIdVal = report.shelfId
318
- if (shelfIdVal != null) result.putInt("shelfId", shelfIdVal) else result.putNull("shelfId")
319
-
290
+ report.shelfId?.let { result.putInt("shelfId", it) } ?: result.putNull("shelfId")
320
291
  result.putString("shelfName", report.shelfName)
321
292
  result.putString("status", report.status)
322
293
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pensasystems/pensa-react-native",
3
- "version": "0.1.0-beta-14",
3
+ "version": "0.1.0-beta-15",
4
4
  "description": "The Pensa Mobile App SDK is a developer toolkit designed to simplify adding Pensa’s capabilities to your mobile applications. It provides pre-built libraries, tools, and APIs to accelerate development and integration, offering streamlined SDK integration, easy initialization, and comprehensive functionality. With the Pensa SDK, you can enhance your app’s features or seamlessly integrate with other services for a cohesive user experience.",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -68,7 +68,6 @@
68
68
  "@release-it/conventional-changelog": "^9.0.2",
69
69
  "@types/jest": "^29.5.5",
70
70
  "@types/react": "^19.0.0",
71
- "commitlint": "^19.6.1",
72
71
  "del-cli": "^5.1.0",
73
72
  "eslint": "^9.22.0",
74
73
  "eslint-config-prettier": "^10.1.1",