```import requests import json from requests_oauth...
# suitetalkapi
y
Copy code
import requests
import json
from requests_oauthlib import OAuth1

client_key = 'xx'
client_secret = 'xx'
access_token = 'xx'
access_token_secret = 'xx'
realm = 'xx'
oauth = OAuth1(client_key, client_secret, access_token, access_token_secret,
               signature_method='HMAC-SHA256', realm=realm)

def del_employee(id_value):
    headers = {
      'prefer': 'transient',
      'Content-Type': 'application/json',
      'Cookie': 'NS_ROUTING_VERSION=LAGGING'
    }
    url_d = f"<https://xxxxxx.suitetalk.api.netsuite.com/services/rest/record/v1/employee/{id_value}>"
    print(url_d)
    response = requests.request("DELETE", url=url_d, auth=oauth, headers=headers)
    status = response.text
    print(status)

firstname = "'Yogi'"
lastname = "'Test'"
createdate = "'16/3/2023%'"
deputy_instance = "'xxxxxxxxxxx'"
ids = "('5379753','5382764')"

def list_employee():
    payload = {
    "q": f"SELECT id, firstname, lastname, email, lastmodifieddate, datecreated, custentity_pkf_integration_instance,custentity_pkf_integration_identifier FROM employee where firstname = {firstname} and lastname = {lastname} and custentity_pkf_integration_instance = {deputy_instance} and id not in {ids}"
    }
    # datecreated like {createdate} and
    print(payload)
    headers = {
    'prefer': 'transient',
    'Content-Type': 'application/json',
    'Cookie': 'NS_ROUTING_VERSION=LAGGING'
    }
    url_q = "<https://xxxxxx.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000>"
    response = requests.request("POST", url = url_q, auth=oauth, headers=headers, json=payload)
    data_emp = json.loads(response.text)
    #print(data_emp)
    for item in data_emp['items']:
        id_value = item['id']
        name_value = item['firstname']
        lastname_value = item['lastname']
        instance_value = item['custentity_pkf_integration_instance']
        created_value = item['datecreated']
        print(f"==> InternalID {id_value}  Name {name_value} {lastname_value} from deputy instance {instance_value} created on {created_value} will be deleted ")
        #print(name_value)
        #print(instance_value)
        #del_employee(id_value)
list_employee()