Module: Forms

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

Instance Method Summary collapse

Instance Method Details

#create_form(data) ⇒ 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)


174
175
176
# File 'lib/user/content/forms.rb', line 174

def create_form(data)
  @client.raw('post', '/content/forms', nil, 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)


203
204
205
# File 'lib/user/content/forms.rb', line 203

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)


141
142
143
# File 'lib/user/content/forms.rb', line 141

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)


76
77
78
# File 'lib/user/content/forms.rb', line 76

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)


158
159
160
# File 'lib/user/content/forms.rb', line 158

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)


88
89
90
# File 'lib/user/content/forms.rb', line 88

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)


215
216
217
# File 'lib/user/content/forms.rb', line 215

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)


129
130
131
# File 'lib/user/content/forms.rb', line 129

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)


113
114
115
# File 'lib/user/content/forms.rb', line 113

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


97
98
99
# File 'lib/user/content/forms.rb', line 97

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)


18
19
20
# File 'lib/user/content/forms.rb', line 18

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)


34
35
36
37
# File 'lib/user/content/forms.rb', line 34

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)


227
228
229
# File 'lib/user/content/forms.rb', line 227

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)


64
65
66
# File 'lib/user/content/forms.rb', line 64

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)


51
52
53
54
# File 'lib/user/content/forms.rb', line 51

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) ⇒ 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)


191
192
193
# File 'lib/user/content/forms.rb', line 191

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