class Spree::Api::V1::DevicesController < Spree::Api::BaseController skip_before_action :check_device, only: :create before_action :set_user def create @resource = device_service.find_or_create_user_device(@user, params[:name], params[:uid]) if @resource.errors.any? render 'spree/api/errors/invalid_resource', status: 422 else head :ok end end private def set_user @user = current_api_user end def device_service Spree::DeviceService.instance end end