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')

测试

安装nose testing framework

pip install nose

安装mock模拟和测试库:

pip install mock

您可以通过运行以下命令运行测试:

nosetests

起毛

安装flake8

pip install flake8

您可以通过运行

flake8 checkmate

在根目录中。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaSpringMVC控制器测试打印结果JSON字符串   若catch语句返回,那个么为什么它最终会阻塞呢?   java Grails中servletContext在哪里可用?   java Jhipster:如何为现有项目启用多种语言   java异常评估SpringEL表达式:“#fields.hasErrors('something')”   java如何验证SeleniumWebDriver中的文本颜色?   java在绘图时使用JPanel坐标   java如何初始化spring启动到project?   java如何通过JDBC的PreparedStatement将UUID数组插入HyperSQL数据库   java修改JVM以跨线程序列化文件访问   Javascript到Java正则表达式   使用Java运行时调用aspell程序时出现字符集问题。getRuntime()。执行官   执行RDP时的java Sukuli按钮识别   java如何使用okhttp更改connect请求的标头   java无法创建Maven Eclipse项目