Class: FaspClient::EventSubscriptionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/fasp_client/event_subscriptions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#fasp_client_controller?, #get_provider, #verify_request

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/fasp_client/event_subscriptions_controller.rb', line 7

def create
  options = params.deep_transform_keys(&:underscore).expect(event_subscription: [ :category, :subscription_type ])
  if options[:category] == "content" && options[:subscription_type] == "trends"
    head :not_implemented
    return
  end
  sub = FaspClient::EventSubscription.create(options.merge(fasp_client_provider: @provider))
  if sub.valid?
    respond_to do |format|
      format.json do
        render json: { "subscription" => { "id" => sub.id.to_s } }, status: :created
      end
    end
  else
    head :unprocessable_content
  end
end

#destroyObject



25
26
27
28
29
# File 'app/controllers/fasp_client/event_subscriptions_controller.rb', line 25

def destroy
  @subscription = @provider.fasp_client_event_subscriptions.find(params[:id])
  @subscription.destroy
  head :no_content
end