<commit_before>require "securerandom"
require "hotel_beds/model"
require "hotel_beds/model/available_room"

module HotelBeds
  module HotelBasketAdd
    class Request
      class HotelService
        include HotelBeds::Model

        # attributes
        attribute :availability_token, String
        attribute :contract_name, String
        attribute :contract_incoming_office_code, String
        attribute :check_in_date, Date
        attribute :check_out_date, Date
        attribute :hotel_code, String
        attribute :destination_code, String
        attribute :rooms, Array[HotelBeds::Model::AvailableRoom]

        # validation
        validates :destination_code, length: { is: 3 }
        validates :rooms, length: { minimum: 1, maximum: 5 }
        validates :session_id, :availability_token, :contract_name,
          :contract_incoming_office_code, :check_in_date, :check_out_date,
          :hotel_code, presence: true
        validate do |service|
          unless (1..5).cover?(service.rooms.size)
            service.errors.add(:rooms, "quantity must be between 1 and 5")
          end
          unless service.rooms.all?(&:valid?)
            service.errors.add(:rooms, "are invalid")
          end
        end
      end

      include HotelBeds::Model

      # attributes
      attribute :session_id, String, default: SecureRandom.hex[0..15]
      attribute :language, String, default: "ENG"
      attribute :service, HotelService
<commit_msg>Enforced existence of destination_code in hotel basket add<commit_after>require "securerandom"
require "hotel_beds/model"
require "hotel_beds/model/available_room"

module HotelBeds
  module HotelBasketAdd
    class Request
      class HotelService
        include HotelBeds::Model

        # attributes
        attribute :availability_token, String
        attribute :contract_name, String
        attribute :contract_incoming_office_code, String
        attribute :check_in_date, Date
        attribute :check_out_date, Date
        attribute :hotel_code, String
        attribute :destination_code, String
        attribute :rooms, Array[HotelBeds::Model::AvailableRoom]

        # validation
        validates :destination_code, length: { is: 3, allow_blank: false }
        validates :rooms, length: { minimum: 1, maximum: 5 }
        validates :session_id, :availability_token, :contract_name,
          :contract_incoming_office_code, :check_in_date, :check_out_date,
          :hotel_code, presence: true
        validate do |service|
          unless (1..5).cover?(service.rooms.size)
            service.errors.add(:rooms, "quantity must be between 1 and 5")
          end
          unless service.rooms.all?(&:valid?)
            service.errors.add(:rooms, "are invalid")
          end
        end
      end

      include HotelBeds::Model

      # attributes
      attribute :session_id, String, default: SecureRandom.hex[0..15]
      attribute :language, String, default: "ENG"
      attribute :service, HotelService

{'fraction_non_alphanumeric': 0.08280467445742905, 'fraction_numerical': 0.00667779632721202, 'mean_word_length': 2.782828282828283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7047596', 'n_tokens_mistral': 843, 'n_tokens_neox': 808, 'n_words': 213}