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



151
152
153
# File 'lib/files.com/models/form_field_set.rb', line 151

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)


178
179
180
181
182
183
184
185
# File 'lib/files.com/models/form_field_set.rb', line 178

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: title must be an String") if params[:title] and !params[:title].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: form_fields must be an Array") if params[:form_fields] and !params[: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



205
206
207
208
209
210
211
212
213
# File 'lib/files.com/models/form_field_set.rb', line 205

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

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

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



215
216
217
218
# File 'lib/files.com/models/form_field_set.rb', line 215

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

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

Parameters:

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


157
158
159
160
161
162
163
164
165
# File 'lib/files.com/models/form_field_set.rb', line 157

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



167
168
169
# File 'lib/files.com/models/form_field_set.rb', line 167

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.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).


141
142
143
144
145
146
147
148
149
# File 'lib/files.com/models/form_field_set.rb', line 141

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[: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)


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

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



111
112
113
114
115
116
117
118
119
# File 'lib/files.com/models/form_field_set.rb', line 111

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[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

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

#destroy(params = {}) ⇒ Object



121
122
123
124
# File 'lib/files.com/models/form_field_set.rb', line 121

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

#form_fieldsObject

array(object) - 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

array(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

#in_useObject

boolean - Form Field Set is in use by an active Inbox / Bundle / Inbox Registration / Bundle Registration



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

def in_use
  @attributes[:in_use]
end

#in_use=(value) ⇒ Object



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

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

#saveObject



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

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

  @attributes = new_obj.attributes
  true
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)


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

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[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: title must be an String") if params[:title] and !params[:title].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: form_fields must be an Array") if params[:form_fields] and !params[:form_fields].is_a?(Array)
  raise MissingParameterError.new("Parameter missing: id") unless params[: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.



85
86
87
# File 'lib/files.com/models/form_field_set.rb', line 85

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



89
90
91
# File 'lib/files.com/models/form_field_set.rb', line 89

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