UNPKG

scrive

Version:

ERROR: No README.md file found!

194 lines (153 loc) 5.71 kB
(function () { "use strict"; angular.module('standinApp') .factory('ServerRequest', ServerRequest); function ServerRequest(Upload, $http, $q, $localStorage) { var API_URL = '/'; var headers = { 'x-access-token': $localStorage.token || '', }; return { login: login, createAccount: createAccount, getStandins: getStandins, createProfile: createProfile, getCourthouses: getCourthouses, createBooking: createBooking, geolocate: geolocate, forgotPassword: forgotPassword, getBookings: getBookings, cancelBooking: cancelBooking, modifyBooking: modifyBooking, caseInformationSent: caseInformationSent, getUserProfile: getUserProfile, getReviewsForUser: getReviewsForUser, updateStripeCreditCardToken: updateStripeCreditCardToken, submitPayment: submitPayment, updateLocation: updateLocation, submitReview: submitReview, acceptStandin: acceptStandin, rejectStandin: rejectStandin, getTransactionsForUser: getTransactionsForUser, verifyLinkedIn: verifyLinkedIn, loginWithLinkedIn: loginWithLinkedIn }; /////////////////////////////////////////////////////////////////////// function login(dataObj) { return httpPOST("login", dataObj) } function createAccount(dataObj) { return httpPOST("register", dataObj) } function createProfile(dataObj) { return httpPOST("createProfile", dataObj) } function geolocate() { if (navigator.geolocation) { var deferred = $q.defer(); navigator.geolocation.getCurrentPosition(function (position) { var geolocation = { lat: position.coords.latitude, lng: position.coords.longitude }; deferred.resolve(geolocation); }, function (err) { deferred.reject(err); }); return deferred.promise; } } function revGeocode(lat, lng) { var deferred = $q.defer(); $http({ url: 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + ',' + lng, method: 'GET' }) .then(function (successPayload) { deferred.resolve(successPayload.data.results); }, function (errorPayload) { deferred.reject(errorPayload); }); return deferred.promise; } function getStandins(dataObj) { return httpPOST("getStandins", dataObj) } function getCourthouses(dataObj) { return httpPOST("getCourthouses", dataObj) } function createBooking(dataObj) { return httpPOST("createBooking", dataObj) } function forgotPassword(dataObj) { return httpPOST("forgotPassword", dataObj) } function getBookings(dataObj) { return httpPOST("getBookings", dataObj) } function cancelBooking(dataObj) { return httpPOST("cancelBooking", dataObj) } function modifyBooking(dataObj) { return httpPOST("modifyBooking", dataObj) } function caseInformationSent(dataObj) { return httpPOST("caseInformationSent", dataObj) } function getUserProfile(dataObj) { return httpPOST("getStandinWithId", dataObj) } function getReviewsForUser(dataObj) { return httpPOST("getReviewsForUser", dataObj) } function updateStripeCreditCardToken(dataObj) { return httpPOST("updateStripeCreditCardToken", dataObj) } function submitPayment(dataObj) { return httpPOST("submitPayment", dataObj) } function updateLocation(dataObj) { return httpPOST("updateLocation", dataObj) } function submitReview(dataObj) { return httpPOST("submitReview", dataObj) } function acceptStandin(dataObj) { return httpPOST("acceptStandin", dataObj) } function rejectStandin(dataObj) { return httpPOST("rejectStandin", dataObj) } function getTransactionsForUser(dataObj) { return httpPOST("getTransactionsForUser", dataObj) } function verifyLinkedIn(dataObj) { return httpPOST("verifyLinkedIn", dataObj) } function loginWithLinkedIn(dataObj) { return httpPOST("loginWithLinkedIn", dataObj) } function httpPOST(url, dataObj) { if (!dataObj) { dataObj = {} } //if ($localStorage.token){ dataObj['token'] = $localStorage.token } return $q(function (resolve, reject) { $http({ url: encodeURI(API_URL + url), method: 'POST', headers: headers, data: dataObj }) .then(function (response) { resolve(response.data); }, function (response) { reject(response.data); }); }) } } }());