コード例 #1
0
 public ClassesServiceTests()
 {
     _credentials = new MindbodyHeaders
     {
         Key = "[YOUR API KEY HERE]",
         SiteId = -99,
         Username = "******"
     };
 }
コード例 #2
0
        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\"}");
            }
        }
コード例 #3
0
 public MindBodyFindersApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _finderService = new FinderService();
 }
コード例 #4
0
 public MindBodyClassesApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _classService = new ClassService();
 }
コード例 #5
0
 public MindBodySitesApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _siteService = new SiteService();
 }
コード例 #6
0
 public MindBodyApiService(MindbodyHeaders credentials)
 {
     _credentials = credentials;
 }
コード例 #7
0
 public MindBodyAppointmentsApiService(MindbodyHeaders credentials)
     : base(credentials)
 {
     _appointmentService = new AppointmentService();
 }