Module: Forms

Included in:
Content
Defined in:
lib/user/content/forms.rb

Instance Method Summary collapse

Instance Method Details

#create_form(data, options = nil) ⇒ Object

Create form.

Create a form with data.

Parameters

data

(Hash) – Data to be submitted.

Example

data = {
  title: 'New Form',
  slug: 'new-form-slug'
}
@data = @mints_user.create_form(data)
[View source]

176
177
178
# File 'lib/user/content/forms.rb', line 176

def create_form(data, options = nil)
  @client.raw('post', '/content/forms', options, data_transform(data))
end

#delete_form(id) ⇒ Object

Delete form.

Delete a form.

Parameters

id

(Integer) – Form id.

Example

@data = @mints_user.delete_form(9)
[View source]

205
206
207
# File 'lib/user/content/forms.rb', line 205

def delete_form(id)
  @client.raw('delete', "/content/forms/#{id}")
end

#delete_form_submission(id) ⇒ Object

Delete form submission.

Delete a form submission.

Parameters

id

(Integer) – Form submission id.

Example

@data = @mints_user.delete_form_submission(1)
[View source]

143
144
145
# File 'lib/user/content/forms.rb', line 143

def delete_form_submission(id)
  @client.raw('delete', "/content/forms/submissions/#{id}")
end

#duplicate_form(id) ⇒ Object

Duplicate form.

Duplicate a form.

Parameters

id

(Integer) – Form id.

Example

@data = @mints_user.duplicate_form(3)
[View source]

78
79
80
# File 'lib/user/content/forms.rb', line 78

def duplicate_form(id)
  @client.raw('post', "/content/forms/#{id}/duplicate")
end

#get_form(id, options = nil) ⇒ Object

Get form.

Get a form info.

Parameters

id

(Integer) – Form id.

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @mints_user.get_form(9)

Second Example

options = { sort: 'id', fields: 'title' }
@data = @mints_user.get_form(2, options)
[View source]

160
161
162
# File 'lib/user/content/forms.rb', line 160

def get_form(id, options = nil)
  @client.raw('get', "/content/forms/#{id}", options)
end

#get_form_activation_words(id) ⇒ Object

Get activation words form.

Get activation words a form.

Parameters

id

(Integer) – Form id.

Example

@data = @mints_user.get_form_activation_words(3)
[View source]

90
91
92
# File 'lib/user/content/forms.rb', line 90

def get_form_activation_words(id)
  @client.raw('post', "/content/forms/#{id}/activation-words")
end

#get_form_aggregates(id, object_id) ⇒ Object

Get form aggregates.

Get a form aggregates info.

Parameters

id

(Integer) – Form id.

object_id

(Integer) – Object id.

First Example

@data = @mints_user.get_form_aggregates(1)
[View source]

217
218
219
# File 'lib/user/content/forms.rb', line 217

def get_form_aggregates(id, object_id)
  @client.raw('get', "/content/forms/#{id}/aggregates?object_id=#{object_id}", options)
end

#get_form_submission(id, options) ⇒ Object

Get form submission.

Get form submission.

Parameters

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @mints_user.get_form_submissions

Second Example

options = { fields: 'id' }
@data = @mints_user.get_form_submissions(options)
[View source]

131
132
133
# File 'lib/user/content/forms.rb', line 131

def get_form_submission(id, options)
  @client.raw('get', "/content/forms/submissions/#{id}", options)
end

#get_form_submissions(options = nil) ⇒ Object

Get form submissions.

Get form submissions.

Parameters

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @mints_user.get_form_submissions

Second Example

options = { fields: 'id' }
@data = @mints_user.get_form_submissions(options)
[View source]

115
116
117
# File 'lib/user/content/forms.rb', line 115

def get_form_submissions(options = nil)
  @client.raw('get', '/content/forms/submissions', options)
end

#get_form_support_dataObject

Get form support data.

Get form support data.

Example

@data = @mints_user.get_form_support_data
[View source]

99
100
101
# File 'lib/user/content/forms.rb', line 99

def get_form_support_data
  @client.raw('get', '/content/forms/support-data')
end

#get_forms(options = nil) ⇒ Object

Get forms.

Get a collection of forms.

Parameters

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @mints_user.get_forms

Second Example

options = { sort: 'id', fields: 'title' }
@data = @mints_user.get_forms(options)
[View source]

20
21
22
# File 'lib/user/content/forms.rb', line 20

def get_forms(options = nil)
  @client.raw('get', '/content/forms', options)
end

#publish_form(id, data) ⇒ Object

Publish form.

Publish a form.

Parameters

id

(Integer) – Form id.

data

(Hash) – Data to be submitted.

Example

data = {
  slug: "new-publish"
}
@data = @mints_user.publish_form(1, data)
[View source]

36
37
38
39
# File 'lib/user/content/forms.rb', line 36

def publish_form(id, data)
  # FIXME: Output cannot be processed. response cannot be converted to json.
  @client.raw('put', "/content/forms/#{id}/publish", nil, data_transform(data))
end

#reset_form_aggregates(data) ⇒ Object

Reset aggregates.

Parameters

data

(Hash) – Data to be submitted.

Example

data = { object_id: 1 }
@data = @mints_user.reset_form_aggregates(data)
[View source]

229
230
231
# File 'lib/user/content/forms.rb', line 229

def reset_form_aggregates(data)
  @client.raw('post', "/content/forms/#{id}/aggregates", nil, data_transform(data))
end

#revert_published_form(id) ⇒ Object

Revert published form.

Revert a published form.

Parameters

id

(Integer) – Form id.

Example

@data = @mints_user.revert_published_form(1)
[View source]

66
67
68
# File 'lib/user/content/forms.rb', line 66

def revert_published_form(id)
  @client.raw('get', "/content/forms/#{id}/revert-published-data")
end

#schedule_form(id, data) ⇒ Object

Schedule form.

Schedule a form in a specified date.

Parameters

id

(Integer) – Form id.

data

(Hash) – Data to be submitted.

Example

data = {
  scheduled_at: '2021-09-06T20:29:16+00:00'
}
@data = @mints_user.schedule_form(1, data.to_json)
[View source]

53
54
55
56
# File 'lib/user/content/forms.rb', line 53

def schedule_form(id, data)
  # FIXME: Output cannot be processed. response cannot be converted to json.
  @client.raw('put', "/content/forms/#{id}/schedule", nil, data_transform(data))
end

#update_form(id, data, options = nil) ⇒ Object

Update form.

Update a form info.

Parameters

id

(Integer) – Form id.

data

(Hash) – Data to be submitted.

Example

data = {
  title: 'New Form Modified',
  slug: 'new-form-slug'
}
@data = @mints_user.update_form(3, data)
[View source]

193
194
195
# File 'lib/user/content/forms.rb', line 193

def update_form(id, data, options = nil)
  @client.raw('put', "/content/forms/#{id}", options, data_transform(data))
end