Set the visibility of a section
cULR
iOS SDK
Android SDK
PHP SDK
JS SDK
Flutter SDK
curl https://mburger.cloud/api/blocks/<id>/sections
-X POST
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-H "X-MBurger-Token: <token>"
-H "X-MBurger-Version: 3"
-d 'elements[<locale>][<element_type>]=<value>'
-d 'visibility'
var visibilitySettings = MBAdminVisibilitySettings.draft()
visibilitySettings = MBAdminVisibilitySettings.visible()
// This visibility set the section to be available after 100 seconds
visibilitySettings = MBAdminVisibilitySettings.scheduled(availableAt: Date().addingTimeInterval(100))
MBAdmin.addSectionToBlock(withBlockId: BLOCK_ID,
elements: elements,
visibilitySettings: visibilitySettings,
success: { sectionId in
},
failure: { error in
})
val params = ArrayList<MBAdminGenericParameter>()
/*use MBAdminVisibility:
* ---- VISIBLE
* ---- DRAFT
* ---- SCHEDULED: you should add available_at, if -1L or not set uses
current time
*/
params.add(MBAdminVisibilitySettingsParameter(
visibility = VISIBILITY, available_at = SECONDS_TIMESTAMP))
val addSectionListener = object: MBAdminAddSectionListener{
override fun onSectionAdded(section_id: Long) {
}
override fun onSectionAddedError(error: String) {
}
}
MBurgerAdminTasks.addSection(
context = applicationContext,
block_id = BLOCK_ID,
listener = addSectionListener,
params = params,
locale = Locale.getDefault().getLanguage());
// Work in progress
// POST actions are not available atm on our JS SDK.
// If it could be interesting for you, please submit
// a feature request here:
// https://support.mburger.cloud/hc/en-us/community/topics/360000550497-Feature-Request?
MBAdminVisibilitySettings visibilitySettings =
MBAdminVisibilitySettings.draft();
visibilitySettings = MBAdminVisibilitySettings.visible();
// This visibility set the section to be available after 100 seconds
visibilitySettings = MBAdminVisibilitySettings.scheduled(
DateTime.now().add(Duration(seconds: 100)),
);
await MBAdmin.shared.addSectionToBlock(
944,
elements,
visibilitySettings: visibilitySettings,
);
Visibility can be set as visible, draft or scheduled. If visibility is set on scheduled, you need to specify
available_at
Copy link