API: Mandate

Preconditions (setup)

To make this functionality work 

  • Upload template file to BrokerStar installation
    • Login to BrokerStar with permissions allowing to use general filemanager
    • Go to /fm/index
    • Upload template file
      • File needs to be a PDF
      • In Document category  select Templates/Mandate .
      • Upload file (it does not have to have any additional setup - beside not archived and not deleted)
  • Check if file is compressed correctly
    • Send template request 
    • If response code is 415 (Unsuported Media Type)
      • IN most cases its a compression problem - go to /fm/index and compress pdf with (safe) compression level

Get latest mandate

JWT Authorisation

GET /api/v3/mandate/latest/{contactId}

Request parameter:

ParameterTypeInDescription
contactIdinturlid of contact related to mandate 

Response data:

ParameterTypeDescription
created_atstring|datedate of mandate creation
namestringfilename
titlestring|nullFile title
idintfile id



Metadata: object.

ParameterTypeDescription
statusintResponse status (same as in http code)

Data:  object.data

Response (Error):

ParameterTypeDescription
codeintegerAn error code
errorstringA message containing some information about the error 
errorsarrayList of errors devided by field in associative array {field_name:error message}
Request
curl -X GET https://public.brokerstar.biz/api/v3/mandate/5 --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2NTg[...]cm5hbWUiOiJkZW1vLWRlIn0.VTVp[...]cqIg'


Response (Success)
200 OK   
{
    "data": {
        "created_at": "2022-11-17T00:00:00+01:00",
        "name": "Mandat.pdf",
        "title": "Mandat",
        "id": 69
    },
    "status": 200
}
Response (Error)
404 Not found
{
	"error": "Entity not found",
	"code": 404
}
Response (Error)
403 Forbidden
{
	"error": "You have no access to contact id:5",
	"code": 403
}

Or one of 

Template

JWT Authorisation

POST /api/v3/mandate/template

Request parameter:

ParameterTypeInDescription
actionstringFORM_DATAgenerate (default) | save - if we want to save to contact filemanager
contactint|nullFORM_DATArequired if saving, contact id
image[]FILEFORM_DATAarray of files
image_data[]JSONFORM_DATAJSON definition of image (keys must mach the image FILE list)
Params:
  • x - int, X starting point
  • y - int, Y starting point
  • w - int, image width
  • h - int, image height

text[]

JSONFORM_DATAJSON definition of image (keys must mach the image FILE list)
Params:
  • x - int, X starting point (default 0)
  • y - int, Y starting point  (default 0)
  • text - string, text to be written
  • font - string, (default: Heveltica)
  • style - string  (default " "-regular)
    • B -bold
    • I - italic
    • U - underline
    • O - over line
    • D- line through
  • align - string  (default L)
    • L -left
    • R- right
    • C - center
  • size - int, font size (default 12)
  • line-height - int, line height (default 16)
  • color-r, int (0,255) - R color (default 0)
  • color-g, int (0,255) - G color (default 0)
  • color-b int (0,255) - B color (default 0)




JSON data (All fields are optional and can be send selective):

ParameterOut TypeIn TypeDescription
All fields from Single File +





Response data:

Request
curl --location --request POST 'http://public.brokerstar.biz/api/v3/mandate/template' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2Njg1OTc2NDcsImV4cCI6MTY2ODY4NDA0Nywicm9sZXMiOlsiUk9MRV9VU0VSIl0sImNsc2lkIjoiMWVkNjVhMGItODE4ZC02YzQ0LTlmODUtY2IwMjViMDI5NjQ1IiwidXNlcm5hbWUiOiJ0ZW1hdCJ9.z1Uu5g1gLCNdQqtxqLawMQqW68XCXTAeTgJXbX1BA1k9cNK7RICSxBDFUyaMb9zgoaalQo7H7GtI7o0ILEFIoA' \
--form 'action="save"' \
--form 'contact="4"' \
--form 'image[]=@"/home/dev/logo.png"' \
--form 'image_data[]
="{ \"x\":\"55\", \"y\":\"55\", \"w\":\"11\", \"h\":\"11\"}"' \
--form 'image[]=@"/home/dev/image.png"' \
--form 'image_data[]="{ \"x\":\"115\", \"y\":\"120\", \"w\":\"44\", \"h\":\"44\"}"' \
--form 'text[]="{\"text\":\"Name\", \"x\":\"15\", \"y\":\"20\",\"style\":\"B\"}"' \
--form 'text[]="{\"text\":\"Maciej\", \"x\":\"30\", \"y\":\"20\"}"'
Response (Success)
200 OK   
{
	"status":200
}
Response (Error)
400 Bad request
{
	"error": "Missing `contact` argument (int)",
	"code": 400
}
Response (Error)
415 Unsupported Media Type
{
	"error": "Template file is not supported, probably incorrect compression method, please change compression (BrokerStar filemanager allows to do that - use safest compression method)",
	"code": 415
}
Response (Error)
400 Bad request
{
	"error": "File was not send (form data)",
	"code": 400
}
Response (Error)
406 Not acceptable
{
	"error": "Disk quota: Not enough space!",
	"code": 406
}
Response (Error)
403 Forbidden
{
	"error": "You have no access to XXX id:123",
	"code": 403
}

Or one of 

Inform Insurances

JWT Authorisation

POST /api/v3/mandate/inform-insurances

Request parameter:

ParameterMandatoryIn TypeDescription
new_mandatenoboolDefault = false, if set to true, all insurances that have flag true will replace contact Third-party care
insurances[]yesarrayList of insurances where key is insurance id and value is flag determining if this insurance should be stored in third party care *only if new_mandate flag is set to true
Additional setup
_sendMailnoboolDefault = false, If true - if success mail will be send to contact and to related advisors.

Response data:


ParameterTypeDescription
statusintResponse status code (same as in http code)


Response (Error):

ParameterTypeDescription
codeintegerAn error code
errorstringA message containing some information about the error 
errorsarrayList of errors devided by field in associative array {field_name:error message}
Request
curl -X GET https://public.brokerstar.biz/api/v3/mandate/inform-insurances  -d '{
    "new_mandate": true,
    "_sendMail": true,
    "insurances": {
        "3929":true,
        "3427":false,
        "3412":true,
        "1866":false
    }
}' 
Response (Success)
200 OK 
{
    "status": 200
}

Related pages