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)

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

def create_form(data)
    return @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)

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

def delete_form(id)
    return @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)

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

def delete_form_submission(id)
    return @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)

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

def duplicate_form(id)
    return @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)

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

def get_form(id, options = nil)
    return @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)

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

def get_form_activation_words(id)
    return @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)

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

def get_form_aggregates(id, object_id)
    return @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)

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

def get_form_submission(id, options)
    return @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)

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

def get_form_submissions(options = nil)
    return @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

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

def get_form_support_data
    return @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)
    return @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 = {
  "data": {
    "slug": "new-publish"
  }
}
@data = @mints_user.publish_form(1, data.to_json)

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

def publish_form(id, data) #FIXME: Output cannot be processed. response cannot be converted to json.
    return @client.raw("put", "/content/forms/#{id}/publish", nil, 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)

231
232
233
# File 'lib/user/content/forms.rb', line 231

def reset_form_aggregates(data)
    return @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)

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

def revert_published_form(id)
    return @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 = {
  "data": {
    "scheduled_at": "2021-09-06T20:29:16+00:00"
  }
}
@data = @mints_user.schedule_form(1, data.to_json)

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

def schedule_form(id, data) #FIXME: Output cannot be processed. response cannot be converted to json.
    return @client.raw("put", "/content/forms/#{id}/schedule", nil, 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)

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

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