Sha256: e6e4e040806727383fd9bcd2e035277415b4e08dd345b848fcee92f65abcb6cf

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

require 'sinatra'

module RestPack::Activity::Service::Api
  class Activity < Sinatra::Base
    get "/.json" do
      render Commands::Activity::List.run(params, application_params)
    end

    get "/:id.json" do
      render Commands::Activity::Get.run(params, application_params)
    end

    post "/.json" do
      render Commands::Activity::Create.run(params, application_params)
    end

    put "/:id.json" do
      render Commands::Activity::Update.run(params, application_params)
    end

    delete "/:id.json" do
      render Commands::Activity::Destroy.run(params, application_params)
    end

    private

    def application_params
      #TODO: application_id may come from a domain mapping
      {
        application_id: 1
      }
    end

    def render(response)
      status response.code
      response.result[:errors] = response.errors
      response.result.to_json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_activity_service-0.0.7 lib/restpack_activity_service/api/activity.rb