public ClassesServiceTests()
 {
     _credentials = new MindbodyHeaders
     {
         Key = "[YOUR API KEY HERE]",
         SiteId = -99,
         Username = "******"
     };
 }
        public override async Task Invoke(IOwinContext context)
        {
            string[] vals;
            string userName = null;
            string apiKey = null;
            bool siteProvided = false;
            int siteId = 0;

            if (context.Request.Headers.TryGetValue(MindbodyHeaders.UsernameHeaderKey, out vals))
            {
                userName = (vals == null || vals.Length == 0) ? String.Empty : vals[0];
            }

            if (context.Request.Headers.TryGetValue(MindbodyHeaders.ApiKeyHeaderKey, out vals))
            {
                apiKey = (vals == null || vals.Length == 0) ? String.Empty : vals[0];
            }

            if (context.Request.Headers.TryGetValue(MindbodyHeaders.SiteIdHeaderKey, out vals))
            {
                siteProvided = Int32.TryParse((vals == null || vals.Length == 0) ? String.Empty : vals[0], out siteId);
            }

            bool containsAllHeaders = !String.IsNullOrEmpty(userName) &&
                                        !String.IsNullOrEmpty(apiKey) &&
                                        siteProvided;

            if (!context.Request.Uri.AbsolutePath.Contains("/api/") || containsAllHeaders)
            {
                var headers = new MindbodyHeaders
                {
                    Key = apiKey,
                    SiteId = siteId,
                    Username = userName
                };

                context.Set<MindbodyHeaders>(MindbodyHeaders.OwinKey, headers);

                await Next.Invoke(context);
            }
            else
            {
                context.Response.StatusCode = 400;
                context.Response.ContentType = "application/json";
                await context.Response.WriteAsync("{Message:\"Missing credentials\"}");
            }
        }
 public MindBodyFindersApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _finderService = new FinderService();
 }
 public MindBodyClassesApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _classService = new ClassService();
 }
 public MindBodySitesApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _siteService = new SiteService();
 }
 public MindBodyApiService(MindbodyHeaders credentials)
 {
     _credentials = credentials;
 }
 public MindBodyAppointmentsApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _appointmentService = new AppointmentService();
 }