Sha256: 57dc22b6fadfdc41628b577bef157fa77d12fd1a6a5241faa35453d4006cc160

Contents?: true

Size: 978 Bytes

Versions: 15

Compression:

Stored size: 978 Bytes

Contents

class SwitchToBrandHandler < BaseHandler
    def mount
        @server.mount_proc('/switch') do |req, res|
            if req.request_method == 'POST'
                begin
                    request_payload = JSON.parse(req.body)
                    brand_key = request_payload['brand_key']

                    result = SolaraManager.new.switch(brand_key)
                    Solara.logger.debug(result)

                    res.status = 200
                    res.body = JSON.generate({ success: true, message: "Switched to brand: #{brand_key}", result: result })
                    res.content_type = 'application/json'
                rescue JSON::ParserError => e
                    handle_error(res, e, "Invalid JSON in request body", 400)
                rescue StandardError => e
                    handle_error(res, e, "Error switching to brand")
                end
            else
                method_not_allowed(res)
            end
        end
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
solara-0.7.4 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.7.3 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.7.2 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.7.1 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.7.0 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.6.0 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.5.0 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.4.0 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.3.0 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.2.4 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.2.3 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.2.2 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.2.1 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.2.0 solara/lib/core/dashboard/handler/switch_handler.rb
solara-0.1.0 solara/lib/core/dashboard/handler/switch_handler.rb