Class: Supersaas::Forms

Inherits:
BaseApi show all
Defined in:
lib/supersaas-api-client/api/forms.rb

Overview

Constant Summary

Constants inherited from BaseApi

BaseApi::DATETIME_REGEX, BaseApi::INTEGER_REGEX, BaseApi::PROMOTION_REGEX

Instance Attribute Summary

Attributes inherited from BaseApi

#client

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize

Constructor Details

This class inherits a constructor from Supersaas::BaseApi

Instance Method Details

#formsObject



22
23
24
25
26
# File 'lib/supersaas-api-client/api/forms.rb', line 22

def forms
  path = '/super_forms'
  res = client.get(path)
  res.map { |attributes| Supersaas::SuperForm.new(attributes) }
end

#get(form_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/supersaas-api-client/api/forms.rb', line 15

def get(form_id)
  path = '/forms'
  params = { id: validate_id(form_id) }
  res = client.get(path, params)
  Supersaas::Form.new(res)
end

#list(template_form_id, from_time = nil, user = nil) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/supersaas-api-client/api/forms.rb', line 6

def list(template_form_id, from_time = nil, user = nil)
  path = '/forms'
  params = { form_id: validate_id(template_form_id) }
  params.merge!(from: validate_datetime(from_time)) if from_time
  params.merge!(user: validate_user(user)) if user
  res = client.get(path, params)
  res.map { |attributes| Supersaas::Form.new(attributes) }
end