memorandum.
Get user information from Garoon SOAP API with Python + Zeep https://qiita.com/yamashi6/items/d360546eb4ccf2495951
Common specifications of Garoon SOAP API https://developer.cybozu.io/hc/ja/articles/202228464
Search for appointments https://developer.cybozu.io/hc/ja/articles/202235474
from zeep import Client
from zeep import xsd
client = Client(wsdl='https://(Subdomain name).cybozu.com/g/index.csp?WSDL')
#You can't use schedule acquisition unless you bind
sc_client = client.bind('ScheduleService', 'SchedulePort')
header = xsd.ComplexType([
xsd.Element('Action', xsd.String()),
xsd.Element('Security',
xsd.ComplexType([xsd.Element(
'UsernameToken',
xsd.ComplexType([
xsd.Element('Username', xsd.String()),
xsd.Element('Password', xsd.String()),
])
)]
)),
xsd.Element('Timestamp',
xsd.ComplexType([
xsd.Element('Created', xsd.String()),
xsd.Element('Expires', xsd.String()),
])
),
xsd.Element('Locale', xsd.String()),
])
header_value = header(
Action="ScheduleSearchEvents",
#Changing users and passwords
Security={'UsernameToken':{'Username':'','Password':''}},
Timestamp={'Created':'2010-08-12T14:45:00Z','Expires':'2037-08-12T14:45:00Z'},
Locale="jp")
#This way of writing is also OK
# header_value = header("ScheduleSearchEvents",
# {'UsernameToken':{'Username':'', 'Password':''}},
# {'Created':'2010-08-12T14:45:00Z','Expires':'2037-08-12T14:45:00Z'},
# 'jp')
request = xsd.Element('parameters',
xsd.ComplexType([
xsd.Attribute('text', xsd.String()),
xsd.Attribute('start', xsd.String()),
xsd.Attribute('end', xsd.String()),
xsd.Attribute('title_search', xsd.Boolean()),
xsd.Attribute('customer_search', xsd.Boolean()),
xsd.Attribute('memo_search', xsd.Boolean()),
xsd.Attribute('follow_search', xsd.Boolean()),
xsd.Attribute('all_repeat_events', xsd.Boolean())])
)
request_data = request("test","2019-06-06T02:00:00Z", "2019-07-07T02:00:00Z", True, False, False, False, False)
#This way of writing is also OK
# request_data = request(
# text='test',
# start= "2019-06-06T02:00:00Z",
# end="2019-10-07T02:00:00Z",
# title_search= True,
# customer_search=False,
# memo_search=False,
# follow_search=False,
# all_repeat_events=False
# )
try:
response = sc_client.ScheduleSearchEvents(request_data, _soapheaders=[header_value])
#Returned in list
print(response)
except:
import traceback
traceback.print_exc()
Returned in list
[{
'members': {
'member': [
{
'user': {
'id': '1',
'order': 0,
'_attr_1': {
'name': 'Yamada Taro'
}
},
'organization': None,
'facility': None,
'_value_1': None,
'_attr_1': None
}
],
'_value_1': None,
'_attr_1': None
},
'observers': None,
'customer': None,
'repeat_info': None,
'when': {
'_attr_1': None,
'datetime': [
{
'_value_1': None,
'start': datetime.datetime(2019, 6, 20, 10, 0, tzinfo=<isodate.tzinfo.Utc object at 0x000001B4773B0F08>),
'end': datetime.datetime(2019, 6, 20, 12, 0, tzinfo=<isodate.tzinfo.Utc object at 0x000001B4773B0F08>),
'facility_id': None,
'_attr_1': {
}
}
],
'date': None
},
'follows': None,
'file': [],
'remove_file_id': [],
'_value_1': None,
'id': '11111',
'event_type': 'normal',
'version': '111111111',
'public_type': 'public',
'plan': 'Meeting',
'detail': 'test',
'description': 'test',
'timezone': 'Asia/Tokyo',
'end_timezone': 'Asia/Tokyo',
'allday': False,
'start_only': False,
'hidden_private': None,
'facility_using_purpose': None,
'_attr_1': {
}
}]
Recommended Posts