@pensasystems/pensa-react-native 0.1.0-beta-4 → 0.1.0-beta-6

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.
@@ -21,5 +21,5 @@ Pod::Spec.new do |s|
21
21
  s.dependency "React-Core"
22
22
  end
23
23
 
24
- s.dependency "PensaSdk", "~> 1.0.5"
24
+ s.dependency "PensaSdk", "~> 1.0.7"
25
25
  end
@@ -143,8 +143,8 @@ class PensaSdkReactNative: NSObject {
143
143
  // metadata
144
144
  if let metadata = status.metadata {
145
145
  dict["metadata"] = [
146
- "guid": metadata.guid ?? NSNull(),
147
- "serverUploadStarted": metadata.serverUploadStarted ?? NSNull()
146
+ "guid": (metadata.guid as Any?) ?? NSNull(),
147
+ "serverUploadStarted": (metadata.serverUploadStarted as Any?) ?? NSNull()
148
148
  ]
149
149
  } else {
150
150
  dict["metadata"] = NSNull()
@@ -161,59 +161,60 @@ class PensaSdkReactNative: NSObject {
161
161
  )
162
162
  }
163
163
 
164
- @objc(fetchOnDemandReports:projectId:withResolver:withRejecter:)
165
- func fetchOnDemandReports(
166
- scanId: NSNumber,
167
- projectId: NSNumber?,
168
- resolve: @escaping RCTPromiseResolveBlock,
169
- reject: @escaping RCTPromiseRejectBlock
170
- ) {
171
-
172
- Pensa.shared.fetchOnDemandReports(
173
- scanId: scanId.intValue,
174
- projectId: projectId?.intValue,
175
- onSuccess: { report in
176
- var result: [String: Any] = [:]
177
-
178
- // facingsSeen bucket
179
- if let bucket = report.facingsSeen {
180
- let products = bucket.productList.map { product -> [String: Any] in
181
- return [
182
- "brand": product.brand ?? NSNull(),
183
- "brandId": product.brandId as Any,
184
- "category": product.category ?? NSNull(),
185
- "categoryId": product.categoryId as Any,
186
- "facings": product.facings as Any,
187
- "manufacturer": product.manufacturer ?? NSNull(),
188
- "manufacturerId": product.manufacturerId as Any,
189
- "product": product.product ?? NSNull(),
190
- "productId": product.productId as Any,
191
- "upc": product.upc ?? NSNull()
192
- ]
193
- }
194
-
195
- result["facingsSeen"] = [
196
- "productList": products
197
- ]
198
- } else {
199
- result["facingsSeen"] = NSNull()
200
- }
164
+ @objc(fetchOnDemandReports:projectId:withResolver:withRejecter:)
165
+ func fetchOnDemandReports(
166
+ scanId: NSNumber,
167
+ projectId: NSNumber?,
168
+ resolve: @escaping RCTPromiseResolveBlock,
169
+ reject: @escaping RCTPromiseRejectBlock
170
+ ) {
171
+
172
+ Pensa.shared.fetchOnDemandReports(
173
+ scanId: scanId.intValue,
174
+ projectId: projectId?.intValue,
175
+ onSuccess: { report in
176
+
177
+ func rn(_ value: Any?) -> Any { value ?? NSNull() }
178
+
179
+ var result: [String: Any] = [
180
+ "shelfId": rn(report.shelfId),
181
+ "shelfName": rn(report.shelfName),
182
+ "projectId": rn(report.projectId),
183
+ "projectName": rn(report.projectName),
184
+ "projectReportId": rn(report.projectReportId),
185
+ "projectReportName": rn(report.projectReportName)
186
+ ]
187
+
188
+ if let bucket = report.facingsSeen?.report {
189
+ let products: [[String: Any]] = bucket.productList.map { product in
190
+ return [
191
+ "brand": rn(product.brand),
192
+ "brandId": rn(product.brandId),
193
+ "category": rn(product.category),
194
+ "categoryId": rn(product.categoryId),
195
+ "facings": rn(product.facings),
196
+ "manufacturer": rn(product.manufacturer),
197
+ "manufacturerId": rn(product.manufacturerId),
198
+ "product": rn(product.product),
199
+ "productId": rn(product.productId),
200
+ "upc": rn(product.upc)
201
+ ]
202
+ }
201
203
 
202
- // Scalar fields
203
- result["projectId"] = report.projectId as Any
204
- result["projectName"] = report.projectName ?? NSNull()
205
- result["projectReportId"] = report.projectReportId as Any
206
- result["projectReportName"] = report.projectReportName ?? NSNull()
207
- result["shelfId"] = report.shelfId as Any
208
- result["shelfName"] = report.shelfName ?? NSNull()
204
+ result["facingsSeen"] = [
205
+ "productList": products
206
+ ]
207
+ } else {
208
+ result["facingsSeen"] = NSNull()
209
+ }
209
210
 
210
- resolve(result)
211
- },
212
- onError: { error in
213
- reject("FETCH_ON_DEMAND_REPORTS_FAILED", error.localizedDescription, error)
214
- }
215
- )
211
+ resolve(result)
212
+ },
213
+ onError: { error in
214
+ reject("FETCH_ON_DEMAND_REPORTS_FAILED", error.localizedDescription, error)
216
215
  }
216
+ )
217
+ }
217
218
 
218
219
  @objc(fetchProductImageBase64:withResolver:withRejecter:)
219
220
  func fetchProductImageBase64(productId: NSNumber,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pensasystems/pensa-react-native",
3
- "version": "0.1.0-beta-4",
3
+ "version": "0.1.0-beta-6",
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",