Sprintf
Sprintf is a special way of passing the JSON key's value from one step to another step (source/operations/target) in the eZintegrations data pipeline dynamically
Inside the eZintegrations pipeline the data flows in JSON format and to make a handshake and relationship between Operations and Target systems, Sprintf easy way to achieve.
Sprintf helps eZintegrations users in the following :
- To make a relationship between two or more datasets from different sources.
- Mapping the source and target payloads
- Generate dynamic JSON payload for a Target API
- Send dynamic Email recipients from a given dataset
- Configure dynamic Email Body
- Orchestrate Target Applications like Database, SaaS, No SQL, Bizintel360 Data Lake and Email
It uses the following notation:
{%key%}
Note: In-case of a key whose value is a dynamic Integer and Boolean value
In below example the price
key was integer and status_flag
key was boolean before using Append operation and after using Append operation the data type remains same with the below sprintf
feature
"price":"{%^stock_price^%}",
"status_flag":"{%^status_flag^%}",
In the eZintegrations data pipeline, Sprintf can be used in Data Source/Data Target/Operations:
- API Data Source
- API Operation
- API Data Target
- Append Operation
- Bizintel360 Datalake Search Operation
- Email Target
- Email Operation
Usage of Sprintf:
Sprintf is used at several distinct stages in the eZintegrations data pipeline. Illustrating various use cases for Sprintf in eZintegrations:
API Data Source
In API Source, Sprintf can be used in Endpoint URL, Headers, Body, Params, Authorization, Pre-request Script and in certain cases in Pagination.
Example of Sprintf in Params:
Passing values using Sprintf in Params helps in dynamic insertion of variables, making it flexible for inclusion of user-specific data. To use the Sprintf in Params, add the minimum and maximum values in Numeric Params.
Use the values of Numeric Params as Sprintf in Params directly.
Example of Sprintf in Headers:
In this example, we are using Pre-request Script, which is used in OAuth 2.0. Pre-request is helpful in places where users need to write Python code to generate the URL, Headers or Params.
API Operation
Sprintf is used in API operation in two ways:
Scenario 1: In OAuth 2.0
Scenario 2: In URL, Headers and Params, when passing the JSON data.
Example of Sprintf in API operation
Using the ID from the source API to match with the ID in target API, using Sprintf.
Data in Source:
{"id":1,"email":"george.bluth@reqres.in","first_name":"George","last_name":"Bluth","avatar":"https://reqres.in/img/faces/1-image.jpg"},{"id":2,"email":"janet.weaver@reqres.in","first_name":"Janet","last_name":"Weaver","avatar":"https://reqres.in/img/faces/2-image.jpg"}
API Operation:
Pass the value of ID in Sprintf format.
{%id%}
API Data Target
In API Target, Sprintf can be used in Endpoint URL, Headers, Body, Params, Authorization, Pre-request Script and in certain cases in Pagination.
The usage of Sprintf in Target will be in the same way as API Source. Refer to API Source, for the examples.
Append Operation
Append operation is used for creating a new key-value pair in the required data. Sprintf in Append is used for modifying or fetching multiple values coming from JSON data from the source.
Example of Sprintf in Append Operation:
Data in Source:
{"id":1,"email":"george.bluth@reqres.in","first_name":"George","last_name":"Bluth","avatar":"https://reqres.in/img/faces/1-image.jpg"},{"id":2,"email":"janet.weaver@reqres.in","first_name":"Janet","last_name":"Weaver","avatar":"https://reqres.in/img/faces/2-image.jpg"}
Append Operation:
"User ID": "{%id%}", "Email ID": "{%email%}"
Output:
{"User ID":1,"Email ID":"george.bluth@reqres.in","first_name":"George","last_name":"Bluth","avatar":"https://reqres.in/img/faces/1-image.jpg"},{"User ID":2,"Email ID":"janet.weaver@reqres.in","first_name":"Janet","last_name":"Weaver","avatar":"https://reqres.in/img/faces/2-image.jpg"}
Bizintel360 Datalake Search Operation
In the Datalake Search Operation, similar functionality is used in the case of Sprintf. Using Sprintf, the values of specific columns from the source can be fetched.
Example:
In the below example, the Patient ID is matched from the source data, and if the ID is matched, the values of the column Encounter ID and Patient Name will be fetched along with the other details in the target.
Email Target
Email as Target is used for sending emails for various purposes like sending standard mails, alert notifications or any other required communication.
In Email as Target, Sprintf can be used for passing the interpolated values coming from the source. The Sprintf values are the JSON data coming through source.
In Email, Sprintf can be used in CC, BCC, Source Key or Body.
In the below example, using Sprintf, Ticket ID and Status values are being fetched from the source.
Email Operation
Email as an Operation is also used for sending mail for various purposes like for standard email communications, important alert notifications and other required communications.
Sprintf in Email Operations can be used in CC, BCC, Source Key and Body, similar to the way as used in Target.
To use Sprintf in Source Key, the key should be singleline JSON data.
Example:
{"items": {"id":1,"email":"george.bluth@reqres.in","first_name":"George","last_name":"Bluth","avatar":"https://reqres.in/img/faces/1-image.jpg"}}