Add support for AppUpdates
* Added model * Added blueprint * Added method to ApiController * Added route
This commit is contained in:
parent
7911374c1e
commit
caf357a84d
4 changed files with 24 additions and 3 deletions
9
app/blueprints/api/v1/update_blueprint.rb
Normal file
9
app/blueprints/api/v1/update_blueprint.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V1
|
||||
class UpdateBlueprint < Blueprinter::Base
|
||||
fields :update_type, :updated_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -36,6 +36,11 @@ module Api
|
|||
respond_to :json
|
||||
|
||||
##### Methods
|
||||
# Returns the latest update
|
||||
def latest
|
||||
render json: UpdateBlueprint.render_as_json(AppUpdate.last)
|
||||
end
|
||||
|
||||
# Assign the current user if the Doorkeeper token isn't nil, then
|
||||
# update the current user's last seen datetime and last IP address
|
||||
# before returning
|
||||
|
|
@ -85,9 +90,9 @@ module Api
|
|||
|
||||
def render_not_found_response(object)
|
||||
render json: ErrorBlueprint.render(nil, error: {
|
||||
message: "#{object.capitalize} could not be found",
|
||||
code: 'not_found'
|
||||
}), status: :not_found
|
||||
message: "#{object.capitalize} could not be found",
|
||||
code: 'not_found'
|
||||
}), status: :not_found
|
||||
end
|
||||
|
||||
def render_unauthorized_response
|
||||
|
|
|
|||
5
app/models/app_update.rb
Normal file
5
app/models/app_update.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AppUpdate < ApplicationRecord
|
||||
|
||||
end
|
||||
|
|
@ -13,6 +13,8 @@ Rails.application.routes.draw do
|
|||
resources :grid_summons, only: %i[update destroy]
|
||||
resources :favorites, only: [:create]
|
||||
|
||||
get 'latest', to: 'api#latest'
|
||||
|
||||
get 'users/info/:id', to: 'users#info'
|
||||
|
||||
get 'parties/favorites', to: 'parties#favorites'
|
||||
|
|
|
|||
Loading…
Reference in a new issue