<commit_before>require 'rack'

module ActionSms
  module Providers
    class CoolSmsProvider < Provider
      DELIVERED_OK = "SMS sent"
      DELIVER_EXCEPTION = "Exception: %s"
      SMS_GATEWAY_ERROR = "SMS Gateway Error Code: %s"

      def self.deliver(message)
        all_ok = false

        begin
          url = "https://api.linkmobility.dk/v2/message.json?apikey=#{ENV['COOLSMS_API_KEY']}"

          body = {
            message: {
              recipients: message.phone_number,
              sender: message.from,
              message: message.body
            }
          }

          if message.status_report_url.present?
            body[:message][:status] = true
            body[:message][:statusurl] = message.status_report_url
          end

          response = RestClient.post(url, body.to_json, content_type: 'application/json')

          all_ok = response.code == 201
          if all_ok
            parsed_response = JSON.parse(response.body)
            m.message_id = parsed_response['details']['batchid']
            m.after_send(true, DELIVERED_OK)
          else
            m.after_send(false, SMS_GATEWAY_ERROR % response.code)
          end
        rescue URI::InvalidURIError => e
          m.after_send(false, DELIVER_EXCEPTION % e.to_s)
        rescue StandardError => e
          m.after_send(false, DELIVER_EXCEPTION % e.to_s)
        end

        all_ok
      end
    end
  end
end<commit_msg>Fix one more typo...<commit_after>require 'rack'

module ActionSms
  module Providers
    class CoolSmsProvider < Provider
      DELIVERED_OK = "SMS sent"
      DELIVER_EXCEPTION = "Exception: %s"
      SMS_GATEWAY_ERROR = "SMS Gateway Error Code: %s"

      def self.deliver(message)
        all_ok = false

        begin
          url = "https://api.linkmobility.dk/v2/message.json?apikey=#{ENV['COOLSMS_API_KEY']}"

          body = {
            message: {
              recipients: message.phone_number,
              sender: message.from,
              message: message.body
            }
          }

          if message.status_report_url.present?
            body[:message][:status] = true
            body[:message][:statusurl] = message.status_report_url
          end

          response = RestClient.post(url, body.to_json, content_type: 'application/json')

          all_ok = response.code == 201
          if all_ok
            parsed_response = JSON.parse(response.body)
            message.message_id = parsed_response['details']['batchid']
            message.after_send(true, DELIVERED_OK)
          else
            message.after_send(false, SMS_GATEWAY_ERROR % response.code)
          end
        rescue URI::InvalidURIError => e
          message.after_send(false, DELIVER_EXCEPTION % e.to_s)
        rescue StandardError => e
          message.after_send(false, DELIVER_EXCEPTION % e.to_s)
        end

        all_ok
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09266276265931794, 'fraction_numerical': 0.002755769893213917, 'mean_word_length': 1.9542217700915565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3381715', 'n_tokens_mistral': 896, 'n_tokens_neox': 861, 'n_words': 166}