Introduction
Many organizations prefer to use Yomly as the reference source of information about their employees and HR processes. You might require one-way synchronization of data. For example, you might want to:
- Update Active Directory (AD) with new employee information
- Transfer payment information to Oracle GL.
- Update Microsoft Outlook with calendar information related to Yomly activities.
To enable these types of transfers, Yomly implements a simple publish/subscribe model in which events from within Yomly are packaged and sent to a queue. A client program can then read this queue and perform the required tasks on a remote system. Unlike the Yomly REST API and GraphQL APIs, this push mechanism is read-only with respect to Yomly data.
Objective
In this tutorial, you will learn how to program the Yomly push API.
Procedure
To program the push API, do the following:
-
Define an API user. This step is performed by our Professional Services team.
-
Define a queue. This step is also performed by our Professional Services team.
-
Activate the push API. You can do this by updating the API preferences in the platform settings. Do the following:
-
In the sidebar, in the Business section, click Settings.
-
Go to the Preferences tab.
-
Click API to expand the section.
-
Click the name of the push API (for example, Employee-Push-API) to view the preferences that you can set.
-
Select the enabled checkbox.
-
In queue, enter the name of the queue created in step 2.
- Click Save.
-
Client Code
The following code snippet illustrates the basic structure of a Python client to access the queue:
import boto3
def getMessage(sqs):
# Receive message from SQS queue
response = sqs.receive_message(
QueueUrl=queue_url,
AttributeNames=[
'SentTimestamp'
],
MaxNumberOfMessages=1,
MessageAttributeNames=[
'All'
],
VisibilityTimeout=0,
WaitTimeSeconds=0
)
message = response['Messages'][0] # message is received as a JSON object here
def deleteMessage(message):
receipt_handle = message['ReceiptHandle'] # grab the handle so we can delete the message once processed
sqs.delete_message(
QueueUrl=queue_url,
ReceiptHandle=receipt_handle
)
def processMessage(message):
type = message["transactionType"]
# process the message here in whatever way you want
if __name__ == '__main__':
# Create SQS client
sqs = boto3.client('sqs')
queue_url = 'iMile_Transaction_Queue'
message = getMessage(sqs)
processMessage(message)
deleteMessage(message)
Queue Data Structures
The messages delivered to the queue are formatted as JSON messages. The formalization of these messages into JSON schema definitions is ongoing. However, the eventual schemas will be backward-compatible with the descriptions in the following table.
Queue messages are built around the structure of workflow events and the data formats are interchangeable between workflow usage and queue formats. In fact, the queue is populated via a global workflow that responds to the published global event.
Note that if a local workflow has consumed the event, the workflow will need to re-emit the event or the local workflow must directly call the Queue Activity task.
The Queue Activity task minimally processes the information passed to it. If the user has activated the API, the task adds a message header to the information passed and simply adds it to the queue. This enables you to create arbitrary queue messages if you want to produce message types other than the ones catered by the native message types.
Message Attributes
The following elements are added to the data appended to the queue.
Element | Data type | Description |
---|---|---|
messageGroup |
Integer |
Multiple objects can be sent in a single event. For example, creating an employee may generate a business object, the employee record of the requester, as well as the subject employeeData. All of these are sent with the same messageGroup identifier. |
object |
String | The name of the object |
queueName |
String | The name of the queue |
action |
String |
One of the following values:
A transfer of record values without an update is sent with an |
Objects
EmployeeData
The EmployeeData object contains the information of the employee that is the subject of the event.
A separate Employee object can be included to describe the employee that requested or initiated the event.
Parameter | Data type | Note |
---|---|---|
businessId |
Integer | |
employeeId |
Integer | |
authSource |
String | |
jwtSubject |
String | |
salutation |
String | |
firstName |
String | |
preferredName |
String | |
middleName |
String | |
lastName |
String | |
businessPhone |
String | |
businessEmail |
||
personalEmail |
||
personalAddress |
String | |
personalPhone |
String | |
dateOfBirth |
dateTime | |
gender |
String | |
religion |
String | |
placeOfBirth |
Integer | |
citizenship |
Integer | |
citizenship_countryId |
Integer | |
freezone |
Boolean | |
workLocation |
Integer | |
residencyVisaLocation |
Integer | |
startDate |
dateTime | |
leaveDate |
dateTime | |
employmentType |
String | |
leaveGroupId |
Integer | |
leaveApprover |
Integer | |
leaveAllowance |
Integer | |
workingPatternId |
Integer | |
accessLevel |
[accessLevel] | |
eosTier |
Integer | |
permittedDependents |
Integer | |
payrollId |
Integer | |
payrollAgentId |
Integer | |
paymentMethod |
String | |
payrollSalaryCardNumber |
String | |
lockBankDetails |
Boolean | |
establishmentId |
Integer | |
maritalStatus |
String | |
isHRAdmin |
Boolean | |
welcomeStatus |
Boolean | |
welcomeEmailLastSent |
dateTime | |
profilePicture |
URL | |
loginService_accountStatus |
String | |
employeeCode |
String | |
businessArea |
String | |
appliedGradeProfileId |
Integer | |
flightTicketClass |
String | |
fullName |
String | |
personalIdentifier |
String | |
businessIdentifier |
String | |
noticePeriodDays |
Integer | |
shirtSizeListItemKey |
String | Custom List |
sponsorTypeListItemKey |
String | Custom List |
sponsorEntityListItemKey |
String | Custom List |
contractTypeInternalListItemKey |
String | Custom List |
contractDocumentCodeListItemKey |
String | Custom List |
stringE1ListItemKey |
String | Custom List |
stringE2ListItemKey |
String | Custom List |
stringE3ListItemKey |
String | Custom List |
stringE4ListItemKey |
String | Custom List |
stringE5ListItemKey |
String | Custom List |
stringP1ListItemKey |
String | Custom List |
stringP2ListItemKey |
String | Custom List |
stringP3ListItemKey |
String | Custom List |
stringP4ListItemKey |
String | Custom List |
stringP5ListItemKey |
String | Custom List |
managementAllowanceDate |
dateTime | |
additionalManagementDate |
dateTime | |
dewaCap |
Integer | |
customValues |
JSON | Data container |
gradeName |
Integer | |
teams |
[Teams] | |
locations |
[Location] | |
customBranding |
Boolean | |
portalLogoUrl |
URL | |
employmentStatus |
String | |
status |
Status Object |
Status Object
Parameter | Data type | Note |
---|---|---|
available |
Boolean | |
awayUntil |
dateTime |
Leave Request
Leave request messages are sent when a leave is requested, approved or cancelled.
Parameter | Data type | Description |
---|---|---|
leaveTypeId |
Integer | Key of Leave Category |
halfDayStart |
Boolean | |
halfDayEnd |
Boolean | |
requestMessage |
String | |
startDate |
dateTime | |
endDate |
dateTime |
Comments
Please sign in to leave a comment.