react-native-altibbi 0.1.0
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.
- package/LICENSE +20 -0
- package/README.md +190 -0
- package/android/build.gradle +104 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/altibbi/AltibbiModule.kt +18 -0
- package/android/src/main/java/com/altibbi/AltibbiPackage.kt +18 -0
- package/android/src/main/java/com/altibbi/OTCustomAudioDevice.java +1146 -0
- package/android/src/main/java/com/altibbi/OTPublisherLayout.java +61 -0
- package/android/src/main/java/com/altibbi/OTPublisherViewManager.java +30 -0
- package/android/src/main/java/com/altibbi/OTRN.java +101 -0
- package/android/src/main/java/com/altibbi/OTScreenCapturer.java +120 -0
- package/android/src/main/java/com/altibbi/OTSessionManager.java +1281 -0
- package/android/src/main/java/com/altibbi/OTSubscriberLayout.java +68 -0
- package/android/src/main/java/com/altibbi/OTSubscriberViewManager.java +30 -0
- package/android/src/main/java/com/altibbi/Socket.kt +294 -0
- package/android/src/main/java/com/altibbi/SocketEventEmitter.kt +25 -0
- package/android/src/main/java/com/altibbi/utils/EventUtils.java +189 -0
- package/android/src/main/java/com/altibbi/utils/Utils.java +135 -0
- package/ios/Altibbi-Bridging-Header.h +6 -0
- package/ios/Altibbi.mm +10 -0
- package/ios/Altibbi.swift +4 -0
- package/ios/OTCustomAudioDriver.swift +696 -0
- package/ios/OTPublisher.m +16 -0
- package/ios/OTPublisherManager.swift +21 -0
- package/ios/OTPublisherView.swift +28 -0
- package/ios/OTRN.swift +27 -0
- package/ios/OTScreenCapture.h +27 -0
- package/ios/OTScreenCapture.m +171 -0
- package/ios/OTSessionManager.m +127 -0
- package/ios/OTSessionManager.swift +866 -0
- package/ios/OTSubscriber.m +15 -0
- package/ios/OTSubscriberManager.swift +21 -0
- package/ios/OTSubscriberView.swift +29 -0
- package/ios/OpenTokReactNative.h +13 -0
- package/ios/OpenTokReactNative.m +13 -0
- package/ios/SocketReactNative.m +38 -0
- package/ios/SocketReactNative.swift +276 -0
- package/ios/Utils/EventUtils.swift +143 -0
- package/ios/Utils/Utils.swift +126 -0
- package/lib/commonjs/connection.js +200 -0
- package/lib/commonjs/connection.js.map +1 -0
- package/lib/commonjs/data.js +12 -0
- package/lib/commonjs/data.js.map +1 -0
- package/lib/commonjs/index.js +275 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/scoket.js +245 -0
- package/lib/commonjs/scoket.js.map +1 -0
- package/lib/commonjs/service.js +21 -0
- package/lib/commonjs/service.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/video/OT.js +57 -0
- package/lib/commonjs/video/OT.js.map +1 -0
- package/lib/commonjs/video/OTError.js +17 -0
- package/lib/commonjs/video/OTError.js.map +1 -0
- package/lib/commonjs/video/OTPublisher.js +171 -0
- package/lib/commonjs/video/OTPublisher.js.map +1 -0
- package/lib/commonjs/video/OTSession.js +205 -0
- package/lib/commonjs/video/OTSession.js.map +1 -0
- package/lib/commonjs/video/OTSubscriber.js +185 -0
- package/lib/commonjs/video/OTSubscriber.js.map +1 -0
- package/lib/commonjs/video/contexts/OTContext.js +11 -0
- package/lib/commonjs/video/contexts/OTContext.js.map +1 -0
- package/lib/commonjs/video/helpers/OTHelper.js +92 -0
- package/lib/commonjs/video/helpers/OTHelper.js.map +1 -0
- package/lib/commonjs/video/helpers/OTPublisherHelper.js +117 -0
- package/lib/commonjs/video/helpers/OTPublisherHelper.js.map +1 -0
- package/lib/commonjs/video/helpers/OTSessionHelper.js +206 -0
- package/lib/commonjs/video/helpers/OTSessionHelper.js.map +1 -0
- package/lib/commonjs/video/helpers/OTSubscriberHelper.js +121 -0
- package/lib/commonjs/video/helpers/OTSubscriberHelper.js.map +1 -0
- package/lib/commonjs/video/index.js +42 -0
- package/lib/commonjs/video/index.js.map +1 -0
- package/lib/commonjs/video/views/OTPublisherView.js +26 -0
- package/lib/commonjs/video/views/OTPublisherView.js.map +1 -0
- package/lib/commonjs/video/views/OTSubscriberView.js +25 -0
- package/lib/commonjs/video/views/OTSubscriberView.js.map +1 -0
- package/lib/module/connection.js +180 -0
- package/lib/module/connection.js.map +1 -0
- package/lib/module/data.js +6 -0
- package/lib/module/data.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/scoket.js +235 -0
- package/lib/module/scoket.js.map +1 -0
- package/lib/module/service.js +14 -0
- package/lib/module/service.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/video/OT.js +49 -0
- package/lib/module/video/OT.js.map +1 -0
- package/lib/module/video/OTError.js +10 -0
- package/lib/module/video/OTError.js.map +1 -0
- package/lib/module/video/OTPublisher.js +162 -0
- package/lib/module/video/OTPublisher.js.map +1 -0
- package/lib/module/video/OTSession.js +195 -0
- package/lib/module/video/OTSession.js.map +1 -0
- package/lib/module/video/OTSubscriber.js +175 -0
- package/lib/module/video/OTSubscriber.js.map +1 -0
- package/lib/module/video/contexts/OTContext.js +4 -0
- package/lib/module/video/contexts/OTContext.js.map +1 -0
- package/lib/module/video/helpers/OTHelper.js +82 -0
- package/lib/module/video/helpers/OTHelper.js.map +1 -0
- package/lib/module/video/helpers/OTPublisherHelper.js +110 -0
- package/lib/module/video/helpers/OTPublisherHelper.js.map +1 -0
- package/lib/module/video/helpers/OTSessionHelper.js +195 -0
- package/lib/module/video/helpers/OTSessionHelper.js.map +1 -0
- package/lib/module/video/helpers/OTSubscriberHelper.js +112 -0
- package/lib/module/video/helpers/OTSubscriberHelper.js.map +1 -0
- package/lib/module/video/index.js +7 -0
- package/lib/module/video/index.js.map +1 -0
- package/lib/module/video/views/OTPublisherView.js +18 -0
- package/lib/module/video/views/OTPublisherView.js.map +1 -0
- package/lib/module/video/views/OTSubscriberView.js +17 -0
- package/lib/module/video/views/OTSubscriberView.js.map +1 -0
- package/lib/typescript/src/connection.d.ts +40 -0
- package/lib/typescript/src/connection.d.ts.map +1 -0
- package/lib/typescript/src/data.d.ts +7 -0
- package/lib/typescript/src/data.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/scoket.d.ts +100 -0
- package/lib/typescript/src/scoket.d.ts.map +1 -0
- package/lib/typescript/src/service.d.ts +9 -0
- package/lib/typescript/src/service.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +22 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +178 -0
- package/react-native-altibbi.podspec +46 -0
- package/src/connection.ts +255 -0
- package/src/data.ts +21 -0
- package/src/index.tsx +80 -0
- package/src/scoket.ts +365 -0
- package/src/service.ts +20 -0
- package/src/types.ts +22 -0
- package/src/video/OT.js +65 -0
- package/src/video/OTError.js +14 -0
- package/src/video/OTPublisher.js +193 -0
- package/src/video/OTSession.js +168 -0
- package/src/video/OTSubscriber.js +148 -0
- package/src/video/contexts/OTContext.js +5 -0
- package/src/video/helpers/OTHelper.js +91 -0
- package/src/video/helpers/OTPublisherHelper.js +122 -0
- package/src/video/helpers/OTSessionHelper.js +233 -0
- package/src/video/helpers/OTSubscriberHelper.js +125 -0
- package/src/video/index.js +13 -0
- package/src/video/views/OTPublisherView.js +19 -0
- package/src/video/views/OTSubscriberView.js +18 -0
package/package.json
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-altibbi",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Altibbi Sdk",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "@types/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"*.podspec",
|
|
17
|
+
"!ios/build",
|
|
18
|
+
"!android/build",
|
|
19
|
+
"!android/gradle",
|
|
20
|
+
"!android/gradlew",
|
|
21
|
+
"!android/gradlew.bat",
|
|
22
|
+
"!android/local.properties",
|
|
23
|
+
"!**/__tests__",
|
|
24
|
+
"!**/__fixtures__",
|
|
25
|
+
"!**/__mocks__",
|
|
26
|
+
"!**/.*"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"example": "yarn workspace react-native-altibbi-example",
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib"
|
|
34
|
+
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"react-native",
|
|
38
|
+
"ios",
|
|
39
|
+
"android"
|
|
40
|
+
],
|
|
41
|
+
"repository": "https://github.com/altibbi-com/altibb-react-native",
|
|
42
|
+
"author": "Altibbi Tech team <mobile@altibbi.com> (https://github.com/altibbi-com/altibb-react-native)",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/altibbi-com/altibb-react-native/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/altibbi-com/altibb-react-native/readme",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"registry": "https://registry.npmjs.org/"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
53
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
54
|
+
"@react-native/eslint-config": "^0.72.2",
|
|
55
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
56
|
+
"@types/jest": "^28.1.2",
|
|
57
|
+
"@types/react": "~17.0.21",
|
|
58
|
+
"@types/react-native": "0.70.0",
|
|
59
|
+
"babel-jest": "26.6.3",
|
|
60
|
+
"commitlint": "^17.0.2",
|
|
61
|
+
"del-cli": "^5.0.0",
|
|
62
|
+
"eslint": "8.55.0",
|
|
63
|
+
"eslint-config-airbnb": "19.0.4",
|
|
64
|
+
"eslint-config-prettier": "^8.5.0",
|
|
65
|
+
"eslint-plugin-import": "2.29.0",
|
|
66
|
+
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
67
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
68
|
+
"eslint-plugin-react": "7.33.2",
|
|
69
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
70
|
+
"jest": "^28.1.1",
|
|
71
|
+
"metro-react-native-babel-preset": "0.77.0",
|
|
72
|
+
"pod-install": "^0.1.0",
|
|
73
|
+
"prettier": "^2.0.5",
|
|
74
|
+
"react": "18.2.0",
|
|
75
|
+
"react-native": "0.72.7",
|
|
76
|
+
"react-native-builder-bob": "^0.20.0",
|
|
77
|
+
"react-test-renderer": "18.2.0",
|
|
78
|
+
"release-it": "^15.0.0",
|
|
79
|
+
"turbo": "^1.10.7",
|
|
80
|
+
"typescript": "^5.0.2"
|
|
81
|
+
},
|
|
82
|
+
"resolutions": {
|
|
83
|
+
"@types/react": "17.0.21"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"react": "*",
|
|
87
|
+
"react-native": "*"
|
|
88
|
+
},
|
|
89
|
+
"workspaces": [
|
|
90
|
+
"example"
|
|
91
|
+
],
|
|
92
|
+
"packageManager": "yarn@3.6.1",
|
|
93
|
+
"engines": {
|
|
94
|
+
"node": ">= 16.0.0"
|
|
95
|
+
},
|
|
96
|
+
"jest": {
|
|
97
|
+
"preset": "react-native",
|
|
98
|
+
"modulePathIgnorePatterns": [
|
|
99
|
+
"<rootDir>/example/node_modules",
|
|
100
|
+
"<rootDir>/lib/"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"commitlint": {
|
|
104
|
+
"extends": [
|
|
105
|
+
"@commitlint/config-conventional"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"release-it": {
|
|
109
|
+
"git": {
|
|
110
|
+
"commitMessage": "chore: release ${version}",
|
|
111
|
+
"tagName": "v${version}"
|
|
112
|
+
},
|
|
113
|
+
"npm": {
|
|
114
|
+
"publish": true
|
|
115
|
+
},
|
|
116
|
+
"github": {
|
|
117
|
+
"release": true
|
|
118
|
+
},
|
|
119
|
+
"plugins": {
|
|
120
|
+
"@release-it/conventional-changelog": {
|
|
121
|
+
"preset": "angular"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"eslintConfig": {
|
|
126
|
+
"root": true,
|
|
127
|
+
"extends": [
|
|
128
|
+
"@react-native",
|
|
129
|
+
"prettier"
|
|
130
|
+
],
|
|
131
|
+
"rules": {
|
|
132
|
+
"prettier/prettier": [
|
|
133
|
+
"error",
|
|
134
|
+
{
|
|
135
|
+
"quoteProps": "consistent",
|
|
136
|
+
"singleQuote": true,
|
|
137
|
+
"tabWidth": 2,
|
|
138
|
+
"trailingComma": "es5",
|
|
139
|
+
"useTabs": false
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"eslintIgnore": [
|
|
145
|
+
"node_modules/",
|
|
146
|
+
"lib/"
|
|
147
|
+
],
|
|
148
|
+
"prettier": {
|
|
149
|
+
"quoteProps": "consistent",
|
|
150
|
+
"singleQuote": true,
|
|
151
|
+
"tabWidth": 2,
|
|
152
|
+
"trailingComma": "es5",
|
|
153
|
+
"useTabs": false
|
|
154
|
+
},
|
|
155
|
+
"dependencies": {
|
|
156
|
+
"@sendbird/chat": "4.10.3",
|
|
157
|
+
"axios": "1.6.2",
|
|
158
|
+
"deprecated-react-native-prop-types": "5.0.0",
|
|
159
|
+
"flow-bin": "0.223.3",
|
|
160
|
+
"prop-types": "15.8.1",
|
|
161
|
+
"underscore": "1.13.6",
|
|
162
|
+
"uuid": "^3.4.0"
|
|
163
|
+
},
|
|
164
|
+
"react-native-builder-bob": {
|
|
165
|
+
"source": "src",
|
|
166
|
+
"output": "lib",
|
|
167
|
+
"targets": [
|
|
168
|
+
"commonjs",
|
|
169
|
+
"module",
|
|
170
|
+
[
|
|
171
|
+
"typescript",
|
|
172
|
+
{
|
|
173
|
+
"project": "tsconfig.build.json"
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "react-native-altibbi"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => "13.0" }
|
|
15
|
+
s.swift_version = "4.2"
|
|
16
|
+
s.source = { :git => "https://bitbucket.org/altibbi/react-native-altibbi-sdk/src/master/.git", :tag => "#{s.version}" }
|
|
17
|
+
s.dependency 'React'
|
|
18
|
+
s.dependency 'PusherSwift', '~> 10.1.1'
|
|
19
|
+
#s.dependency 'OpenTok','~> 2.21.3'
|
|
20
|
+
s.dependency 'OTXCFramework','2.26.1'
|
|
21
|
+
|
|
22
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
23
|
+
|
|
24
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
25
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
26
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
27
|
+
install_modules_dependencies(s)
|
|
28
|
+
else
|
|
29
|
+
//s.dependency "React-Core"
|
|
30
|
+
|
|
31
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
32
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
33
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
34
|
+
s.pod_target_xcconfig = {
|
|
35
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
36
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
37
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
38
|
+
}
|
|
39
|
+
s.dependency "React-Codegen"
|
|
40
|
+
s.dependency "RCT-Folly"
|
|
41
|
+
s.dependency "RCTRequired"
|
|
42
|
+
s.dependency "RCTTypeSafety"
|
|
43
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { TBIConstants } from './service';
|
|
2
|
+
import { UserType } from './types';
|
|
3
|
+
|
|
4
|
+
interface MethodsObject {
|
|
5
|
+
get: string;
|
|
6
|
+
post: string;
|
|
7
|
+
delete: string;
|
|
8
|
+
put: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ConsultationObject {
|
|
12
|
+
question: string;
|
|
13
|
+
medium: string;
|
|
14
|
+
userId: number;
|
|
15
|
+
mediaIds?: string[];
|
|
16
|
+
followUpId?: string;
|
|
17
|
+
}
|
|
18
|
+
export const Methods: MethodsObject = {
|
|
19
|
+
get: 'GET',
|
|
20
|
+
post: 'POST',
|
|
21
|
+
delete: 'DELETE',
|
|
22
|
+
put: 'PUT',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const fetchData = (
|
|
26
|
+
url: string,
|
|
27
|
+
request: RequestInterface,
|
|
28
|
+
timeout: number
|
|
29
|
+
): Promise<Response> | any =>
|
|
30
|
+
Promise.race([
|
|
31
|
+
fetch(url, request).catch((error) => {
|
|
32
|
+
throw Error(`Fetch Error ${error}`);
|
|
33
|
+
}),
|
|
34
|
+
new Promise((_, reject) =>
|
|
35
|
+
setTimeout(() => reject(new Error('request timeout')), timeout)
|
|
36
|
+
),
|
|
37
|
+
]).catch((e) => {
|
|
38
|
+
throw Error(`Fetch Error : ${e}`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
interface RequestParamsInterface {
|
|
42
|
+
method: string;
|
|
43
|
+
data?: Record<any, any>;
|
|
44
|
+
endPoint: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
type?: string;
|
|
47
|
+
fileName?: string;
|
|
48
|
+
download?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface RequestInterface {
|
|
52
|
+
method: string;
|
|
53
|
+
headers: Record<string, string>;
|
|
54
|
+
body: string | FormData | undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const request = async ({
|
|
58
|
+
method,
|
|
59
|
+
data,
|
|
60
|
+
endPoint,
|
|
61
|
+
path,
|
|
62
|
+
type,
|
|
63
|
+
fileName,
|
|
64
|
+
download,
|
|
65
|
+
}: RequestParamsInterface) => {
|
|
66
|
+
if (!TBIConstants.domain) {
|
|
67
|
+
return {
|
|
68
|
+
message: 'Add your domain to Init',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const headers = {
|
|
73
|
+
'Content-Type': 'application/json',
|
|
74
|
+
'Authorization': `Bearer ${TBIConstants.token}`,
|
|
75
|
+
'accept-language': TBIConstants.language,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
let url = `${TBIConstants.domain}/v1/${endPoint}`;
|
|
79
|
+
let body;
|
|
80
|
+
if (method === Methods.get) {
|
|
81
|
+
url = url + '?' + new URLSearchParams(data).toString();
|
|
82
|
+
} else if (path) {
|
|
83
|
+
const formData = new FormData();
|
|
84
|
+
formData.append('file', {
|
|
85
|
+
uri: path,
|
|
86
|
+
type: type,
|
|
87
|
+
name: fileName,
|
|
88
|
+
});
|
|
89
|
+
body = formData;
|
|
90
|
+
headers['Content-Type'] = 'multipart/form-data';
|
|
91
|
+
} else {
|
|
92
|
+
if (data && data.expand) {
|
|
93
|
+
url = url + '?' + new URLSearchParams({ expand: data.expand }).toString();
|
|
94
|
+
}
|
|
95
|
+
body = JSON.stringify(data);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const requestConfig: RequestInterface = {
|
|
99
|
+
method,
|
|
100
|
+
headers,
|
|
101
|
+
body,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const timeOut = path ? 180000 : 30000;
|
|
105
|
+
const apiResponse = await fetchData(url, requestConfig, timeOut);
|
|
106
|
+
if (download) {
|
|
107
|
+
return apiResponse;
|
|
108
|
+
}
|
|
109
|
+
const response = await apiResponse.text();
|
|
110
|
+
const responseData = response ? JSON.parse(response) : '';
|
|
111
|
+
return {
|
|
112
|
+
status: apiResponse.status,
|
|
113
|
+
data: responseData,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const getUser = (userId: string) =>
|
|
118
|
+
request({
|
|
119
|
+
method: Methods.get,
|
|
120
|
+
data: {},
|
|
121
|
+
endPoint: `users/${userId}`,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const getUsers = (page: number = 1, perPage: number = 20) =>
|
|
125
|
+
request({
|
|
126
|
+
method: Methods.get,
|
|
127
|
+
data: { page, 'per-page': perPage },
|
|
128
|
+
endPoint: `users`,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export const createUser = (user: UserType) =>
|
|
132
|
+
request({
|
|
133
|
+
method: Methods.post,
|
|
134
|
+
data: user,
|
|
135
|
+
endPoint: `users`,
|
|
136
|
+
});
|
|
137
|
+
export const updateUser = (user: UserType, userId: string) =>
|
|
138
|
+
request({
|
|
139
|
+
method: Methods.put,
|
|
140
|
+
data: user,
|
|
141
|
+
endPoint: `users/${userId}`,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export const deleteUser = (userId: string) =>
|
|
145
|
+
request({
|
|
146
|
+
method: Methods.delete,
|
|
147
|
+
data: {},
|
|
148
|
+
endPoint: `users/${userId}`,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export const createConsultation = async ({
|
|
152
|
+
question,
|
|
153
|
+
medium,
|
|
154
|
+
userId,
|
|
155
|
+
mediaIds,
|
|
156
|
+
followUpId,
|
|
157
|
+
}: ConsultationObject) => {
|
|
158
|
+
if (!question || !medium || !userId) {
|
|
159
|
+
return { message: 'missing field' };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const data = {
|
|
163
|
+
question,
|
|
164
|
+
medium,
|
|
165
|
+
user_id: userId,
|
|
166
|
+
media_ids: mediaIds,
|
|
167
|
+
expand:
|
|
168
|
+
'pusherAppKey,parentConsultation,consultations,user,media,pusherChannel,' +
|
|
169
|
+
'chatConfig,chatHistory,voipConfig,videoConfig,recommendation',
|
|
170
|
+
followUpId,
|
|
171
|
+
};
|
|
172
|
+
return await request({
|
|
173
|
+
method: Methods.post,
|
|
174
|
+
data,
|
|
175
|
+
endPoint: `consultations`,
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const getConsultationInfo = (consultationId: number) =>
|
|
180
|
+
request({
|
|
181
|
+
method: Methods.get,
|
|
182
|
+
data: {
|
|
183
|
+
expand:
|
|
184
|
+
'pusherAppKey,parentConsultation,consultations,user,media,pusherChannel,' +
|
|
185
|
+
'chatConfig,chatHistory,voipConfig,videoConfig,recommendation',
|
|
186
|
+
},
|
|
187
|
+
endPoint: `consultations/${consultationId}`,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export const getLastConsultation = () =>
|
|
191
|
+
request({
|
|
192
|
+
method: Methods.get,
|
|
193
|
+
data: {
|
|
194
|
+
'per-page': 1,
|
|
195
|
+
'sort': '-id',
|
|
196
|
+
'expand':
|
|
197
|
+
'pusherAppKey,parentConsultation,consultations,user,media,pusherChannel,' +
|
|
198
|
+
'chatConfig,chatHistory,voipConfig,videoConfig,recommendation',
|
|
199
|
+
},
|
|
200
|
+
endPoint: `consultations`,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
export const getConsultationList = async (
|
|
204
|
+
userId: number,
|
|
205
|
+
page: number = 1,
|
|
206
|
+
perPage = 20
|
|
207
|
+
) => {
|
|
208
|
+
if (!userId) {
|
|
209
|
+
return { message: 'missing user id' };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return await request({
|
|
213
|
+
method: Methods.get,
|
|
214
|
+
data: {
|
|
215
|
+
page,
|
|
216
|
+
'per-page': perPage,
|
|
217
|
+
'filter[user_id]': userId,
|
|
218
|
+
'expand':
|
|
219
|
+
'pusherAppKey,parentConsultation,consultations,user,media,pusherChannel,' +
|
|
220
|
+
'chatConfig,chatHistory,voipConfig,videoConfig,recommendation',
|
|
221
|
+
},
|
|
222
|
+
endPoint: `consultations`,
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const deleteConsultation = (consultationId: number) =>
|
|
227
|
+
request({
|
|
228
|
+
method: Methods.delete,
|
|
229
|
+
data: {},
|
|
230
|
+
endPoint: `consultations/${consultationId}`,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export const cancelConsultation = (consultationId: number) =>
|
|
234
|
+
request({
|
|
235
|
+
method: Methods.post,
|
|
236
|
+
data: {},
|
|
237
|
+
endPoint: `consultations/${consultationId}/cancel`,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
export const uploadMedia = (path: string, type: string, fileName: string) =>
|
|
241
|
+
request({
|
|
242
|
+
method: Methods.post,
|
|
243
|
+
endPoint: `media`,
|
|
244
|
+
data: {},
|
|
245
|
+
path,
|
|
246
|
+
type,
|
|
247
|
+
fileName,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
export const getPrescription = (consultationId: number) =>
|
|
251
|
+
request({
|
|
252
|
+
method: Methods.get,
|
|
253
|
+
endPoint: `consultations/${consultationId}/download-prescription`,
|
|
254
|
+
download: true,
|
|
255
|
+
});
|
package/src/data.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BloodType, BoolString, GenderType, MaritalStatus, MediumType } from './types';
|
|
2
|
+
|
|
3
|
+
export const materialStatusArray: MaritalStatus[] = [
|
|
4
|
+
'single',
|
|
5
|
+
'married',
|
|
6
|
+
'divorced',
|
|
7
|
+
'widow',
|
|
8
|
+
];
|
|
9
|
+
export const bloodTypeArray: BloodType[] = [
|
|
10
|
+
'A+',
|
|
11
|
+
'B+',
|
|
12
|
+
'AB+',
|
|
13
|
+
'O+',
|
|
14
|
+
'A-',
|
|
15
|
+
'B-',
|
|
16
|
+
'AB-',
|
|
17
|
+
'O-',
|
|
18
|
+
];
|
|
19
|
+
export const boolStringArray: BoolString[] = ['yes', 'no'];
|
|
20
|
+
export const genderTypeArray: GenderType[] = ['male', 'female'];
|
|
21
|
+
export const MediumArray: MediumType[] = ['chat', 'gsm', 'voip', 'video'];
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import OT, {
|
|
2
|
+
OTPublisher,
|
|
3
|
+
OTSession,
|
|
4
|
+
OTSubscriber,
|
|
5
|
+
OTSubscriberView,
|
|
6
|
+
} from './video';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
OTSession as TBISession,
|
|
10
|
+
OTPublisher as TBIPublisher,
|
|
11
|
+
OTSubscriber as TBISubscriber,
|
|
12
|
+
OTSubscriberView as TBISubscriberView,
|
|
13
|
+
OT as TBIVideo,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { default as AltibbiChat } from '@sendbird/chat';
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
BaseChannel,
|
|
20
|
+
ChannelType,
|
|
21
|
+
type MetaCounter,
|
|
22
|
+
type MetaData,
|
|
23
|
+
PushTriggerOption,
|
|
24
|
+
RestrictedUser,
|
|
25
|
+
User,
|
|
26
|
+
ConnectionHandler,
|
|
27
|
+
} from '@sendbird/chat';
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
GroupChannel,
|
|
31
|
+
GroupChannelHandler,
|
|
32
|
+
GroupChannelModule,
|
|
33
|
+
} from '@sendbird/chat/groupChannel';
|
|
34
|
+
export {
|
|
35
|
+
BaseMessage,
|
|
36
|
+
ReactionEvent,
|
|
37
|
+
ThreadInfoUpdateEvent,
|
|
38
|
+
} from '@sendbird/chat/message';
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
uploadMedia,
|
|
42
|
+
getUser,
|
|
43
|
+
getUsers,
|
|
44
|
+
createUser,
|
|
45
|
+
updateUser,
|
|
46
|
+
deleteUser,
|
|
47
|
+
getConsultationList,
|
|
48
|
+
getConsultationInfo,
|
|
49
|
+
getLastConsultation,
|
|
50
|
+
createConsultation,
|
|
51
|
+
deleteConsultation,
|
|
52
|
+
cancelConsultation,
|
|
53
|
+
getPrescription,
|
|
54
|
+
} from './connection';
|
|
55
|
+
|
|
56
|
+
export { TBIConstants, init } from './service';
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
TBISocket,
|
|
60
|
+
TBISocketChannel,
|
|
61
|
+
TBISocketMember,
|
|
62
|
+
TBISocketEvent,
|
|
63
|
+
type TBISocketAuthorizerResult,
|
|
64
|
+
} from './scoket';
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
UserType,
|
|
68
|
+
type BloodType,
|
|
69
|
+
type MaritalStatus,
|
|
70
|
+
type BoolString,
|
|
71
|
+
type GenderType,
|
|
72
|
+
type MediumType,
|
|
73
|
+
} from './types';
|
|
74
|
+
export {
|
|
75
|
+
materialStatusArray,
|
|
76
|
+
bloodTypeArray,
|
|
77
|
+
boolStringArray,
|
|
78
|
+
genderTypeArray,
|
|
79
|
+
MediumArray,
|
|
80
|
+
} from './data';
|