self.build

in codegen/projections/rails_json/lib/rails_json/builders.rb [411:462]


      def self.build(http_req, input:)
        http_req.http_method = 'POST'
        http_req.append_path('/InputAndOutputWithHeaders')
        http_req.headers['X-String'] = input[:header_string] unless input[:header_string].nil? || input[:header_string].empty?
        http_req.headers['X-Byte'] = input[:header_byte].to_s unless input[:header_byte].nil?
        http_req.headers['X-Short'] = input[:header_short].to_s unless input[:header_short].nil?
        http_req.headers['X-Integer'] = input[:header_integer].to_s unless input[:header_integer].nil?
        http_req.headers['X-Long'] = input[:header_long].to_s unless input[:header_long].nil?
        http_req.headers['X-Float'] = Seahorse::NumberHelper.serialize(input[:header_float]) unless input[:header_float].nil?
        http_req.headers['X-Double'] = Seahorse::NumberHelper.serialize(input[:header_double]) unless input[:header_double].nil?
        http_req.headers['X-Boolean1'] = input[:header_true_bool].to_s unless input[:header_true_bool].nil?
        http_req.headers['X-Boolean2'] = input[:header_false_bool].to_s unless input[:header_false_bool].nil?
        unless input[:header_string_list].nil? || input[:header_string_list].empty?
          http_req.headers['X-StringList'] = input[:header_string_list]
            .compact
            .map { |s| (s.include?('"') || s.include?(",")) ? "\"#{s.gsub('"', '\"')}\"" : s }
            .join(', ')
        end
        unless input[:header_string_set].nil? || input[:header_string_set].empty?
          http_req.headers['X-StringSet'] = input[:header_string_set]
            .to_a
            .compact
            .map { |s| (s.include?('"') || s.include?(",")) ? "\"#{s.gsub('"', '\"')}\"" : s }
            .join(', ')
        end
        unless input[:header_integer_list].nil? || input[:header_integer_list].empty?
          http_req.headers['X-IntegerList'] = input[:header_integer_list]
            .compact
            .map { |s| s.to_s }
            .join(', ')
        end
        unless input[:header_boolean_list].nil? || input[:header_boolean_list].empty?
          http_req.headers['X-BooleanList'] = input[:header_boolean_list]
            .compact
            .map { |s| s.to_s }
            .join(', ')
        end
        unless input[:header_timestamp_list].nil? || input[:header_timestamp_list].empty?
          http_req.headers['X-TimestampList'] = input[:header_timestamp_list]
            .compact
            .map { |s| Seahorse::TimeHelper.to_http_date(s) }
            .join(', ')
        end
        http_req.headers['X-Enum'] = input[:header_enum] unless input[:header_enum].nil? || input[:header_enum].empty?
        unless input[:header_enum_list].nil? || input[:header_enum_list].empty?
          http_req.headers['X-EnumList'] = input[:header_enum_list]
            .compact
            .map { |s| (s.include?('"') || s.include?(",")) ? "\"#{s.gsub('"', '\"')}\"" : s }
            .join(', ')
        end
      end