Added working delete function for photos (#159)

Co-authored-by: sebastian messier <sebastian.messier@flexreceipts.com>
This commit is contained in:
s.m 2020-03-20 13:48:24 -04:00 committed by GitHub
parent 0382bddbec
commit f69833637c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -505,6 +505,35 @@ class PhotoAsset(object):
**kwargs
)
def delete(self):
recordName = self._asset_record['recordName']
recordType = self._asset_record['recordType']
recordChangeTag = self._master_record['recordChangeTag']
json_data = ('{"query":{"recordType":"CheckIndexingState"},'
'"zoneID":{"zoneName":"PrimarySync"}}')
json_data = ('{"operations":[{'
'"operationType":"update",'
'"record":{'
'"recordName":"%s","recordType":"%s",'
'"recordChangeTag":"%s",'
'"fields":{"isDeleted":{"value":1}'
'}}}],'
'"zoneID":{'
'"zoneName":"PrimarySync"'
'},"atomic":true}'
% (recordName, recordType, recordChangeTag))
endpoint = self._service._service_endpoint
params = urlencode(self._service.params)
url = ('%s/records/modify?%s' % (endpoint, params))
return self._service.session.post(
url,
data=json_data,
headers={'Content-type': 'text/plain'}
)
def __repr__(self):
return "<%s: id=%s>" % (
type(self).__name__,