internal static string GenerateEndPointUri(string resourceTemplateUri, ApiRequestSettings requestSettings, Dictionary<string, string> args)
        {
            StringBuilder endpointUri = new StringBuilder();

              if (requestSettings.Host[requestSettings.Host.Length - 1] == '/')
              {
            endpointUri.Append(requestSettings.Host);
              }
              else
              {
            endpointUri.Append(requestSettings.Host);
            endpointUri.Append("/");
              }

              string template = Regex.Replace(resourceTemplateUri, @"\{(.+?)\}", m => args[m.Groups[1].Value], RegexOptions.IgnoreCase);

              if (template[0] == '/')
              {
            endpointUri.Append(template.Substring(1));
              }
              else
              {
            endpointUri.Append(template);
              }

              return endpointUri.ToString();
        }
        public ApiRequest(ApiRequestSettings requestSettings)
        {
            if (requestSettings == null)
              {
            throw new ArgumentNullException("requestSettings");
              }

              this.requestSettings = requestSettings;
              this.apiHttpRequester = new ApiHttpRequest(requestSettings);
        }
        private IContainer BuildMVCContainer()
        {
            var builder = new ContainerBuilder();

              var apiRequestSettings = new ApiRequestSettings()
              {
            Host = ConfigurationManager.AppSettings["RefUnitedApiHostName"],
            UserName = ConfigurationManager.AppSettings["RefUnitedApiUserName"],
            Password = ConfigurationManager.AppSettings["RefUnitedApiPassword"]
              };

              string twilioAccountSid = ConfigurationManager.AppSettings["TwilioAccountSid"];
              string twilioAuthToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
              string twilioPhoneNumber = ConfigurationManager.AppSettings["TwilioPhoneNumber"];

              var azureTableStorageConnectionString = ConfigurationManager.AppSettings["AzureTableStorageConnectionString"];

              builder.Register<IApiRequest>(m => new ApiRequest(apiRequestSettings)).SingleInstance();
              builder.Register<IIVRRouteProvider>(m => new IVRRouteProvider());

              builder.Register<IProfileRepository>(m => new ProfileRepository(azureTableStorageConnectionString)).SingleInstance();
              builder.Register<IRecordingRepository>(m => new RecordingRepository(azureTableStorageConnectionString)).SingleInstance();

              builder.Register<IRefugeesUnitedAccountManager>(m => new RefugeesUnitedAccountManager(m.Resolve<IApiRequest>())).SingleInstance();
              builder.Register<IProfileManager>(m => new ProfileManager(m.Resolve<IProfileRepository>(), m.Resolve<IRecordingRepository>(), m.Resolve<IRefugeesUnitedAccountManager>())).SingleInstance();
              builder.Register<IBroadcastManager>(m => new BroadcastManager()).SingleInstance();

              builder.Register<ISMSReceiverLogic>(m=>new SMSReceiverLogic(twilioAccountSid, twilioAuthToken, twilioPhoneNumber)).InstancePerHttpRequest();

              builder.Register<IIVREntryLogic>(m => new IVREntryLogic(m.Resolve<IProfileManager>())).InstancePerHttpRequest();
              builder.Register<IIVRMainLogic>(m => new IVRMainLogic(m.Resolve<IProfileManager>(), m.Resolve<IRefugeesUnitedAccountManager>(), m.Resolve<IIVRRouteProvider>()));
              builder.Register<IIVRAuthenticateLogic>(m => new IVRAuthenticateLogic(m.Resolve<IProfileManager>(), m.Resolve<IIVRRouteProvider>()));
              builder.Register<IIVRBroadcastLogic>(m => new IVRBroadcastLogic(m.Resolve<IBroadcastManager>(), m.Resolve<IIVRRouteProvider>(), m.Resolve<IProfileManager>()));

              builder.RegisterControllers(typeof(MvcApplication).Assembly);
              builder.RegisterApiControllers(typeof(MvcApplication).Assembly);

              return builder.Build();
        }