Module: CurdBee::Invoiceable

Included in:
Estimate, Invoice
Defined in:
lib/curdbee/invoiceable.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



11
12
13
14
# File 'lib/curdbee/invoiceable.rb', line 11

def close
 response = self.class.send_request(:post, "/#{self.class.resource}/#{self[:id]}/close")
 return true if response.code.to_i == 200
end

#deliver(send_list = {}) ⇒ Object



21
22
23
24
25
# File 'lib/curdbee/invoiceable.rb', line 21

def deliver(send_list={}) 
 body = {:delivery => send_list}.to_json
 response = self.class.send_request(:post, "/deliver/#{self.class.element}/#{self[:id]}", :body => body)
 return true if response.code.to_i == 200
end

#duplicateObject

common methods for invoices and estimates



6
7
8
9
# File 'lib/curdbee/invoiceable.rb', line 6

def duplicate
 response = self.class.send_request(:post, "/#{self.class.resource}/#{self[:id]}/duplicate")
 self.class.new(response["#{self.class.element}"])
end


27
28
29
30
31
32
33
34
# File 'lib/curdbee/invoiceable.rb', line 27

def permalink
 statement_type = self.class.element == "estimate" ? "est" : "inv"
 unless self.hash_key.nil? || self.hash_key.empty?
   "#{self.class.base_uri}/#{statement_type}/#{self.hash_key}" 
 else
   ""
 end
end

#reopenObject



16
17
18
19
# File 'lib/curdbee/invoiceable.rb', line 16

def reopen
 response = self.class.send_request(:post, "/#{self.class.resource}/#{self[:id]}/reopen")
 return true if response.code.to_i == 200
end