MindBody Cancel Appointment Using Python

Mind Body Cancel Appointment Using Python

In last tutorial it was explained how to book an appointment here. After booking an appointment you will get Appointment ID and this ID will be used to Cancel an Appointment. Here you don’t need to do lots of things like Booking an Appointment. One can cancel appointment in two ways :

Mind Body Cancel Appointment Using Python

Way one of cancelling appointment: Pass the Appointment ID and Update action to the AddOrUpdateAppointments Method of BookAppointment.py created in last tutorial as given below.
appointment_id = XXXXXXX ## Appointment Id to be cancel i.e 10125004.
ID = {“ID”:appointment_id,”Execute”:”cancel”} ## ID is formatted as required by Mindbody.
result = BookAppointmentMethods().AddOrUpdateAppointments(ID,”Update”) ## Here Appointment ID and Action is passed

Way Two of cancelling appointment : Just make a new file Cancel_Appointment.py and copy the code given below

from datetime import datetime
from suds.client import Client
import BasicRequestHelper
import os
import json
import re

class AppointmentService():

  def Cancel_Appoinment(self):
    appointment_id = raw_input("Please Enter Appointment ID to cancel an Appointment : ")
    ID             = {"ID":appointment_id,"Execute":"cancel"}
    result         = BookAppointmentMethods().AddOrUpdateAppointments(ID,"Update")
    try:                
      if(result.Status=="InternalException"):
        print "\nAppointment cancellaton is unsuccessfully Either Appointment ID is not found or you have entered
               wrong Appointment ID"
      elif(result.Status=='Success'):
        if (result.Appointments.Appointment[0].Action=="Updated"):
          print "\nAppointment cancelled successfully"
      else:
        print "Try Again"
    except:
        print "\nInternal Error Please Try Agian"

class BookAppointmentMethods():

  serviceName = "Appointment"
  urlService  = "https://api.mindbodyonline.com/0_5/" + serviceName + "Service.asmx?wsdl"
  service = Client(urlService)

  def CreateBasicRequest(self, requestName):
      return BasicRequestHelper.CreateBasicRequest(self.service, requestName)

  def AddOrUpdateAppointments(self,appointments, updateAction,test=False,sendEmail=False,applyPayment=True):
      request = self.CreateBasicRequest("AddOrUpdateAppointments")

      request.UpdateAction = updateAction
      request.Test = test
      request.SendEmail = sendEmail
      request.ApplyPayment = applyPayment        
      request.Appointments = BasicRequestHelper.FillArrayType(self.service, [appointments], "Appointment", "Appointment")

      return self.service.service.AddOrUpdateAppointments(request)
    
AppointmentService().Cancel_Appoinment()

Run the Cancel_Appointment.py and you will be asked to enter Appointment Id that need to be cancel. After Successful cancellation you will get message on command prompt as “Appointment cancelled successfully” else you will get message “Appointment cancellation is unsuccessful”.

top

GET A FREE
MindBody Consulation

Let Experts Help You!
This Offer Is Limited! Don't Miss...
Fill out this form for a FREE, Immediate, Case Evaluation
GET HELP NOW