Class: Files::FormFieldSet

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/form_field_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ FormFieldSet

Returns a new instance of FormFieldSet.



7
8
9
10
# File 'lib/files.com/models/form_field_set.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/form_field_set.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/form_field_set.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



139
140
141
# File 'lib/files.com/models/form_field_set.rb', line 139

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
title - string - Title to be displayed
skip_email - boolean - Skip validating form email
skip_name - boolean - Skip validating form name
skip_company - boolean - Skip validating company
form_fields - array(object)


166
167
168
169
170
171
172
173
# File 'lib/files.com/models/form_field_set.rb', line 166

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: title must be an String") if params.dig(:title) and !params.dig(:title).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: form_fields must be an Array") if params.dig(:form_fields) and !params.dig(:form_fields).is_a?(Array)

  response, options = Api.send_request("/form_field_sets", :post, params, options)
  FormFieldSet.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



193
194
195
196
197
198
199
200
201
# File 'lib/files.com/models/form_field_set.rb', line 193

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/form_field_sets/#{params[:id]}", :delete, params, options)
  response.data
end

.destroy(id, params = {}, options = {}) ⇒ Object



203
204
205
# File 'lib/files.com/models/form_field_set.rb', line 203

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - Form Field Set ID.


145
146
147
148
149
150
151
152
153
# File 'lib/files.com/models/form_field_set.rb', line 145

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/form_field_sets/#{params[:id]}", :get, params, options)
  FormFieldSet.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



155
156
157
# File 'lib/files.com/models/form_field_set.rb', line 155

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).


129
130
131
132
133
134
135
136
137
# File 'lib/files.com/models/form_field_set.rb', line 129

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)

  List.new(FormFieldSet, params) do
    Api.send_request("/form_field_sets", :get, params, options)
  end
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

title - string - Title to be displayed
skip_email - boolean - Skip validating form email
skip_name - boolean - Skip validating form name
skip_company - boolean - Skip validating company
form_fields - array(object)


181
182
183
184
185
186
187
188
189
190
191
# File 'lib/files.com/models/form_field_set.rb', line 181

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: title must be an String") if params.dig(:title) and !params.dig(:title).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: form_fields must be an Array") if params.dig(:form_fields) and !params.dig(:form_fields).is_a?(Array)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/form_field_sets/#{params[:id]}", :patch, params, options)
  FormFieldSet.new(response.data, options)
end

Instance Method Details

#delete(params = {}) ⇒ Object



102
103
104
105
106
107
108
109
110
# File 'lib/files.com/models/form_field_set.rb', line 102

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/form_field_sets/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



112
113
114
# File 'lib/files.com/models/form_field_set.rb', line 112

def destroy(params = {})
  delete(params)
end

#form_fieldsObject

FormField - Associated form fields



40
41
42
# File 'lib/files.com/models/form_field_set.rb', line 40

def form_fields
  @attributes[:form_fields]
end

#form_fields=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/form_field_set.rb', line 44

def form_fields=(value)
  @attributes[:form_fields] = value
end

#form_layoutObject

int64 - Layout of the form



31
32
33
# File 'lib/files.com/models/form_field_set.rb', line 31

def form_layout
  @attributes[:form_layout]
end

#form_layout=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/form_field_set.rb', line 35

def form_layout=(value)
  @attributes[:form_layout] = value
end

#idObject

int64 - Form field set id



13
14
15
# File 'lib/files.com/models/form_field_set.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/form_field_set.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#saveObject



116
117
118
119
120
121
122
123
# File 'lib/files.com/models/form_field_set.rb', line 116

def save
  if @attributes[:id]
    update(@attributes)
  else
    new_obj = FormFieldSet.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end

#skip_companyObject

boolean - Any associated InboxRegistrations or BundleRegistrations can be saved without providing company



67
68
69
# File 'lib/files.com/models/form_field_set.rb', line 67

def skip_company
  @attributes[:skip_company]
end

#skip_company=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/form_field_set.rb', line 71

def skip_company=(value)
  @attributes[:skip_company] = value
end

#skip_emailObject

boolean - Any associated InboxRegistrations or BundleRegistrations can be saved without providing email



58
59
60
# File 'lib/files.com/models/form_field_set.rb', line 58

def skip_email
  @attributes[:skip_email]
end

#skip_email=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/form_field_set.rb', line 62

def skip_email=(value)
  @attributes[:skip_email] = value
end

#skip_nameObject

boolean - Any associated InboxRegistrations or BundleRegistrations can be saved without providing name



49
50
51
# File 'lib/files.com/models/form_field_set.rb', line 49

def skip_name
  @attributes[:skip_name]
end

#skip_name=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/form_field_set.rb', line 53

def skip_name=(value)
  @attributes[:skip_name] = value
end

#titleObject

string - Title to be displayed



22
23
24
# File 'lib/files.com/models/form_field_set.rb', line 22

def title
  @attributes[:title]
end

#title=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/form_field_set.rb', line 26

def title=(value)
  @attributes[:title] = value
end

#update(params = {}) ⇒ Object

Parameters:

title - string - Title to be displayed
skip_email - boolean - Skip validating form email
skip_name - boolean - Skip validating form name
skip_company - boolean - Skip validating company
form_fields - array(object)


90
91
92
93
94
95
96
97
98
99
100
# File 'lib/files.com/models/form_field_set.rb', line 90

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: title must be an String") if params.dig(:title) and !params.dig(:title).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: form_fields must be an Array") if params.dig(:form_fields) and !params.dig(:form_fields).is_a?(Array)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/form_field_sets/#{@attributes[:id]}", :patch, params, @options)
end

#user_idObject

int64 - User ID. Provide a value of ‘0` to operate the current session’s user.



76
77
78
# File 'lib/files.com/models/form_field_set.rb', line 76

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



80
81
82
# File 'lib/files.com/models/form_field_set.rb', line 80

def user_id=(value)
  @attributes[:user_id] = value
end