class Admin

Defined in:

controllers/admin.cr

Constant Summary

AFTER = {} of Nil => Nil
AROUND = {} of Nil => Nil
BEFORE = {determine_tenant_from_domain => {nil, nil}, configure_request_logging => {nil, nil}, check_jwt_scope => {nil, nil}} of Nil => Nil
FORCE = {} of Nil => Nil
LOCAL_AFTER = {} of Nil => Nil

function => options

LOCAL_AROUND = {} of Nil => Nil

function => options

LOCAL_BEFORE = {} of Nil => Nil

function => options

LOCAL_FORCE = {} of Nil => Nil

function => options

LOCAL_RESCUE = {} of Nil => Nil

function => options

LOCAL_ROUTES = {create_token => {"get", "/create_token", nil, do token = UserJWT.new("Staff-API App", Time.local, Time.local + 24.hours, "redant.staff-api.dev", "123", UserJWT::Metadata.new("Toby Carvan", "[email protected]")) render(text: token.encode) end, false}, debug_token => {"get", "/debug_token", nil, do render(json: user_token) end, false}} of Nil => Nil

function => options

LOCAL_SKIP = {} of Nil => Nil

function => options

NAMESPACE = ["/api/staff/v1/admin"]

default namespace based on class

RESCUE = {Error::Unauthorized => {error_unauthorized, do |error| Log.debug do error.message end head(:unauthorized) end}, Error::Forbidden => {error_forbidden, do |error| Log.debug do error.inspect_with_backtrace end head(:forbidden) end}, Clear::SQL::RecordNotFoundError => {clear_sql_record_not_found_error, do |error| Log.debug do error.message end head(:not_found) end}, Clear::SQL::Error => {clear_sql_error, do |error| render_error(HTTP::Status::INTERNAL_SERVER_ERROR, error) end}, KeyError => {key_error, do |error| if error.message.try(&.includes?("param")) else raise(error) end respond_with(:bad_request) do text(error.message) json({error: error.message}) end end}, JSON::MappingError => {json_mapping_error, do |error| respond_with(:bad_request) do text(error.inspect_with_backtrace) json({error: error.message, backtrace: error.backtrace?}) end end}, ::PlaceOS::Client::API::Error => {_place_os_client_api_error, do |error| render_error(HTTP::Status::NOT_FOUND, error) end}, ::Enumerable::EmptyError => {_enumerable_empty_error, do |error| render_error(HTTP::Status::NOT_FOUND, error) end}, PlaceCalendar::Exception => {place_calendar_exception, do |error| render_error(HTTP::Status::INTERNAL_SERVER_ERROR, error, "#{error.http_body} \n #{error.inspect_with_backtrace}") end}} of Nil => Nil
ROUTES = {create_token => {"get", "/create_token", nil, do token = UserJWT.new("Staff-API App", Time.local, Time.local + 24.hours, "redant.staff-api.dev", "123", UserJWT::Metadata.new("Toby Carvan", "[email protected]")) render(text: token.encode) end, false}, debug_token => {"get", "/debug_token", nil, do render(json: user_token) end, false}} of Nil => Nil
SKIP = {} of Nil => Nil

Class Method Summary

Instance Method Summary

Macro Summary

Class methods inherited from class Application

context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &) context

Instance methods inherited from module Utils::MultiTenant

client : PlaceCalendar::Client client, tenant tenant

Instance methods inherited from module Utils::CurrentUser

authorize! authorize!, check_admin check_admin, check_support check_support, is_admin? is_admin?, is_support? is_support?, user user, user_token : UserJWT user_token

Instance methods inherited from module Utils::PlaceOSHelpers

check_access(groups : Array(String), check : Array(String)) check_access, get_placeos_client : PlaceOS::Client get_placeos_client, get_user_calendars get_user_calendars, matching_calendar_ids(allow_default = false) matching_calendar_ids

Class Method Detail

def self.__init_routes__(router) #

Routes call the functions generated above


def self.__route_list__ #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.base_route #

Helper for obtaining base route


def self.context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &) #

[View source]
def self.create_token(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Helper methods for performing redirect_to calls


def self.debug_token(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_staff_v1_admin_create_token(context, head_request) #

Generate functions for each route


def self.get__api_staff_v1_admin_debug_token(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


Instance Method Detail

def _enumerable_empty_error(error) #

def _place_os_client_api_error(error) #

def base_route(*args, **options) #

Helper for obtaining base route


def base_route(*args, **options, &) #

Helper for obtaining base route


def clear_sql_error(error) #

def clear_sql_record_not_found_error(error) #

def create_token #

Create functions for named routes Skip the CRUD verbs, as they are already defined Annotations defined via the annotations argument are applied here


def debug_token #

def error_forbidden(error) #

def error_unauthorized(error) #

Create functions as required for errors Skip the generating methods for existing handlers


def json_mapping_error(error) #

def key_error(error) #

def place_calendar_exception(error) #

Macro Detail

macro __inherit_after_filters__ #

macro __inherit_around_filters__ #

macro __inherit_before_filters__ #

macro __inherit_force_filters__ #

macro __inherit_rescue_filters__ #

macro __inherit_routes_filters__ #

macro __inherit_skip_filters__ #