Class: Clicksign::API::Document
- Inherits:
-
Object
- Object
- Clicksign::API::Document
- Extended by:
- Requests
- Defined in:
- lib/clicksign/api/document.rb
Constant Summary collapse
- REQUEST_PATH =
'/api/v1/documents/'- ATTRIBUTES =
[:path, :deadline_at, :auto_close, :locale]
Class Method Summary collapse
Methods included from Requests
Class Method Details
.body(params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/clicksign/api/document.rb', line 18 def body(params) document = ATTRIBUTES.each.with_object({}) do |attribute, hash| hash[attribute] = params[attribute] if params.has_key?(attribute) end if params.has_key?(:file) content_base64 = Base64.encode64(File.read(params[:file])) document[:content_base64] = "data:application/pdf;base64,#{content_base64}" end body = { document: document } end |
.create(params = {}) ⇒ Object
10 11 12 |
# File 'lib/clicksign/api/document.rb', line 10 def create(params = {}) post(REQUEST_PATH, body(params)) end |
.find(key) ⇒ Object
14 15 16 |
# File 'lib/clicksign/api/document.rb', line 14 def find(key) get(REQUEST_PATH + key) end |