Skip to content

Commit

Permalink
feat: added flag to return only non-empty values in the advanced quer…
Browse files Browse the repository at this point in the history
…y (new build lib) (#73)
  • Loading branch information
CarlsCorrea authored Jul 13, 2022
1 parent f6c03b6 commit f6a2958
Show file tree
Hide file tree
Showing 28 changed files with 137 additions and 666 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

## [Version 1.2.6]

- Feat: Implemented option to return only filled blocks in the advanced query. (https://outsystemsrd.atlassian.net/browse/RMET-1714)

## [Version 1.2.5]

- Removed hook that adds swift support and added the plugin as dependecy. (https://outsystemsrd.atlassian.net/browse/RMET-1680)
- Added to the info.plist file a property to identify the background tasks used in the plugin.(https://outsystemsrd.atlassian.net/browse/RMET-1689)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.outsystems.plugins.healthfitness",
"version": "1.2.5",
"version": "1.2.6",
"description": "Health & Fitness cordova plugin for OutSystems applications.",
"keywords": [
"ecosystem:cordova",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin id="com.outsystems.plugins.healthfitness" version="1.2.5" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.outsystems.plugins.healthfitness" version="1.2.6" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>HealthFitness</name>
<description>Health &amp; Fitness cordova plugin for OutSystems applications.</description>
<author>OutSystems Inc</author>
Expand Down
41 changes: 22 additions & 19 deletions src/ios/OSHealthFitness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class OSHealthFitness: CordovaImplementation {
@objc(updateBackgroundJob:)
func updateBackgroundJob(command: CDVInvokedUrlCommand) {
callbackId = command.callbackId

let queryParameters = command.arguments[0] as? String ?? ""
if let parameters = parseUpdateParameters(parameters: queryParameters) {

Expand Down Expand Up @@ -134,15 +134,16 @@ class OSHealthFitness: CordovaImplementation {
timeUnit: "",
operationType: "MOST_RECENT",
mostRecent:true,
onlyFilledBlocks: false,
timeUnitLength: 1) { success, result, error in

if error != nil {
self.sendResult(result: nil, error: error, callBackID: self.callbackId)
} else if success {
self.sendResult(result: result, error: nil, callBackID: self.callbackId)
}
}

}

@objc(deleteBackgroundJob:)
Expand All @@ -157,7 +158,7 @@ class OSHealthFitness: CordovaImplementation {
}
}
}

@objc(listBackgroundJobs:)
func listBackgroundJobs(command: CDVInvokedUrlCommand) {
callbackId = command.callbackId
Expand All @@ -176,7 +177,7 @@ class OSHealthFitness: CordovaImplementation {

let queryParameters = command.arguments[0] as? String ?? ""
if let params = queryParameters.decode(string: queryParameters) as BackgroundJobParameters? {

let variable = params.variable ?? ""
let timeUnitGrouping = params.timeUnitGrouping ?? 0
let condition = params.condition ?? ""
Expand All @@ -187,7 +188,7 @@ class OSHealthFitness: CordovaImplementation {
let value = params.value ?? 0
let notificationHeader = params.notificationHeader ?? ""
let notificationBody = params.notificationBody ?? ""

plugin?.setBackgroundJob(variable: variable,
timeUnit: timeUnit,
timeUnitGrouping: timeUnitGrouping,
Expand All @@ -199,7 +200,7 @@ class OSHealthFitness: CordovaImplementation {
notificationHeader: notificationHeader,
notificationBody: notificationBody)
{ success, result, error in

if error != nil {
self.sendResult(result: nil, error: error, callBackID: self.callbackId)
}
Expand All @@ -209,39 +210,41 @@ class OSHealthFitness: CordovaImplementation {
}
}
}

@objc(getData:)
func getData(command: CDVInvokedUrlCommand) {
callbackId = command.callbackId

let queryParameters = command.arguments[0] as? String ?? ""
if let params = queryParameters.decode(string: queryParameters) as QueryParameters? {

let variable = params.variable ?? ""
let startDate = params.startDate ?? ""
let endDate = params.endDate ?? ""
let timeUnit = params.timeUnit ?? ""
let operationType = params.operationType ?? ""
let timeUnitLength = params.timeUnitLength ?? 1

let onlyFilledBlocks = params.advancedQueryReturnType == AdvancedQueryReturnTypeEnum.removeEmptyDataBlocks.rawValue

plugin?.advancedQuery(variable: variable,
startDate: Date(startDate),
endDate: Date(endDate),
timeUnit: timeUnit,
operationType: operationType,
mostRecent:false,
timeUnitLength:timeUnitLength) { success, result, error in

startDate: Date(startDate),
endDate: Date(endDate),
timeUnit: timeUnit,
operationType: operationType,
mostRecent: false,
onlyFilledBlocks: onlyFilledBlocks,
timeUnitLength: timeUnitLength) { success, result, error in

if error != nil {
self.sendResult(result: nil, error: error, callBackID: self.callbackId)
}
else if success {
self.sendResult(result: result, error: nil, callBackID: self.callbackId)
}
}

}

}

}

}
10 changes: 5 additions & 5 deletions src/ios/frameworks/OSHealthFitnessLib.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>OSHealthFitnessLib.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>OSHealthFitnessLib.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)
// Generated by Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
#ifndef OSHEALTHFITNESSLIB_SWIFT_H
#define OSHEALTHFITNESSLIB_SWIFT_H
#pragma clang diagnostic push
Expand Down Expand Up @@ -184,6 +184,13 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#if !defined(IBSegueAction)
# define IBSegueAction
#endif
#if !defined(SWIFT_EXTERN)
# if defined(__cplusplus)
# define SWIFT_EXTERN extern "C"
# else
# define SWIFT_EXTERN extern
# endif
#endif
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
Expand Down Expand Up @@ -215,7 +222,6 @@ SWIFT_CLASS("_TtC18OSHealthFitnessLib13BackgroundJob")
@end

@class NSString;
@class NSNumber;
@class NSDate;
@class Notification;

Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)
// swift-compiler-version: Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name OSHealthFitnessLib
import BackgroundTasks
import CloudKit
Expand All @@ -12,6 +12,7 @@ import Swift
import UIKit
import UserNotifications
import UserNotificationsUI
import _Concurrency
public enum HealthKitErrors : Swift.Int, Foundation.CustomNSError, Foundation.LocalizedError {
case variableNotAvailable
case variableNotAuthorized
Expand All @@ -38,10 +39,10 @@ public enum HealthKitErrors : Swift.Int, Foundation.CustomNSError, Foundation.Lo
get
}
}
extension String {
extension Swift.String {
public func decode<T>(string: Swift.String) -> T where T : Swift.Decodable
}
extension Encodable {
extension Swift.Encodable {
public func encode() -> Swift.String
}
open class HealthFitnessPlugin {
Expand All @@ -54,10 +55,10 @@ open class HealthFitnessPlugin {
public func requestPermissions(customPermissions: Swift.String, allVariables: Swift.String, fitnessVariables: Swift.String, healthVariables: Swift.String, profileVariables: Swift.String, summaryVariables: Swift.String, completion: @escaping (Swift.Bool, Foundation.NSError?) -> Swift.Void)
public func setBackgroundJob(variable: Swift.String, timeUnit: Swift.String, timeUnitGrouping: Swift.Int, notificationFrequency: Swift.String, notificationFrequencyGrouping: Swift.Int, jobFrequency: Swift.String, condition: Swift.String, value: Swift.Double, notificationHeader: Swift.String, notificationBody: Swift.String, completion: @escaping (Swift.Bool, Swift.String?, Foundation.NSError?) -> Swift.Void)
public func updateBackgroundJob(id: Swift.Int64?, notificationFrequency: Swift.String?, notificationFrequencyGrouping: Swift.Int?, condition: Swift.String?, value: Swift.Double?, notificationHeader: Swift.String?, notificationBody: Swift.String?, isActive: Swift.Bool?, completion: @escaping (Swift.Bool, Foundation.NSError?) -> Swift.Void)
public func advancedQuery(variable: Swift.String, startDate: Foundation.Date, endDate: Foundation.Date, timeUnit: Swift.String, operationType: Swift.String, mostRecent: Swift.Bool, timeUnitLength: Swift.Int, completion: @escaping (Swift.Bool, Swift.String?, Foundation.NSError?) -> Swift.Void)
public func advancedQuery(variable: Swift.String, startDate: Foundation.Date, endDate: Foundation.Date, timeUnit: Swift.String, operationType: Swift.String, mostRecent: Swift.Bool, onlyFilledBlocks: Swift.Bool, timeUnitLength: Swift.Int, completion: @escaping (Swift.Bool, Swift.String?, Foundation.NSError?) -> Swift.Void)
@objc deinit
}
extension Date {
extension Foundation.Date {
public init(_ dateString: Swift.String)
public static func - (recent: Foundation.Date, previous: Foundation.Date) -> (year: Swift.Int?, month: Swift.Int?, week: Swift.Int?, day: Swift.Int?, hour: Swift.Int?, minute: Swift.Int?, second: Swift.Int?)
public func startOfHour() -> Foundation.Date
Expand All @@ -84,11 +85,20 @@ public class BackgroundJobParameters : Swift.Codable {
public func encode(to encoder: Swift.Encoder) throws
required public init(from decoder: Swift.Decoder) throws
}
public enum AdvancedQueryReturnTypeEnum : Swift.String {
case allData, removeEmptyDataBlocks
public init?(rawValue: Swift.String)
public typealias RawValue = Swift.String
public var rawValue: Swift.String {
get
}
}
@_hasMissingDesignatedInitializers public class QueryParameters : Swift.Codable {
final public let variable: Swift.String?
final public let startDate: Swift.String?, endDate: Swift.String?
final public let timeUnit: Swift.String?, operationType: Swift.String?
final public let timeUnitLength: Swift.Int?
final public let advancedQueryReturnType: Swift.String?
@objc deinit
public func encode(to encoder: Swift.Encoder) throws
required public init(from decoder: Swift.Decoder) throws
Expand All @@ -97,7 +107,7 @@ public class BackgroundJobParameters : Swift.Codable {
@objc override dynamic public init(entity: CoreData.NSEntityDescription, insertInto context: CoreData.NSManagedObjectContext?)
@objc deinit
}
extension BackgroundJob {
extension OSHealthFitnessLib.BackgroundJob {
@nonobjc public class func fetchRequest() -> CoreData.NSFetchRequest<OSHealthFitnessLib.BackgroundJob>
@objc @NSManaged dynamic public var comparision: Swift.String? {
@objc get
Expand Down Expand Up @@ -152,7 +162,7 @@ extension BackgroundJob {
@objc override dynamic public init(entity: CoreData.NSEntityDescription, insertInto context: CoreData.NSManagedObjectContext?)
@objc deinit
}
extension Notification {
extension OSHealthFitnessLib.Notification {
@nonobjc public class func fetchRequest() -> CoreData.NSFetchRequest<OSHealthFitnessLib.Notification>
@objc @NSManaged dynamic public var body: Swift.String? {
@objc get
Expand All @@ -174,3 +184,6 @@ extension Notification {
extension OSHealthFitnessLib.HealthKitErrors : Swift.Equatable {}
extension OSHealthFitnessLib.HealthKitErrors : Swift.Hashable {}
extension OSHealthFitnessLib.HealthKitErrors : Swift.RawRepresentable {}
extension OSHealthFitnessLib.AdvancedQueryReturnTypeEnum : Swift.Equatable {}
extension OSHealthFitnessLib.AdvancedQueryReturnTypeEnum : Swift.Hashable {}
extension OSHealthFitnessLib.AdvancedQueryReturnTypeEnum : Swift.RawRepresentable {}
Binary file not shown.
Loading

0 comments on commit f6a2958

Please sign in to comment.