class CPEE::Callbacks::ExCallback

Public Instance Methods

response() click to toggle source
# File lib/cpee/implementation_callbacks.rb, line 111
def response
  id = @a[0]
  opts = @a[1]
  callback = @r[-1]

  if CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'callback'
    ret = {}
    ret['values'] = @p.map{ |e|
      [e.name, e.class == Riddl::Parameter::Simple ? [:simple,e.value] : [:complex,e.mimetype,e.value.path] ]
    }
    ret['headers'] =  @h

    CPEE::Message::send(
      :'callback-response',
      callback,
      opts[:url],
      id,
      {},
      {},
      ret,
      opts[:redis]
    )
  elsif CPEE::Persistence::extract_item(id,opts,"callback/#{callback}/type") == 'vote'
    if @p.length == 1 && @p[0].name == 'continue' && @p[0].class == Riddl::Parameter::Simple
      CPEE::Message::send(
        :'vote-response',
        callback,
        opts[:url],
        id,
        {},
        {},
        @p[0].value,
        opts[:redis]
      )
    else
      @status = 400
    end
  else
    @status = 503
  end
  nil
end