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

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.6"
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,69 @@ 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
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
+ ]
183
+
184
+ if let item = report.facingsSeen {
185
+ var itemDict: [String: Any] = [
186
+ "projectId": rn(item.projectId),
187
+ "projectName": rn(item.projectName),
188
+ "projectReportId": rn(item.projectReportId),
189
+ "projectReportName": rn(item.projectReportName)
190
+ ]
191
+
192
+ if let bucket = item.report {
193
+ let products: [[String: Any]] = bucket.productList.map { product in
181
194
  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()
195
+ "brand": rn(product.brand),
196
+ "brandId": rn(product.brandId),
197
+ "category": rn(product.category),
198
+ "categoryId": rn(product.categoryId),
199
+ "facings": rn(product.facings),
200
+ "manufacturer": rn(product.manufacturer),
201
+ "manufacturerId": rn(product.manufacturerId),
202
+ "product": rn(product.product),
203
+ "productId": rn(product.productId),
204
+ "upc": rn(product.upc)
192
205
  ]
193
206
  }
194
207
 
195
- result["facingsSeen"] = [
208
+ itemDict["report"] = [
196
209
  "productList": products
197
210
  ]
198
211
  } else {
199
- result["facingsSeen"] = NSNull()
212
+ itemDict["report"] = NSNull()
200
213
  }
201
214
 
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()
209
-
210
- resolve(result)
211
- },
212
- onError: { error in
213
- reject("FETCH_ON_DEMAND_REPORTS_FAILED", error.localizedDescription, error)
215
+ result["facingsSeen"] = itemDict
216
+ } else {
217
+ result["facingsSeen"] = NSNull()
214
218
  }
215
- )
216
- }
219
+
220
+ resolve(result)
221
+ },
222
+ onError: { error in
223
+ reject("FETCH_ON_DEMAND_REPORTS_FAILED", error.localizedDescription, error)
224
+ }
225
+ )
226
+ }
217
227
 
218
228
  @objc(fetchProductImageBase64:withResolver:withRejecter:)
219
229
  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-5",
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",