Skip to content
Snippets Groups Projects
Commit 4f9b7432 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Fix #52 - Add API versioning (v1)

parent 3f75f522
No related branches found
No related tags found
No related merge requests found
Showing
with 24 additions and 38 deletions
......@@ -36,7 +36,7 @@ export function fetchAccount(id) {
dispatch(fetchAccountRequest(id));
axios.all([boundApi.get(`/api/accounts/${id}`), boundApi.get(`/api/accounts/relationships?id=${id}`)]).then(values => {
axios.all([boundApi.get(`/api/v1/accounts/${id}`), boundApi.get(`/api/v1/accounts/relationships?id=${id}`)]).then(values => {
dispatch(fetchAccountSuccess(values[0].data, values[1].data[0]));
}).catch(error => {
dispatch(fetchAccountFail(id, error));
......@@ -48,7 +48,7 @@ export function fetchAccountTimeline(id) {
return (dispatch, getState) => {
dispatch(fetchAccountTimelineRequest(id));
api(getState).get(`/api/accounts/${id}/statuses`).then(response => {
api(getState).get(`/api/v1/accounts/${id}/statuses`).then(response => {
dispatch(fetchAccountTimelineSuccess(id, response.data));
}).catch(error => {
dispatch(fetchAccountTimelineFail(id, error));
......@@ -62,7 +62,7 @@ export function expandAccountTimeline(id) {
dispatch(expandAccountTimelineRequest(id));
api(getState).get(`/api/accounts/${id}/statuses?max_id=${lastId}`).then(response => {
api(getState).get(`/api/v1/accounts/${id}/statuses?max_id=${lastId}`).then(response => {
dispatch(expandAccountTimelineSuccess(id, response.data));
}).catch(error => {
dispatch(expandAccountTimelineFail(id, error));
......@@ -97,7 +97,7 @@ export function followAccount(id) {
return (dispatch, getState) => {
dispatch(followAccountRequest(id));
api(getState).post(`/api/accounts/${id}/follow`).then(response => {
api(getState).post(`/api/v1/accounts/${id}/follow`).then(response => {
dispatch(followAccountSuccess(response.data));
}).catch(error => {
dispatch(followAccountFail(error));
......@@ -109,7 +109,7 @@ export function unfollowAccount(id) {
return (dispatch, getState) => {
dispatch(unfollowAccountRequest(id));
api(getState).post(`/api/accounts/${id}/unfollow`).then(response => {
api(getState).post(`/api/v1/accounts/${id}/unfollow`).then(response => {
dispatch(unfollowAccountSuccess(response.data));
}).catch(error => {
dispatch(unfollowAccountFail(error));
......
......@@ -36,7 +36,7 @@ export function submitCompose() {
return function (dispatch, getState) {
dispatch(submitComposeRequest());
api(getState).post('/api/statuses', {
api(getState).post('/api/v1/statuses', {
status: getState().getIn(['compose', 'text'], ''),
in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null),
media_ids: getState().getIn(['compose', 'media_attachments']).map(item => item.get('id'))
......@@ -75,7 +75,7 @@ export function uploadCompose(files) {
let data = new FormData();
data.append('file', files[0]);
api(getState).post('/api/media', data, {
api(getState).post('/api/v1/media', data, {
onUploadProgress: function (e) {
dispatch(uploadComposeProgress(e.loaded, e.total));
}
......
......@@ -16,7 +16,7 @@ export function submitFollow(router) {
return function (dispatch, getState) {
dispatch(submitFollowRequest());
api(getState).post('/api/follows', {
api(getState).post('/api/v1/follows', {
uri: getState().getIn(['follow', 'text'])
}).then(function (response) {
dispatch(submitFollowSuccess(response.data));
......
......@@ -12,7 +12,7 @@ export function reblog(status) {
return function (dispatch, getState) {
dispatch(reblogRequest(status));
api(getState).post(`/api/statuses/${status.get('id')}/reblog`).then(function (response) {
api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`).then(function (response) {
// The reblog API method returns a new status wrapped around the original. In this case we are only
// interested in how the original is modified, hence passing it skipping the wrapper
dispatch(reblogSuccess(status, response.data.reblog));
......@@ -24,7 +24,7 @@ export function reblog(status) {
export function unreblog(status) {
return (dispatch, getState) => {
api(getState).post(`/api/statuses/${status.get('id')}/unreblog`).then(response => {
api(getState).post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => {
//
}).catch(error => {
//
......@@ -59,7 +59,7 @@ export function favourite(status) {
return function (dispatch, getState) {
dispatch(favouriteRequest(status));
api(getState).post(`/api/statuses/${status.get('id')}/favourite`).then(function (response) {
api(getState).post(`/api/v1/statuses/${status.get('id')}/favourite`).then(function (response) {
dispatch(favouriteSuccess(status, response.data));
}).catch(function (error) {
dispatch(favouriteFail(status, error));
......@@ -69,7 +69,7 @@ export function favourite(status) {
export function unfavourite(status) {
return (dispatch, getState) => {
api(getState).post(`/api/statuses/${status.get('id')}/unfavourite`).then(response => {
api(getState).post(`/api/v1/statuses/${status.get('id')}/unfavourite`).then(response => {
//
}).catch(error => {
//
......
......@@ -18,7 +18,7 @@ export function fetchStatus(id) {
dispatch(fetchStatusRequest(id));
axios.all([boundApi.get(`/api/statuses/${id}`), boundApi.get(`/api/statuses/${id}/context`)]).then(values => {
axios.all([boundApi.get(`/api/v1/statuses/${id}`), boundApi.get(`/api/v1/statuses/${id}/context`)]).then(values => {
dispatch(fetchStatusSuccess(values[0].data, values[1].data));
}).catch(error => {
dispatch(fetchStatusFail(id, error));
......
......@@ -45,7 +45,7 @@ export function refreshTimeline(timeline) {
return function (dispatch, getState) {
dispatch(refreshTimelineRequest(timeline));
api(getState).get(`/api/statuses/${timeline}`).then(function (response) {
api(getState).get(`/api/v1/statuses/${timeline}`).then(function (response) {
dispatch(refreshTimelineSuccess(timeline, response.data));
}).catch(function (error) {
dispatch(refreshTimelineFail(timeline, error));
......@@ -67,7 +67,7 @@ export function expandTimeline(timeline) {
dispatch(expandTimelineRequest(timeline));
api(getState).get(`/api/statuses/${timeline}?max_id=${lastId}`).then(response => {
api(getState).get(`/api/v1/statuses/${timeline}?max_id=${lastId}`).then(response => {
dispatch(expandTimelineSuccess(timeline, response.data));
}).catch(error => {
dispatch(expandTimelineFail(timeline, error));
......
class Api::AccountsController < ApiController
class Api::V1::AccountsController < ApiController
before_action :doorkeeper_authorize!
before_action :set_account
respond_to :json
......
class Api::AppsController < ApplicationController
class Api::V1::AppsController < ApplicationController
respond_to :json
def create
......
class Api::FollowsController < ApiController
class Api::V1::FollowsController < ApiController
before_action :doorkeeper_authorize!
respond_to :json
......
class Api::MediaController < ApiController
class Api::V1::MediaController < ApiController
before_action :doorkeeper_authorize!
respond_to :json
......
class Api::StatusesController < ApiController
class Api::V1::StatusesController < ApiController
before_action :doorkeeper_authorize!
respond_to :json
......
module Api::AccountsHelper
end
module Api::AppsHelper
end
module Api::FollowsHelper
end
module Api::MediaHelper
end
module Api::SalmonHelper
end
module Api::StatusesHelper
end
module Api::SubscriptionsHelper
end
......@@ -3,11 +3,11 @@ module HomeHelper
{
token: @token,
account: render(file: 'api/accounts/show', locals: { account: current_user.account }, formats: :json),
account: render(file: 'api/v1/accounts/show', locals: { account: current_user.account }, formats: :json),
timelines: {
home: render(file: 'api/statuses/home', locals: { statuses: @home }, formats: :json),
mentions: render(file: 'api/statuses/mentions', locals: { statuses: @mentions }, formats: :json)
home: render(file: 'api/v1/statuses/home', locals: { statuses: @home }, formats: :json),
mentions: render(file: 'api/v1/statuses/mentions', locals: { statuses: @mentions }, formats: :json)
}
}
end
......
......@@ -54,6 +54,6 @@ class FeedManager
end
end
Rabl::Renderer.new('api/statuses/show', status, view_path: 'app/views', format: :json, scope: rabl_scope.new(target_account)).render
Rabl::Renderer.new('api/v1/statuses/show', status, view_path: 'app/views', format: :json, scope: rabl_scope.new(target_account)).render
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment