Skip to content

Commit

Permalink
Create rideAPI.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 12, 2024
1 parent 9f6e93a commit 82f7589
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions blockchain_integration/pi_network/PiRide/api/rideAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import axios from 'axios';
import { API_URL } from '../constants';

const rideAPI = {
createRideRequest: async (rideRequestData) => {
try {
const response = await axios.post(`${API_URL}/rides`, rideRequestData);
return response.data;
} catch (error) {
throw error.response.data;
}
},

getRideRequests: async () => {
try {
const response = await axios.get(`${API_URL}/rides`);
return response.data;
} catch (error) {
throw error.response.data;
}
},

createRideOffer: async (rideOfferData) => {
try {
const response = await axios.post(`${API_URL}/rides/offers`, rideOfferData);
return response.data;
} catch (error) {
throw error.response.data;
}
},

getRideOffers: async () => {
try {
const response = await axios.get(`${API_URL}/rides/offers`);
return response.data;
} catch (error) {
throw error.response.data;
}
},

acceptRideOffer: async (rideOfferId) => {
try {
const response = await axios.patch(`${API_URL}/rides/offers/${rideOfferId}/accept`);
return response.data;
} catch (error) {
throw error.response.data;
}
},

declineRideOffer: async (rideOfferId) => {
try {
const response = await axios.patch(`${API_URL}/rides/offers/${rideOfferId}/decline`);
return response.data;
} catch (error) {
throw error.response.data;
}
},
};

export default rideAPI;

0 comments on commit 82f7589

Please sign in to comment.