<commit_before>module Pushr
  class MessageGcm < Pushr::Message
    POSTFIX = 'gcm'
    validates :collapse_key, :presence => true
    # TODO: validates max size -> The message size limit is 4096 bytes.
    # The total size of the payload data that is included in a message can't exceed 4096 bytes.
    # Note that this includes both the size of the keys as well as the values.
    attr_accessor :type, :app, :device, :collapse_key, :delay_when_idle, :time_to_live, :payload

    def to_message
      hsh = Hash.new
      hsh['registration_ids'] = [device]
      hsh['collapse_key'] = collapse_key
      hsh['delay_when_idle'] = delay_when_idle if delay_when_idle
      hsh['time_to_live'] = time_to_live if time_to_live
      hsh['data'] = payload
      MultiJson.dump(hsh)
    end

    def to_json
      MultiJson.dump({ type: self.class.to_s, app: @app, device: @device, collapse_key: @collapse_key, delay_when_idle: @delay_when_idle, time_to_live: @time_to_live, payload: @payload })<commit_msg>collapse_key is not required<commit_after>module Pushr
  class MessageGcm < Pushr::Message
    POSTFIX = 'gcm'
    # TODO: validates max size -> The message size limit is 4096 bytes.
    # The total size of the payload data that is included in a message can't exceed 4096 bytes.
    # Note that this includes both the size of the keys as well as the values.
    attr_accessor :type, :app, :device, :collapse_key, :delay_when_idle, :time_to_live, :payload

    def to_message
      hsh = Hash.new
      hsh['registration_ids'] = [device]
      hsh['collapse_key'] = collapse_key if collapse_key
      hsh['delay_when_idle'] = delay_when_idle if delay_when_idle
      hsh['time_to_live'] = time_to_live if time_to_live
      hsh['data'] = payload
      MultiJson.dump(hsh)
    end

    def to_json
      MultiJson.dump({ type: self.class.to_s, app: @app, device: @device, collapse_key: @collapse_key, delay_when_idle: @delay_when_idle, time_to_live: @time_to_live, payload: @payload })
{'fraction_non_alphanumeric': 0.09334006054490414, 'fraction_numerical': 0.008072653884964682, 'mean_word_length': 3.778313253012048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4193347', 'n_tokens_mistral': 668, 'n_tokens_neox': 653, 'n_words': 199}