Sha256: 83346d27c9262c92eb42416a72393066727eaa8c0622facd246f09ab3455506e
Contents?: true
Size: 1.79 KB
Versions: 11
Compression:
Stored size: 1.79 KB
Contents
module Locomotive module API module Resources class CurrentSiteResource < Grape::API resource :current_site do entity_klass = Entities::SiteEntity before do authenticate_locomotive_account! require_site! end helpers do def service @service ||= Locomotive::SiteService.new(current_account) end end desc 'Show current_site' get do authorize current_site, :show? present current_site, with: entity_klass end desc 'Update current site' params do requires :site, type: Hash do optional :name optional :handle optional :seo_title optional :meta_keywords optional :meta_description optional :robots_txt optional :locales, type: Array optional :domains, type: Array optional :timezone optional :picture optional :metafields_schema optional :metafields optional :metafields_ui end end put do authorize current_site, :update? current_site_form = Forms::SiteForm.new(permitted_params_from_policy(current_site, :site, [:picture], [:metafields_ui, :metafields_schema, :metafields])) service.update!(current_site, current_site_form.serializable_hash) present current_site, with: entity_klass end desc "Delete current site" delete do authorize current_site, :destroy? current_site.destroy present current_site, with: entity_klass end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems