@dashx/react-native 1.0.6 → 1.0.8

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.
@@ -1,89 +0,0 @@
1
- @rem
2
- @rem Copyright 2015 the original author or authors.
3
- @rem
4
- @rem Licensed under the Apache License, Version 2.0 (the "License");
5
- @rem you may not use this file except in compliance with the License.
6
- @rem You may obtain a copy of the License at
7
- @rem
8
- @rem https://www.apache.org/licenses/LICENSE-2.0
9
- @rem
10
- @rem Unless required by applicable law or agreed to in writing, software
11
- @rem distributed under the License is distributed on an "AS IS" BASIS,
12
- @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- @rem See the License for the specific language governing permissions and
14
- @rem limitations under the License.
15
- @rem
16
-
17
- @if "%DEBUG%" == "" @echo off
18
- @rem ##########################################################################
19
- @rem
20
- @rem Gradle startup script for Windows
21
- @rem
22
- @rem ##########################################################################
23
-
24
- @rem Set local scope for the variables with windows NT shell
25
- if "%OS%"=="Windows_NT" setlocal
26
-
27
- set DIRNAME=%~dp0
28
- if "%DIRNAME%" == "" set DIRNAME=.
29
- set APP_BASE_NAME=%~n0
30
- set APP_HOME=%DIRNAME%
31
-
32
- @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33
- for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34
-
35
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36
- set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37
-
38
- @rem Find java.exe
39
- if defined JAVA_HOME goto findJavaFromJavaHome
40
-
41
- set JAVA_EXE=java.exe
42
- %JAVA_EXE% -version >NUL 2>&1
43
- if "%ERRORLEVEL%" == "0" goto execute
44
-
45
- echo.
46
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47
- echo.
48
- echo Please set the JAVA_HOME variable in your environment to match the
49
- echo location of your Java installation.
50
-
51
- goto fail
52
-
53
- :findJavaFromJavaHome
54
- set JAVA_HOME=%JAVA_HOME:"=%
55
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56
-
57
- if exist "%JAVA_EXE%" goto execute
58
-
59
- echo.
60
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61
- echo.
62
- echo Please set the JAVA_HOME variable in your environment to match the
63
- echo location of your Java installation.
64
-
65
- goto fail
66
-
67
- :execute
68
- @rem Setup the command line
69
-
70
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71
-
72
-
73
- @rem Execute Gradle
74
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75
-
76
- :end
77
- @rem End local scope for the variables with windows NT shell
78
- if "%ERRORLEVEL%"=="0" goto mainEnd
79
-
80
- :fail
81
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82
- rem the _cmd.exe /c_ return code!
83
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84
- exit /b 1
85
-
86
- :mainEnd
87
- if "%OS%"=="Windows_NT" endlocal
88
-
89
- :omega
@@ -1,7 +0,0 @@
1
- //
2
- // Use this file to import your target's public headers that you would like to expose to Swift.
3
- //
4
-
5
- #import "React/RCTBridgeModule.h"
6
- #import "React/RCTBridge.h"
7
- #import "React/RCTEventEmitter.h"
package/ios/DashX.swift DELETED
@@ -1,174 +0,0 @@
1
- import Foundation
2
- import DashX
3
-
4
- typealias CBU = CallbackUtils
5
-
6
- @objc(DashXReactNative)
7
- class DashXReactNative: RCTEventEmitter {
8
- private var dashXClient = DashX
9
-
10
- override init() {
11
- super.init()
12
- DashXEventEmitter.instance.registerEventEmitter(eventEmitter: self)
13
- }
14
-
15
- override func supportedEvents() -> [String] {
16
- return ["messageReceived"]
17
- }
18
-
19
- @objc
20
- func configure(_ options: NSDictionary) {
21
- let publicKey = options["publicKey"] as! String,
22
- baseURI = options["baseURI"] as? String,
23
- targetEnvironment = options["targetEnvironment"] as? String
24
-
25
- dashXClient.configure(withPublicKey: publicKey,
26
- baseURI: baseURI,
27
- targetEnvironment: targetEnvironment)
28
- }
29
-
30
- @objc(identify:)
31
- func identify(_ options: NSDictionary) {
32
- try? dashXClient.identify(withOptions: options)
33
- }
34
-
35
- @objc(setIdentity:token:)
36
- func setIdentity(_ uid: String, _ token: String) {
37
- dashXClient.setIdentity(uid: uid, token: token)
38
- }
39
-
40
- @objc
41
- func reset() {
42
- dashXClient.reset()
43
- }
44
-
45
- @objc(track:data:)
46
- func track(_ event: String, _ data: NSDictionary?) {
47
- dashXClient.track(event, withData: data)
48
- }
49
-
50
- @objc(screen:data:)
51
- func screen(_ screenName: String, _ data: NSDictionary?) {
52
- dashXClient.screen(screenName, withData: data)
53
- }
54
-
55
- @objc(searchContent:options:resolver:rejecter:)
56
- func searchContent(_ contentType: String, _ options: NSDictionary?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
57
- let optionsDictionary = options as? [String: Any]
58
-
59
- dashXClient.searchContent(
60
- contentType: contentType,
61
- returnType: optionsDictionary?["returnType"] as! String? ?? "all",
62
- filter: optionsDictionary?["filter"] as! NSDictionary?,
63
- order: optionsDictionary?["order"] as! NSDictionary?,
64
- limit: optionsDictionary?["limit"] as! Int?,
65
- preview: optionsDictionary?["preview"] as! Bool?,
66
- language: optionsDictionary?["language"] as! String?,
67
- fields: optionsDictionary?["fields"] as! [String]?,
68
- include: optionsDictionary?["include"] as! [String]?,
69
- exclude: optionsDictionary?["exclude"] as! [String]?,
70
- successCallback: CBU.resolveToSuccessCallback(resolve),
71
- failureCallback: CBU.rejectToFailureCallback(reject)
72
- )
73
- }
74
-
75
- @objc(fetchContent:options:resolver:rejecter:)
76
- func fetchContent(_ urn: String, _ options: NSDictionary?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
77
- let optionsDictionary = options as? [String: Any]
78
- let urnArray = urn.split{$0 == "/"}.map(String.init)
79
-
80
- dashXClient.fetchContent(
81
- contentType: urnArray[0],
82
- content: urnArray[1],
83
- preview: optionsDictionary?["preview"] as! Bool?,
84
- language: optionsDictionary?["language"] as! String?,
85
- fields: optionsDictionary?["fields"] as! [String]?,
86
- include: optionsDictionary?["include"] as! [String]?,
87
- exclude: optionsDictionary?["exclude"] as! [String]?,
88
- successCallback: CBU.resolveToSuccessCallback(resolve),
89
- failureCallback: CBU.rejectToFailureCallback(reject)
90
- )
91
- }
92
-
93
- @objc(addItemToCart:pricingId:quantity:reset:custom:resolver:rejecter:)
94
- func addItemToCart(_ itemId: String, _ pricingId: String, _ quantity: String, _ reset: Bool, _ custom: NSDictionary?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
95
- dashXClient.addItemToCart(
96
- itemId: itemId,
97
- pricingId: pricingId,
98
- quantity: quantity,
99
- reset: reset,
100
- custom: custom,
101
- successCallback: CBU.resolveToSuccessCallback(resolve),
102
- failureCallback: CBU.rejectToFailureCallback(reject)
103
- )
104
- }
105
-
106
- @objc(fetchCart:rejecter:)
107
- func fetchCart(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
108
- dashXClient.fetchCart(
109
- successCallback: CBU.resolveToSuccessCallback(resolve),
110
- failureCallback: CBU.rejectToFailureCallback(reject)
111
- )
112
- }
113
-
114
- @objc(fetchStoredPreferences:rejecter:)
115
- func fetchStoredPreferences(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
116
- dashXClient.fetchStoredPreferences(
117
- successCallback: CBU.resolveToSuccessCallback(resolve),
118
- failureCallback: CBU.rejectToFailureCallback(reject)
119
- )
120
- }
121
-
122
- @objc(saveStoredPreferences:resolve:rejecter:)
123
- func saveStoredPreferences(_ preferenceData: NSDictionary, _ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
124
- dashXClient.saveStoredPreferences(
125
- preferenceData: preferenceData,
126
- successCallback: CBU.resolveToSuccessCallback(resolve),
127
- failureCallback: CBU.rejectToFailureCallback(reject)
128
- )
129
- }
130
-
131
-
132
- @objc(uploadExternalAsset:externalColumnId:resolver:rejecter:)
133
- func uploadExternalAsset(_ file: NSDictionary, _ externalColumnId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
134
- if let fileDictionary = file as? [String: Any], let fileURI = fileDictionary["uri"] as? String {
135
- // Remove unnecessary file:/// prefix for correct URL resolution
136
- let normalizedURI = fileURI.replacingOccurrences(of: "file:///", with: "")
137
-
138
- dashXClient.uploadExternalAsset(
139
- fileURL: URL(fileURLWithPath: normalizedURI),
140
- externalColumnId: externalColumnId,
141
- successCallback: CBU.resolveToSuccessCallback(resolve),
142
- failureCallback: CBU.rejectToFailureCallback(reject)
143
- )
144
- }
145
- }
146
-
147
- @objc(externalAsset:resolver:rejecter:)
148
- func externalAsset(_ assetId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
149
- dashXClient.externalAsset(
150
- assetId: assetId,
151
- successCallback: CBU.resolveToSuccessCallback(resolve),
152
- failureCallback: CBU.rejectToFailureCallback(reject)
153
- )
154
- }
155
-
156
- @objc
157
- func subscribe() {
158
- dashXClient.subscribe()
159
- }
160
- }
161
-
162
- class CallbackUtils {
163
- static func resolveToSuccessCallback(_ resolve: @escaping RCTPromiseResolveBlock) -> SuccessCallback {
164
- return resolve
165
- }
166
-
167
- static func rejectToFailureCallback(_ reject: @escaping RCTPromiseRejectBlock) -> FailureCallback {
168
- let result: FailureCallback = { (error) in
169
- reject("\((error as NSError).code)", error.localizedDescription, error)
170
- }
171
-
172
- return result
173
- }
174
- }
@@ -1,25 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTEventEmitter.h>
3
-
4
- @interface RCT_EXTERN_MODULE(DashXReactNative, RCTEventEmitter)
5
- + (BOOL)requiresMainQueueSetup
6
- {
7
- return NO;
8
- }
9
-
10
- RCT_EXTERN_METHOD(configure:(NSDictionary *)options)
11
- RCT_EXTERN_METHOD(identify:)
12
- RCT_EXTERN_METHOD(setIdentity:(nonnull NSString *)uid token:(nonnull NSString *)token)
13
- RCT_EXTERN_METHOD(reset)
14
- RCT_EXTERN_METHOD(track:(NSString *)event data:(nullable NSDictionary *)data)
15
- RCT_EXTERN_METHOD(screen:(NSString *)event data:(nullable NSDictionary *)data)
16
- RCT_EXTERN_METHOD(searchContent:(NSString *)contentType options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
17
- RCT_EXTERN_METHOD(fetchContent:(NSString *)urn options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
18
- RCT_EXTERN_METHOD(addItemToCart:(NSString *)itemId pricingId:(NSString *)pricingId quantity:(NSString *)quantity reset:(BOOL)reset custom:(NSDictionary *)custom resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
19
- RCT_EXTERN_METHOD(fetchCart:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
20
- RCT_EXTERN_METHOD(fetchStoredPreferences:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
21
- RCT_EXTERN_METHOD(saveStoredPreferences:(NSDictionary *)preferenceData resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
22
- RCT_EXTERN_METHOD(uploadExternalAsset:(NSDictionary *)file externalColumnId:(NSString *)externalColumnId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
23
- RCT_EXTERN_METHOD(externalAsset:(NSString *)assetId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
24
- RCT_EXTERN_METHOD(subscribe)
25
- @end