2020-05-31 21:17:10 +02:00
|
|
|
import AbstractService from './abstractService'
|
|
|
|
import BackgroundImageModel from '../models/backgroundImage'
|
|
|
|
import ListModel from '../models/list'
|
|
|
|
|
|
|
|
export default class BackgroundUnsplashService extends AbstractService {
|
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
getAll: '/backgrounds/unsplash/search',
|
|
|
|
update: '/lists/{listId}/backgrounds/unsplash',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
modelFactory(data) {
|
|
|
|
return new BackgroundImageModel(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
modelUpdateFactory(data) {
|
|
|
|
return new ListModel(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
thumb(model) {
|
|
|
|
return this.http({
|
2020-05-31 22:08:18 +02:00
|
|
|
url: `/backgrounds/unsplash/images/${model.id}/thumb`,
|
2020-05-31 21:17:10 +02:00
|
|
|
method: 'GET',
|
|
|
|
responseType: 'blob',
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
return window.URL.createObjectURL(new Blob([response.data]))
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
return e
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|