README.md in pdfmonkey-0.4.0 vs README.md in pdfmonkey-0.5.0

- old
+ new

@@ -92,10 +92,11 @@ "app_id": "d9ec8249-65ae-4d50-8aee-7c12c1f9683a", "checksum": "ac0c2b6bcc77e2b01dc6ca6a9f656b2d", "created_at": "2020-01-02T03:04:05.000+01:00", "document_template_id": "f7fbe2b4-a57c-46ee-8422-5ae8cc37daac", "download_url": "https://example.com/76bebeb9-9eb1-481a-bc3c-faf43dc3ac81.pdf", + "filename": "76bebeb9-9eb1-481a-bc3c-faf43dc3ac81.pdf", "id": "76bebeb9-9eb1-481a-bc3c-faf43dc3ac81", "meta": null, "payload": "{\"name\": \"John Doe\"}", "preview_url": null, "status": "success", @@ -168,9 +169,47 @@ # If the network is down document = Pdfmonkey::Document.fetch('95eb0b6e-090b-4195-9b7c-cc3d50099867') document.status # => 'error' document.errors # => ["Failed to open TCP connection to api.pdfmonkey.io:443 (getaddrinfo: nodename nor servname provided, or not known)"] +``` + +### Deleting a document + +You can delete an existing document using the `.delete` method: + +```ruby +Pdfmonkey::Document.delete('76bebeb9-9eb1-481a-bc3c-faf43dc3ac81') +#=> true +``` + +Alternatively you can call the `#delete!` method: + +```ruby +document.delete! +#=> true +``` + +#### Error handling + +In case of error, be it an HTTP layer error or an API error, an error Hash will be returned. + +```ruby +document.delete! +#=> true + +document.delete! +# { +# errors: ["We couldn't find any Document with ID \"11111111-2222-3333-4444-555555555555\". If ..."], +# status: "error" +# } + +# If the network is down +document.delete! +# { +# errors: ["Failed to open TCP connection to api.pdfmonkey.io:443 (getaddrinfo: nodename nor servname provided, or not known)"], +# status: "error" +# } ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.