Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const BASEURL = "https://eublack-api-proxy-dev.herokuapp.com"
- const login = async (user, password) => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/login`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: user,
- senha: password,
- }),
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const reautenticar = async token => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/reautenticar`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const getUserById = async (token, id) => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/${id}`, {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- })
- return await response.json()
- } catch (e) {
- return error
- }
- }
- const upload = async (token, file) => {
- try {
- const response = await fetch(`${BASEURL}/conteudos/files/upload/base64`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- body: JSON.stringify({ base64Image: file }),
- })
- return await response.json()
- } catch (e) {
- return e
- }
- }
- const updateUser = async (token, id, data) => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/${id}`, {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- body: JSON.stringify({
- id,
- ...data,
- }),
- })
- return await response.json()
- } catch (e) {
- return error
- }
- }
- const updateDeviceToken = async (token, deviceToken) => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/set/deviceToken`, {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- body: JSON.stringify({ deviceToken }),
- })
- return await response.json()
- } catch (error) {
- return null
- }
- }
- const getTrails = async () => {
- try {
- const response = await fetch(`${BASEURL}/gamefication/trails`, {
- method: "GET",
- headers: { "Content-Type": "application/json" },
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const getTrailById = async (token, id) => {
- try {
- const response = await fetch(`${BASEURL}/gamefication/trails/${id}`, {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const getQuizById = async (token, id) => {
- try {
- const response = await fetch(`${BASEURL}/gamefication/quizzes/${id}`, {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const recoverPassword = async email => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/senha/recoveryPin`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ email }),
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const recoverPasswordConfirm = async (pin, email, senha) => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/senha/recoveryPinConfirm`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ pin, email, senha }),
- })
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const getEventsFromSchedule = async ({ searchText, pageNumber, perPage, initDate, endDate, place, eventType, placeType, city }) => {
- try {
- const response = await fetch(
- `${BASEURL}/agendas` +
- `?searchText=${searchText}` +
- `&pageNumber=${pageNumber}` +
- `&perPage=${perPage}` +
- `&initDate=${initDate}` +
- `&endDate=${endDate}` +
- `&place=${place}` +
- `&eventType=${eventType}` +
- `&placeType=${placeType}` +
- `&city=${city}`,
- {
- method: "GET",
- headers: { "Content-Type": "application/json" },
- }
- )
- return await response.json()
- } catch (error) {
- return error
- }
- }
- const onEditRecruiterURL = async token => {
- try {
- const response = await fetch(`${BASEURL}/assinaturas/assinantes/hook/onEditRecruiterURL`,
- {
- method: "POST",
- headers:
- { "Content-Type": "application/json"
- ,"Authorization": `Bearer ${token}`
- }
- }
- )
- return await response.json()
- }
- catch (e) {
- return error
- }
- }
- export default
- { upload
- , login
- , reautenticar
- , getUserById
- , getTrails
- , getTrailById
- , getQuizById
- , updateUser
- , updateDeviceToken
- , recoverPassword
- , recoverPasswordConfirm
- , onEditRecruiterURL
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement