lib/pdfmonkey/document.rb in pdfmonkey-0.4.0 vs lib/pdfmonkey/document.rb in pdfmonkey-0.5.0

- old
+ new

@@ -13,10 +13,11 @@ checksum created_at document_template_id download_url errors + filename id meta payload preview_url status @@ -28,10 +29,14 @@ MEMBER = 'document' attr_reader :attributes def_delegators :attributes, *ATTRIBUTES + def self.delete(document_id) + new(id: document_id).delete! + end + def self.fetch(document_id) new(id: document_id).reload! end def self.generate!(document_template_id, payload, meta = {}) @@ -52,9 +57,13 @@ def initialize(adapter: Pdfmonkey::Adapter.new, **attributes) @adapter = adapter @attributes = OpenStruct.new(ATTRIBUTES.zip([]).to_h) update(attributes) + end + + def delete! + adapter.call(:delete, self) end def done? COMPLETE_STATUSES.include?(status) end