Class: Formable::Templates

Inherits:
Object
  • Object
show all
Defined in:
lib/formable/resources/templates.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Templates

Returns a new instance of Templates.



11
12
13
# File 'lib/formable/resources/templates.rb', line 11

def initialize(http)
  @http = http
end

Instance Method Details

#create(file:, filename: nil, signer_roles: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/formable/resources/templates.rb', line 15

def create(file:, filename: nil, signer_roles: nil)
  io_or_path, resolved_filename = normalize_file(file, filename)
  fields = {
    "file" => Faraday::Multipart::FilePart.new(
      io_or_path,
      "application/octet-stream",
      resolved_filename
    ),
    "filename" => resolved_filename
  }
  unless signer_roles.nil?
    fields["signer_roles"] = JSON.generate(signer_roles)
  end
  @http.post_form("/templates", fields)
end

#create_edit_url(template_id) ⇒ Object



31
32
33
# File 'lib/formable/resources/templates.rb', line 31

def create_edit_url(template_id)
  @http.post("/templates/#{Params.encode_path(template_id)}/edit-url")
end