-
Notifications
You must be signed in to change notification settings - Fork 310
How to DELETE Items
Riley James edited this page Sep 21, 2021
·
1 revision
Can someone please tell me how I can delete an Item record.
According to https://developer.xero.com/documentation/api/items, the http DELETE verb can be used to delete an Item, but I cannot see how to do so with the Xeroizer gem - is this not implemented, or am I missing something?
the client does seem to offer .delete functionality so if I wanted to delete all products with the item code TEST_ I could do
xeroizer_client = Xeroizer::OAuth2Application.new(client_id, client_secret, access_token: access_token)
items = xeroizer_client.Item.all(where: 'Code.StartsWith("TEST_")')
items.each{ |item|
uri = URI("https://api.xero.com/api.xro/2.0/Items/#{item.item_id}")
# call delete on the client xeroizer/lib/xeroizer/oauth2.rb
xeroizer_client.client.delete(uri.request_uri)
}
might be worth to put a sleep(1) in there and items associated with inventory tracking CANNOT be deleted