import client from './client';

export const postApi = {
    list({ page = 1, limit = 10, keyword = '' } = {}) {
        return client.get('/posts', {
            params: {
                page,
                limit,
                keyword: keyword.trim()
            }
        });
    },

    play(id) {
        return client.get(`/posts/${id}/play`);
    },
    show(id) {
        return client.get(`/posts/${id}/show`);
    },
    mine({ page = 1, limit = 10 } = {}) {
        return client.get('/posts/mine', {
            params: {
                page,
                limit
            }
        });
    },
    buy(id) {
        return client.post(`/posts/${id}/buy`);
    }
}