Overview

Introduced in iOS 7, iBeacon is a new technology that enables new location awareness possibilities for apps. Leveraging Bluetooth Low Energy (BLE), a device with iBeacon technology can be used to establish a region around an object. The UUID, major and minor values provide the identifying information for the iBeacon.

The UUID, major and minor values provide the identifying information for the iBeacon. Generally speaking, this information is hierarchical in nature with the major and minor fields allowing for subdivision of the identity established by the UUID.

For example, the values may be used for a nationwide retail store. The UUID is shared by all locations. This allows an iOS device to use a single identifier to recognize any of the stores with a single region. Each specific store, New York, Frankfurt, and Sydney, is then assigned a unique major value, allowing a device to identify which specific store it is in. Within each individual store, departments are given separate minor values, although these are the same across stores to make it easier for an app on a device to readily identify departments.

Using this information, an iOS device can identify when it has entered or left one of the stores, which specific store it is, and what department the user might be standing in. These values are determined by the person or organization deploying the beacon device. UUIDs, major and minor values are not registered with Apple.

The Loyalty iBeacon microservice maps the UUID, Majors and Minors to human readable descriptions so that these values can be reused in other areas. This master data of beacons can then be used in wide variety of use cases. For example, a marketer can make a combination of UUID, Major and Minor using the mapped descriptions in the iBeacon Management microservice and associate it with an offer. When a mobile app come in range of an iBeacon, appropriate offers can then be pulled to the device.


API Reference

/beaconuuids

This resourceType defines the GET, POST, DELETE methods and their responses for a collection resource.

/beaconuuids

get

Gets all iBeacon UUIDs Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get all iBeacons UUIDs
post

Creates a new iBeacon UUID Accepted scopes:

  • 'sap.loyibeacon_manage' - Required to create a new iBeacon UUID

/beaconuuids/{id}

This resource type defines the GET, PUT, DELETE methods and their responses for a single element resource.

get

Gets a iBeacon UUID Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get iBeacons UUID by id
put

Updates a iBeacon UUID Accepted scopes:

*  'sap.loyibeacon_manage' - Required to create a new iBeacon UUID
delete

Deletes a iBeacon UUID Accepted scopes:

*  'sap.loyibeacon_delete' - Required to delete a iBeacon UUID

/majors

This resourceType defines the GET, POST, DELETE methods and their responses for a collection resource.

/majors

get

Gets all iBeacon majors Accepted scopes:

*  'sap.loyibeacon_view' - Required to get all iBeacons majors
post

Creates a new iBeacon major Accepted scopes:

  • 'sap.loyibeacon_manage' - Required to create a new iBeacon UUID

/majors/aggr

get

Gets Average, Sum and Count Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get all iBeacons majors

/majors/{id}

This resource type defines the GET, PUT, DELETE methods and their responses for a single element resource.

get

Gets a iBeacon major Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get iBeacon major by id
put

Updates a iBeacon major Accepted scopes:

  • 'sap.loyibeacon_manage' - Required to create a new iBeacon UUID
delete

Deletes a iBeacon major
Accepted scopes:

  • 'sap.loyibeacon_delete' - Required to delete a iBeacon major

/minors

This resourceType defines the GET, POST, DELETE methods and their responses for a collection resource.

/minors

get

Gets all iBeacon minors Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get all iBeacons minors
post

Creates a new iBeacon minor Accepted scopes:

  • 'sap.loyibeacon_manage' - Required to create a new iBeacon UUID

/minors/aggr

get

Gets Average, Sum and Count Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get all iBeacons majors

/minors/{id}

This resource type defines the GET, PUT, DELETE methods and their responses for a single element resource.

get

Gets a iBeacon minor Accepted scopes:

  • 'sap.loyibeacon_view' - Required to get iBeacon minor by id
put

Updates a iBeacon minor Accepted scopes:

  • 'sap.loyibeacon_manage' - Required to create a new iBeacon UUID
delete

Deletes a iBeacon minor
Accepted scopes:

  • 'sap.loyibeacon_delete' - Required to delete a iBeacon minor


Error Types

For more information about error codes, see the detailed error description for each API operation in API Reference. You can also check the standard error codes at API best practices.


Scopes

Scopes are strings that let you specify exactly what type of access you need to resources and operations in the Loyalty iBeacon service.

You must provide a proper scope that enables users to perform certain operations. The scopes should be granted in an access token from OAuth 2.0 service. For more information about the authorization and authentication used in hybris services, and also about the scopes in general, see: Authorization Scopes

The table presents all the scopes supported by the Loyalty iBeacon service and references to the tutorials that contain examples using the proper scopes.

ScopeDescriptionSelected examples of use
sap.loyibeacon_viewUse this scope to view existing iBeacon configuration.
sap.loyibeacon_manageUse this scope to create or modify existing iBeacon configuration.
sap.loyibeacon_deleteUse this scope to delete an iBeacon configuration.

