Managing bitplaces

Creating bitplaces

The Bitplace class exposes the following getters and setters to access and write its data:

Getter / setter pair Value type Description
getId(), setId() long ID of the bitplace on the Bitplaces platform
getName(), setName() String Descriptive name of the bitplace
getDescription(), setDescription() String Longer description of the bitplace
getAddress(), setAddress() String Postal address
getForeignId(), setForeignId() String Foreign ID matching that of you own platform
getLatitude(), setLatitude() double Geographical latitude
getLongitude(), setLongitude() double Geographical longitude
getRadius(), setRadius() double Radius of the bitplace circle in meters
getUrl(), setUrl() String URL pointing to the bitplace page
getTagIds(), setTagIds() long[] IDs of the corresponding tags
getUtcOffset(), setUtcOffset() int Offset, in hours, of the bitplace's time zone respect to the UTC time
getImageId(), setImageId() Long ID of the image corresponding to this bitplace. Please refer to the section "Fetching images from the Bitplaces platform".

To create a bitplace you can use the following method:

1
createBitplace(Bitplace bitplace, BitplacesOperationCompletionHandler<Bitplace> completionHandler)

Passing to it a configured Bitplace instance, as shown in the example below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
Bitplace testBitplace = new Bitplace();
testBitplace.setName("Dussmann Bookstore");
testBitplace.setDescription("Dussmann das KulturKaufhaus GmbH");
testBitplace.setAddress("Friedrichstrasse 90 10117 Berlin");
testBitplace.setForeignID("V31674452");
testBitplace.setLatitude(52.5183);
testBitplace.setLongitude(13.3885);
testBitplace.setRadius(300);
testBitplace.setStatus("ENABLED");
testBitplace.setUrl("http://www.kulturkaufhaus.de");
BitplacesSDK.getInstance().createBitplace(testBitplace, new BitplacesOperationCompletionHandler<Bitplace>() {
    @Override
    public void onOperationComplete(int resultCode, Bitplace bitplace) {
        if (ResultCode.fromCode(resultCode) == ResultCode.RESULT_SUCCESS) {
            Log.i(TAG, "The newly created bitplace has been assigned the ID: " + bitplace.getId());
            } else {
            Log.e(TAG, "A non-recoverable error happened " + "when attempting to create the bitplace");
        }
    }
});

Modifying a given bitplace

Updating bitplaces is a very similar method call, the only difference is that the passed Bitplace is expected to have a valid ID so the backend will know which bitplace to update.

1
updateBitplace(Bitplace bitplace, BitplacesOperationCompletionHandler <Bitplace> completionHandler)

Fetching a bitplace

If you know the ID of a given bitplace you can fetch it from the backend invoking

1
fetchBitplace(long bitplaceID, BitplacesOperationCompletionHandler<Bitplace> completionHandler)

The provided completionHandler will be notified when the process is completed and, if successful, passed the retrieved bitplace.