From caf357a84d8b6efcbd6d15e68080865f527e2161 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 25 Jan 2023 19:27:49 -0800 Subject: [PATCH] Add support for AppUpdates * Added model * Added blueprint * Added method to ApiController * Added route --- app/blueprints/api/v1/update_blueprint.rb | 9 +++++++++ app/controllers/api/v1/api_controller.rb | 11 ++++++++--- app/models/app_update.rb | 5 +++++ config/routes.rb | 2 ++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 app/blueprints/api/v1/update_blueprint.rb create mode 100644 app/models/app_update.rb diff --git a/app/blueprints/api/v1/update_blueprint.rb b/app/blueprints/api/v1/update_blueprint.rb new file mode 100644 index 0000000..7a2af46 --- /dev/null +++ b/app/blueprints/api/v1/update_blueprint.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Api + module V1 + class UpdateBlueprint < Blueprinter::Base + fields :update_type, :updated_at + end + end +end diff --git a/app/controllers/api/v1/api_controller.rb b/app/controllers/api/v1/api_controller.rb index 087b455..883308f 100644 --- a/app/controllers/api/v1/api_controller.rb +++ b/app/controllers/api/v1/api_controller.rb @@ -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 diff --git a/app/models/app_update.rb b/app/models/app_update.rb new file mode 100644 index 0000000..b1ee7d2 --- /dev/null +++ b/app/models/app_update.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class AppUpdate < ApplicationRecord + +end diff --git a/config/routes.rb b/config/routes.rb index a9709d1..5f419d3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'