<commit_before>require 'sinatra'
require 'twilio-ruby'
require 'psych'

settings = Psych.load(File.read('config.yml'))


# Basic health check - check environment variables have been configured
# correctly
get '/' do
  erb :index, locals: {settings: settings}
end

post '/register' do
  # Authenticate with Twilio
  client = Twilio::REST::Client.new settings['TWILIO_ACCOUNT_SID'], settings['TWILIO_AUTH_TOKEN']
end
<commit_msg>Register bindings from the app to Twilio<commit_after>require 'sinatra'
require 'twilio-ruby'
require 'psych'

settings = Psych.load(File.read('config.yml'))


# Basic health check - check environment variables have been configured
# correctly
get '/' do
  erb :index, locals: {settings: settings}
end

post '/register' do
  # Authenticate with Twilio
  client = Twilio::REST::Client.new settings['TWILIO_ACCOUNT_SID'], settings['TWILIO_AUTH_TOKEN']
  
  # Reference a valid notification service
  service = client.notifications.v1.services(settings['TWILIO_NOTIFICATION_SERVICE_SID'])
  
  begin 
    binding = service.bindings.create(
      endpoint: params[:endpoint],
      identity: params[:identity],
      binding_type: params[:BindingType],
      address: params[:Address],
    )
    response = {message: 'Binding created!' }
    response.to_json
  rescue Twilio::REST::TwilioException => e
    status 500
      response = {
        message: "Failed to create binding: #{e.message}",
        error: e
      }
      response.to_json
  end
end

{'fraction_non_alphanumeric': 0.11238997968855789, 'fraction_numerical': 0.002708192281651997, 'mean_word_length': 4.222614840989399, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3149701', 'n_tokens_mistral': 460, 'n_tokens_neox': 439, 'n_words': 119}