import { actionTypes } from 'redux-resource';
// `bookDetails` could have the following shape:
export default function updateBook(bookDetails) {
return function(dispatch) {
type: actionTypes.UPDATE_RESOURCES_PENDING,
// You can pass either the whole `bookDetails`, or just the ID. Both work.
// Just be sure to pass the whole object on success, so that the updated
// attributes are persisted to your state tree!
resources: [bookDetails.id],
`/books/${bookDetails.id}`,
type: actionTypes.UPDATE_RESOURCES_IDLE,
resources: [bookDetails.id],
} else if (err || res.statusCode >= 400) {
type: actionTypes.UPDATE_RESOURCES_FAILED,
resources: [bookDetails.id],
statusCode: res.statusCode
type: actionTypes.UPDATE_RESOURCES_SUCCEEDED,
statusCode: res.statusCode