react-native-altibbi 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/connection.ts +15 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-altibbi",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Altibbi Sdk",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/connection.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TBIConstants } from './service';
2
- import { ConsultationType, MediaType, ResponseType, UserType } from './types';
2
+ import type { ConsultationType, MediaType, ResponseType, UserType } from './types';
3
3
 
4
4
  interface MethodsObject {
5
5
  get: string;
@@ -233,11 +233,13 @@ export const getConsultationInfo = async (
233
233
  endPoint: `consultations/${consultation_id}`,
234
234
  });
235
235
  if (response.status === 200) {
236
- response.data.socketParams = {
237
- apiKey: response?.data?.[0]?.pusherAppKey,
238
- cluster: 'eu',
239
- authEndpoint: `${TBIConstants.baseURL}/v1/auth/pusher?access-token=${TBIConstants.token}`,
240
- };
236
+ if(response.data && response.data.pusherAppKey){
237
+ response.data.socketParams = {
238
+ apiKey: response.data.pusherAppKey,
239
+ cluster: 'eu',
240
+ authEndpoint: `${TBIConstants.baseURL}/v1/auth/pusher?access-token=${TBIConstants.token}`,
241
+ };
242
+ }
241
243
  return response;
242
244
  }
243
245
  throw Error(JSON.stringify(response));
@@ -258,11 +260,13 @@ export const getLastConsultation = async (): Promise<
258
260
  endPoint: `consultations`,
259
261
  });
260
262
  if (response.status === 200) {
261
- response.data[0].socketParams = {
262
- apiKey: response.data[0].pusherAppKey,
263
- cluster: 'eu',
264
- authEndpoint: `${TBIConstants.baseURL}/v1/auth/pusher?access-token=${TBIConstants.token}`,
265
- };
263
+ if(response.data && response.data[0] && response.data[0].pusherAppKey){
264
+ response.data[0].socketParams = {
265
+ apiKey: response?.data?.[0]?.pusherAppKey,
266
+ cluster: 'eu',
267
+ authEndpoint: `${TBIConstants.baseURL}/v1/auth/pusher?access-token=${TBIConstants.token}`,
268
+ };
269
+ }
266
270
  return response;
267
271
  }
268
272
  throw Error(JSON.stringify(response));