Fetch blocks
You can retrieve the blocks of the project with the function getBlocksWithParameters:Success:Failure like this:
1
MBClient.getBlocks(success: { (blocks, paginationInfo) in
2
​
3
}, failure: { error in
4
​
5
})
Copied!
The parameter named parameters is an optional array of objects that conforms to the MBParameter protocol that will be passed to the MBurger api as parameter.
The majority of the parameters that can be passed to the apis are already implemented in the SDK and can be used after the initialization:
    MBSortParameter
    MBPaginationParameter
    MBFilterParameter
    MBGeofenceParameter
If you want to pass another type of parameter you can use the MBGeneralParameter class that can be initialized with a key and a value that will be passed to the apis.
So if you want to include a pagination parameter you can do this:
1
let paginationParam = MBPaginationParameter(skip: 0, take: 10)
2
MBClient.getBlocks(withParameters: [paginationParam], success: { (blocks, paginationInfo) in
3
​
4
}, failure: { error in
5
​
6
})
Copied!
There are two other versions of the getBlocksWithParameters:Success:Failure: one that takes an additional parameter includingSections (a boolean that indicates whether or not include, for each block, the sections), and another that takes includingSections and includeElements (a boolean value that does the same thing but for the elements of the sections).
So, you could retrieve the information of all the blocks, all the sections of the blocks, and all the elements of the sections with this call:
1
MBClient.getBlocks(withParameters: [paginationParam], includingSections: true, includeElements: true, success: { (blocks, paginationInfo) in
2
​
3
}, failure: { error in
4
​
5
})
Copied!
Last modified 1yr ago
Copy link