This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/services/backgroundUnsplash.ts

29 lines
755 B
TypeScript

import AbstractService from './abstractService'
import BackgroundImageModel, { type IBackgroundImage } from '../models/backgroundImage'
import ListModel from '@/models/list'
export default class BackgroundUnsplashService extends AbstractService<IBackgroundImage> {
constructor() {
super({
getAll: '/backgrounds/unsplash/search',
update: '/lists/{listId}/backgrounds/unsplash',
})
}
modelFactory(data) {
return new BackgroundImageModel(data)
}
modelUpdateFactory(data) {
return new ListModel(data)
}
async thumb(model) {
const response = await this.http({
url: `/backgrounds/unsplash/images/${model.id}/thumb`,
method: 'GET',
responseType: 'blob',
})
return window.URL.createObjectURL(new Blob([response.data]))
}
}