If a certain operation requires two scopes to be allowed, then your role will need to have these two scopes assigned. Let's see an example where you want to see an specific iBeacon and change some properties of the iBeacon and update it:

  1. You want to view a specific iBeacon and change some of the properties and update it. To do this operation, your role needs the sap.loyibeacon_view and sap.loyibeacon_manage scope.
  2. However, if you want to view specific iBeacon and delete it. To do this operation , your role needs the sap.loyibeacon_view and sap.loyibeacon_delete scope.


Perform Simple CRUD Operations on iBeacon Major Object

Introduction

With the Loyalty iBeacon service you can do all the necessary operations to manage your iBeacons: create, retrieve, update, and delete. To perform the basic operations supported by the iBeacon service, you need to be properly authorized. This is achieved through the header that carries the correct access token. The examples in this tutorial will lead you through those operations, showing what you need to provide to the methods, and what you get in return.

clientId = clientIdPlaceholder;
clientSecret = clientSecretPlaceholder;
tenant = projectIdPlaceholder;
client = appIdPlaceholder;
scopesRequired = 'hybris.tenant='+tenant+' sap.loyibeacon_view sap.loyibeacon_manage sap.loyibeacon_delete';
token = tokenPlaceholder;

Get access token

To perform any operations with a specific service, you always need an access token. For this purpose, create an API Client for the oAuth2 service:

API.createClient('oAuth2Service',
'/services/oauth2/v1/api.raml');

Now get the token:

AccessToken = oAuth2Service.token.post({
  'client_id' : clientId,
  'client_secret': clientSecret,
  'grant_type' : 'client_credentials',
  'token_type': 'Bearer',
  'scope': scopesRequired
});
access_token = AccessToken.body.access_token;

Create API client for Loyalty iBeacon service

API.createClient('iBeaconService',
'/services/loyaltyibeacon/v1/api.raml');

Create an iBeacon Major object

majorId = 64587;
ibeacon_obj = iBeaconService.majors.post({
'majorId': majorId,
'description': 'Times Square Store'
}, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )

Retrieve object created with the previous step

  iBeaconService.majors.id(majorId).get(null, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )

Update the iBeacon Major object

Perform a partial update on the object:

iBeaconService.majors.id(majorId).put({
 'majorId': majorId,
 'description': 'Manhattan Store'
}, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
  },
  query: {
    'partial' : true
  }
})

Retrieve the same iBeacon Major object to ensure that proper information is updated

Get the iBeacon Major object to make sure that it was updated.

iBeaconService.majors.id(majorId).get(null, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )

Delete the above iBeacon Major Object

iBeaconService.majors.id(majorId).delete(null, {
  headers: {
   'Authorization': 'Bearer ' + access_token,
  }
})

Retrieve the deleted iBeacon Major object to ensure it is really deleted

iBeaconService.majors.id(majorId).get(null, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )


Perform Simple CRUD Operations on iBeacon Minor Object

Introduction

With the Loyalty iBeacon service you can do all the necessary operations to manage your iBeacons: create, retrieve, update, and delete. To perform the basic operations supported by the iBeacon service, you need to be properly authorized. This is achieved through the header that carries the correct access token. The examples in this tutorial will lead you through those operations, showing what you need to provide to the methods, and what you get in return.

clientId = clientIdPlaceholder;
clientSecret = clientSecretPlaceholder;
tenant = projectIdPlaceholder;
client = appIdPlaceholder;
scopesRequired = 'hybris.tenant='+tenant+' sap.loyibeacon_view sap.loyibeacon_manage sap.loyibeacon_delete';
token = tokenPlaceholder;

Get access token

To perform any operations with a specific service, you always need an access token. For this purpose, create an API Client for the oAuth2 service:

API.createClient('oAuth2Service',
'/services/oauth2/v1/api.raml');

Now get the token:

AccessToken = oAuth2Service.token.post({
  'client_id' : clientId,
  'client_secret': clientSecret,
  'grant_type' : 'client_credentials',
  'token_type': 'Bearer',
  'scope': scopesRequired
});
access_token = AccessToken.body.access_token;

Create API client for Loyalty iBeacon service

API.createClient('iBeaconService',
'/services/loyaltyibeacon/v1/api.raml');

Create an iBeacon Minor object

minorId = 64587;
ibeacon_obj = iBeaconService.minors.post({
'minorId': minorId,
'description': 'Times Square Store'
}, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )

Retrieve object created with the previous step

  iBeaconService.minors.id(minorId).get(null, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )

Update the iBeacon Minor object

Perform a partial update on the object:

iBeaconService.minors.id(minorId).put({
 'minorId': minorId,
 'description': 'Manhattan Store'
}, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
  },
  query: {
    'partial' : true
  }
})

Retrieve the same iBeacon Minor object to ensure that proper information is updated

Get the iBeacon Minor object to make sure that it was updated.

iBeaconService.minors.id(minorId).get(null, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )

Delete the above iBeacon Minor Object

iBeaconService.minors.id(minorId).delete(null, {
  headers: {
   'Authorization': 'Bearer ' + access_token,
  }
})

Retrieve the deleted iBeacon Minor object to ensure it is really deleted

iBeaconService.minors.id(minorId).get(null, {
  headers: {
    'Authorization': 'Bearer ' + access_token,
    'Content-type' : 'application/json'
           }
    }
  )


  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.