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 submited.

Example

data = {
  "title": "New Form",
  "slug": "new-form-slug"
}
@data = @mints_user.create_form(data)

136
137
138
# File 'lib/user/content/forms.rb', line 136

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)

165
166
167
# File 'lib/user/content/forms.rb', line 165

def delete_form(id)
    return @client.raw("delete", "/content/forms/#{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)

120
121
122
# File 'lib/user/content/forms.rb', line 120

def get_form(id, options = nil)
    return @client.raw("get", "/content/forms/#{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)

103
104
105
# File 'lib/user/content/forms.rb', line 103

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

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

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 submited.

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

#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 submited.

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 submited.

Example

data = {
  "title": "New Form Modified",
  "slug": "new-form-slug"
}
@data = @mints_user.update_form(3, data)

153
154
155
# File 'lib/user/content/forms.rb', line 153

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