-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
272 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const settings = ({ | ||
'project_name': 'HotashXMS', | ||
'author': 'Sumon Ahmed', | ||
'organization': 'HotashTech', | ||
'version': '1.0', | ||
}); | ||
|
||
export const storage = ({ | ||
'server': '@auth/server', | ||
'token': '@auth/token', | ||
'queued': '@queued/sms', | ||
'sending_settings': '@settings/sending', | ||
}); | ||
|
||
export const status=({ | ||
'delivered':'delivered', | ||
'pending':'pending', | ||
'failed':'failed', | ||
'running':'running', | ||
'fetched':'fetched', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import axios from "axios"; | ||
|
||
import { getData, setData } from "./storage"; | ||
|
||
import { storage } from "../constants/Server"; | ||
|
||
axios.interceptors.request.use(async (request) => { | ||
const server = await getData(storage.server); | ||
const token = await getData(storage.token); | ||
request.headers["Content-Type"] = "application/json"; | ||
request.headers["accept"] = "application/json"; | ||
|
||
if (token && server) { | ||
request.baseURL = server + "/api/"; | ||
request.headers["Authorization"] = "Bearer " + token; | ||
} | ||
return request; | ||
}, error => { | ||
console.log(error.response.status); | ||
return Promise.reject(error); | ||
}); | ||
|
||
export interface DeviceInfo { | ||
"name": string; | ||
"model": string; | ||
"app_version": string; | ||
"android_version": string; | ||
"device_unique_id": string; | ||
} | ||
|
||
export const addDevice = (info: DeviceInfo) => { | ||
return axios.post("add/device", info).then(res => res.data); | ||
}; | ||
|
||
/** | ||
* @param device_id [Required] | ||
* @param timezone [Required] | ||
* @param limit | ||
*/ | ||
export const getQueues = (device_id, timezone, limit=0) => { | ||
const query = { | ||
device_unique_id:device_id, | ||
timezone:timezone, | ||
}; | ||
if (limit) { | ||
Object.assign({limit:limit},query) | ||
} | ||
return axios.get("queues",{params:query}).then(res => res.data); | ||
}; | ||
|
||
/** | ||
* @param device_id [Required] | ||
* @param queue_id [Required] | ||
* @param status [Required] | ||
* @param error_code | ||
*/ | ||
export const updateQueue = (device_id, queue_id, status,error_code) => { | ||
error_code=error_code || null; | ||
return axios.post("queue/update/status", { device_id, queue_id, status,error_code }).then(res => res.data); | ||
}; | ||
|
||
|
||
export const getSendingSettings = () => { | ||
return axios.get("/sending/setting").then(res => res.data); | ||
}; | ||
|
||
export const storeInbound = (obj) => { | ||
return axios.post("/inbound", obj).then(res => res.data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import CookieManager from '@react-native-cookies/cookies'; | ||
|
||
Date.prototype.addMonths = function(m) { | ||
let date = new Date(this); | ||
let years = Math.floor(m / 12); | ||
let months = m - (years * 12); | ||
if (years) date.setFullYear(date.getFullYear() + years); | ||
if (months) date.setMonth(date.getMonth() + months); | ||
return date; | ||
}; | ||
|
||
export const setCookie = (url, name, value) => { | ||
CookieManager.set(url, { | ||
name, | ||
value, | ||
path: '/', | ||
version: '1', | ||
expires: new Date().addMonths(6).toString() | ||
}).then((done) => { | ||
console.log('CookieManager.set =>', done); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
|
||
export const setData = async (key, value) => { | ||
try { | ||
const jsonValue = JSON.stringify(value); | ||
await AsyncStorage.setItem(key, jsonValue); | ||
} catch (e) { | ||
console.log("storage_saving_error", e); | ||
} | ||
}; | ||
|
||
export const getData = async (key) => { | ||
try { | ||
const jsonValue = await AsyncStorage.getItem(key); | ||
return jsonValue != null ? JSON.parse(jsonValue) : null; | ||
} catch (e) { | ||
console.log("storage_get_error", e); | ||
} | ||
}; | ||
|
||
export const removeData = async (...args) => { | ||
try { | ||
for(let i=0;i<args.length;i++){ | ||
await AsyncStorage.removeItem(args[i]); | ||
} | ||
} catch (e) { | ||
console.log("storage_remove_error", e); | ||
} | ||
}; |
Oops, something went wrong.