import axios from 'axios'

const apiClient = axios.create({
	baseURL: 'https://server.riezel.com/api/v1',
	withCredentials: false,
	timeout: 2000,
	headers: {
		Accept: 'application/json',
		'Content-Type': 'application/json'
	}
})

export function getPhotoLogList() {
	return apiClient.get('/photologs/')
}

export function getPhotoLog(id) {
	return apiClient.get('/photolog/'+id+'/')
}

export function addNewPhotoLog(title, date) {
	return apiClient.post('/addphotolog/', {
		title,
		date: date,
		render_date: true,
		start_slide_image: null,
		slides: []
	})
}

export function updatePhotoLog({id, title, date, render_date, start_slide_image, slides}) {
	return apiClient.put('/updatephotolog/'+id+'/', {
		title,
		date,
		render_date,
		start_slide_image,
		slides
	})
}

export function deletePhotoLog(id) {
	return apiClient.delete('/deletephotolog/'+id+'/')
}

export function getPhotoGroups() {
	return apiClient.get('/photogroups/')
}

export function getPhotosByGroup(group_id) {
	return apiClient.get('/photos/?photogroup='+group_id)
}

export function getPhotoLogPDF(id) {
	return apiClient.get('/generatephotolog/'+id+'/')
}