lib/learnosity/sdk/request/init.rb
# XXX: Needs to be public for unit tests
Needs to be public for unit tests
Needs to be public for unit tests
def generate(encode = true)
          output = {}
          case @service
          when 'assess', 'author', 'data', 'items', 'reports'
            output['security'] =  @security_packet
            unless @request_packet.nil?
              output['request'] = @request_packet
            end
            case @service
            when 'data'
              data_output = { 'security' => JSON.generate(output['security']) }
              if output.key?('request')
                data_output['request'] = JSON.generate(output['request'])
              end
              unless @action.nil?
                data_output['action'] = @action
              end
              return data_output
            when 'assess'
              output = output['request']
            end
          when 'questions'
            output = hash_except(@security_packet, 'domain')
            unless @request_packet.nil?
              output = output.merge(@request_packet)
            end
          when 'events'
            output['security'] =  @security_packet
            output['config'] =  @request_packet
          else
            raise Exception, "generate() for #{@service} not implemented"
          end
          unless encode
            return output
          end
          JSON.generate(output)
        end
def generate ( encode = true ) output = { } case @service when 'assess' , 'author' , 'data' , 'items' , 'reports' output [ 'security' ] = @security_packet unless @request_packet . nil? output [ 'request' ] = @request_packet end case @service when 'data' data_output = { 'security' => JSON . generate ( output [ 'security' ] ) } if output . key? ( 'request' ) data_output [ 'request' ] = JSON . generate ( output [ 'request' ] ) end unless @action . nil? data_output [ 'action' ] = @action end return data_output when 'assess' output = output [ 'request' ] end when 'questions' output = hash_except ( @security_packet , 'domain' ) unless @request_packet . nil? output = output . merge ( @request_packet ) end when 'events' output [ 'security' ] = @security_packet output [ 'config' ] = @request_packet else raise Exception , "generate() for #{@service} not implemented" end unless encode return output end JSON . generate ( output ) end
XXX: Needs to be public for unit tests
XXX : Needs to be public for unit tests
encode
<not_specific>