Seo.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { appApi } from 'src/boot/axios.js'
  2. import { PageSeo } from 'src/models/PageSeo.js'
  3. import APIRepository from '../classes/APIRepository.js'
  4. export default class ContentAPI extends APIRepository {
  5. constructor() {
  6. super('content', appApi)
  7. this.APIAdresses = {
  8. base: (type, id) => '/seo' + '?type=' + type + '&id=' + id
  9. }
  10. this.CacheList = {
  11. base: (type, id) => this.name + this.APIAdresses.base(type, id)
  12. }
  13. }
  14. show(data, cache = { TTL: 1000 }) {
  15. return this.sendRequest({
  16. apiMethod: 'get',
  17. api: this.api,
  18. request: this.APIAdresses.base(data.type, data.id),
  19. cacheKey: this.CacheList.base(data.type, data.id),
  20. data: this.getNormalizedSendData({
  21. type: '', // String -> in:content,content-set,product
  22. id: 0 // Number
  23. }, data),
  24. ...(cache && { cache }),
  25. resolveCallback: (response) => {
  26. return new PageSeo(response.data.data)
  27. },
  28. rejectCallback: (error) => {
  29. return error
  30. }
  31. })
  32. }
  33. }