Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guideDeveloper guideAdmin guide
Company siteHelp center
English
  • Русский
  • English
v74
  • v74
  • v73
  • v72
Login
  • Getting Started
  • Administrator documentation
  • Functional characteristics
  • Technology description
  • System requirements
  • Admin Panel
  • Platform installation
  • Platform configuration
  • Platform maintenance
  • Custom channels guide
    • Overview
    • Creating and configuring a channel
    • Entity field configuration
    • Template language
    • Entities
    • Pipes
      • Pipe: Basic Concepts
      • Result
      • Errors
      • Log
      • Pack
      • Unpack
      • HTTP Request
      • Store Set
      • Store Get
      • Selector
      • SQL
      • Eventer
      • Scheduler
    • Pipelines
  • Extra
  • Processing HTTP/HTTPS traffic
  • Administrator API
  • Custom channels guide
  • Pipes
  • Pack
Documentation for version v74

Pack

Description​

The Pack pipe marshals JSON or XML and writes the result to $in.body as a byte array. It only makes sense to use it in conjunction with an http pipe.

Structure​

FieldType of valueExampleRequiredDescription
idnumber10yesPipe's ID
typestring"pack"yesType of a pipe
paramsPackParamsObject
noType-specific parameters
outsOutsObject
noPipe's outputs

PackParamsObjectt
FieldTypeExampleReqieredDefaultDescription
typestring"JSON"no"JSON"Format.Possible values:- JSON -XMLCustom prefix for log message.
template

object

{}yes-JSON representation of the resulting JSON or XML.

Errors​

  1. params.type is not valid.
  2. Error processing *params.template - the template is not correct or the field was not found.

Examples​

  1. Example of a JSON packer.

Pipe:

{
"id": 6,
"type": "pack",
"params": {
"type": "JSON",
"template": {
"acceptUrl": "$template.acceptUrl",
"backgroundColor": "$template.background_color",
"backgroundImage": "$template.background_Image",
"campaignEnd": "$camp_schedule.stop_time",
"feeType": "fix",
"campaignFee": 0,
"campaignStart": "$camp_schedule.start_time",
"campaignType": "$campaign.campaignType",
"categoryId": "$#campaign.category.category",
"conditions": "$template.conditions",
"description": "$template.description",
"discountAmount": "$#template.discountAmount",
"discountCurrency": "$#template.discountCurrency",
"discountType": "$template.discountType",
"fontColor": "$template.font_color",
"merchantDomain": "$account.merchantDomain",
"merchantLogoPng": "$account.merchantLogoPng",
"merchantLogoSvg": "$account.merchantLogoSvg",
"merchantName": "$account.merchantName",
"offerEnd": "$camp_schedule.stop_time",
"partnerCampaignId": "$#origin.c_id",
"blockIds": "$#campaign.blockIds",
"$$campaign.segment[segments]": ["[$]id"]
"test_obj": {
"field1": 1,
"field2": ""
}
}
},
"outs": {
"success": 7,
"error": 8
}
}

Result:

{
"acceptUrl": "http://exmaple.com/accept_url",
"backgroundColor": "#ffffff",
"backgroundImage": "http://exmaple.com/background_image",
"campaignEnd": "2021-08-09T18:31:42",
"feeType": "fix",
"campaignFee": 0,
"campaignStart": "2021-05-09T15:22:00",
"campaignType": "test",
"categoryId": 50,
"conditions": "test_condition",
"description": "",
"discountAmount": 155,
"discountCurrency": 482,
"discountType": "RUB",
"fontColor": "#ffffff",
"merchantDomain": "http://exmaple.com/merchantDomain",
"merchantLogoPng": "http://exmaple.com/merchantLogoPng",
"merchantLogoSvg": "http://exmaple.com/merchantLogoSvg",
"merchantName": "merchantName",
"offerEnd": "2021-08-09T18:31:42",
"partnerCampaignId": 101,
"blockIds": ["adfadf", "dadasdasdas", "aaaaaa"],
"segments": ["aaaa", "bbbb"]
"test_obj": {
"field1": 1,
"field2": ""
}
}
  1. Example of an XML packer.

Pipe:

{
"id": 106,
"type": "pack",
"params": {
"type": "XML",
"template": {
"event": {
"-cancel": "false",
"-type": "MESSAGE",
"-xmlns": "http://example.com/event.xsd",
"recipients": {
"recipient": {
"addresses": {
"address": [
{
"-channel": "APL",
"-type": "CLIENT_ID",
"-value": "$subscription.id"
},
{
"-channel": "PUSH",
"-type": "CLIENT_ID",
"-value": "$subscription.id"
}
]
}
}
},
"templates": {
"template": [
{
"#text": "$template.title",
"-channel": "APL",
"-type": "TITLE"
},
{
"#text": "$template.body",
"-channel": "APL",
"-type": "BODY"
},
{
"#text": "$template.push_body",
"-channel": "PUSH",
"-type": "BODY"
}
]
}
}
}
},
"outs": {
"success": 108,
"error": 109
}
}

Result:

<?xml version="1.0" encoding="UTF-8"?>
<event xmlns="http://example.com/event.xsd" cancel="false" type="MESSAGE">
<recipients>
<recipient>
<addresses>
<address channel="APL" type="CLIENT_ID" value="aaaaaaaa" />
<address channel="PUSH" type="CLIENT_ID" value="aaaaaaaa" />
</addresses>
</recipient>
</recipients>
<templates>
<template channel="APL" type="TITLE">some title</template>
<template channel="APL" type="BODY">some body</template>
<template channel="PUSH" type="BODY">some push body</template>
</templates>
</event>
Last updated on Nov 13, 2023
Previous
Log
Next
Unpack
  • Description
  • Structure
  • Errors
  • Examples
© 2015 - 2025 Altcraft, LLC. All rights reserved.