checkmate rest api的python包装器。
checkmate-api的Python项目详细描述
将死
checkmate rest api的python包装器
安装
安装:
pip install checkmate-api
或
easy_install checkmate-api
用法
importcheckmateclient=checkmate.CheckMate(api_key='YOUR_KEY_HERE')
注意::如果需要,还可以使用api_base关键字参数传入其他api url。
client=checkmate.CheckMate(api_key='YOUR_KEY_HERE',api_base='API_URL_HERE')
请参阅documentation了解每个调用所需/可选内容的最后一个单词。
搜索属性
可以查询api以获取属性。查询中引用的所有字段都是必需的。
client.properties.search({'name':'Hotel Kabuki','phone':'14159223200','address':{'street':'1625 Post St','city':'San Francisco','region':'CA','postal_code':'94115','country_code':'US'}})
列出预订
您可以查询api以获取所有保留或特定属性的保留。
# paginated list of all reservationsclient.reservations.list()# fetching a different page of reservationsclient.reservations.list({'page':2})# reservations with a specific confirmation numberclient.reservations.list({'confirmation_num':'12349asdf'})# reservations for property with id 13434543client.reservations.list({'property_id':13434543})# exclude property data from the responseclient.reservations.list({'exclude_properties':'true'})
显示预订
您可以从checkmate api请求特定的预订。
# reservation with id 123452client.reservations.show(123452)
创建预订
可以使用现有的属性ID或在请求中创建新的属性来创建校验位中的保留。
# reservation under property 93client.reservations.create({'external_id':'someid123','confirmation_number':'sdlfkjweo324','first_name':'Jane','last_name':'Smith','email':'jane@smith.io','start_on':'2016-12-20','end_on':'2016-12-24','property_id':93})# creating a new propertyclient.reservations.create({'external_id':'someid123','confirmation_number':'sdlfkjweo324','first_name':'Jane','last_name':'Smith','email':'jane@smith.io','start_on':'2016-12-20','end_on':'2016-12-24','property':{'name':'New Hotel','address':{'street':'123 Leaf Lane','city':'Brooklyn','region':'NY','postal_code':'11201','country_code':'US'}}})
更新预订
可以使用保留预订ID更新CytMeTM中的现有预订。
# reservation id 12345client.reservations.update(12345,{'loyalty_number':'abs2332'})
删除预订
可以使用保留保留ID删除.COMPATE中的现有预订。
# reservation id 12345client.reservations.destroy(12345)
批量创建预订
每个保留遵循与单个保留相同的格式(可以在末尾添加可选的webhook)。
client.reservations.bulk_create([{'external_id':'fdoo','confirmation_number':'','first_name':'Frank','last_name':'Smith','email':'frank@example.com','start_on':'2015-12-20','end_on':'2015-12-24','property_id':123},{'external_id':'hfg34','confirmation_number':'gjhhffgh456','first_name':'John','last_name':'Doe','email':'johndoe@example.com','start_on':'2015-11-20','end_on':'2015-11-24','property_id':123}],'https://example.com/callback')