Crawler Import Service
Description
This service is used to simplify importing data to ATOLLON. In ATOLLON, it's possible to add more complex business logic based on request type and it's parameters. External developers are let go of understanding ATOLLON's blackbox.
Request
POST https://<HOST>/crab/crawler/<request_type>?instance=<instance_name>
Contact
Create contact (person or company) with (optionally) contact folder identified by context category (FPATypeCategory).
Request
POST https://<HOST>/crab/crawler/contact?instance=<instance_name>
Data in JSON format:
{
"person": {
"firstName": "<name>",
"lastName": "<surname>",
"prefixTitle": "<prefixTitle>",
"postfixTitle": "<postfixTitle>",
"companyPersonRelation": [{
"companyExternalId": [{
"system": "<system1>",
"id": "<Company contact external ID>"
}],
"positionDesc": "<Position of person in company>",
"companyName": "<Name of the related company>",
"departmentName": "<Name of department>"
}]
},
"company": {
"companyName": "<company name>",
"companyCompanyRelation": [{
"companyExternalId": [{
"system": "<system1>",
"id": "<Company contact external ID>"
}],
"relationType": "<Relation type Mother company>"
}]
},
"address": [{
"street": "<street + number>",
"city": "<city name>",
"zip": "<zip text>",
"region": "<region name>",
"country": "<country name>",
"addressType": "<address type1>"
},
{
"street": "<street + number>",
"city": "<city name>",
"zip": "<zip text>",
"region": "<region name>",
"country": "<country name>",
"addressType": "<address type2>"
}
],
"contacts": {
"email": [{
"contact": "<email1>",
"contactInfoTypeName": ""
}, {
"contact": "<email2>",
"contactInfoTypeName": ""
}],
"phone": [{
"contact": "<telefon1>",
"contactInfoTypeName": ""
}, {
"contact": "<telefon2>",
"contactInfoTypeName": ""
}],
"mobile": [{
"contact": "<mobil1>",
"contactInfoTypeName": ""
}, {
"contact": "<mobil2>",
"contactInfoTypeName": ""
}],
"web": [{
"contact": "<web1>",
"contactInfoTypeName": ""
}, {
"contact": "<web2>",
"contactInfoTypeName": ""
}]
},
"description": "<Contact text field>",
"contactGroup": [{
"name": "<Group 1>",
"description": "<description>"
}, {
"name": "<Group 2>",
"description": "<descritpion>"
}],
"contactFolder": [{
"category": "<string1>",
"refId": "",
"parentFolder": {
"category": "<string1>",
"refId": "<string>",
"contactExternalId": [{
"system": "<system1>",
"id": "<Company contact external ID>"
}]
},
"responsibleUser": [{
"userName": "<user@workspace>",
"userRoleName": "<User Role>",
"primary": true
}]
}],
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<system2>",
"id": "<Contact old id>"
}],
"regNo": "<registered number of business>",
"vatNo": "<VAT number>",
"trackingCode": "<string>",
"source": "<original - your system ident>",
"industries": [{
"name": "<industry name>",
"description": "<industry description>"
}]
}
Response
on SUCESS
- contactId
- folderId
- contact.externalId
Function progress
- Person is filled? => contact is "Person contact" (and the person is representative of the company), otherwise it's "Company contact" (either company or person surname is required)
Company contact
- Check whether company is existing (company name matches some record in DB) // see: https://help.atollon.com/books/backend-development/page/modcontact#bkmrk-%C2%A0
- If company does not exist, create new contact (company)
- Contact info and address is stored with company contact
- With company contact id, check whether contact has the desired contact folder. Desired contact folder is folder with FPATypeCategory (see list below)c. If the lead folder does not exist, it is created.
- If contactFolderCategory is not filled-in, the contact folder is not created.
- contactGroup - find the contact group with the same name. If the contact group does not exist, create it. Assign the contact to the group
Person contact
- Check whether person is existing (based on e-mail, mobile / if these are not filled-in, the person is created anyway). E-mail and mobile is stored with person contact
- Contact info and address is stored with person contact
- With person contact id, check whether contact has the desired contact folder. Desired contact folder is folder with FPATypeCategory of the client, lead, supplier, partner, etc. folder types. If the lead folder does not exist, it is created.
- If contactFolderCategory is not filled-in, the contact folder is not created.
- contactGroup - find the contact group with the same name. If the contact group does not exist, create it. Assign the contact to the group
- employer - if company oldId is found in companyPersonRelation, make binding, otherwise if companyName is filled-in in companyPersonRelation, company based on it's name or create new company contact and create binding
After the request is imported successfully, change the TIF status to "2".
Creating contact folder (client, supplier, etc.)
Contact folders is main building block in contact relations (ATOLLON's context).
Some useful context categories for contact folders used:
Client | com.atollon.project.fpatypecategory.client |
Supplier | com.atollon.project.fpatypecategory.supplier |
Lead (potential client) | com.atollon.leads.fpatypecategory.lead |
Partner | com.atollon.project.fpatypecategory.partner |
ExternalId
Please note that within Contact service, the system + externalId must be unique key.
Product
https://<HOST>/crab/crawler/product?instance=<instance_name>
POST data in JSON format:
{
"name": "<Product name>",
"refId": "<Product code>",
"description": "<Product description>",
"typeName": "<Product typee = Product, Service, Technology ...>",
"defaultQuantity": 1.0000,
"unitPrice": 4990.00,
"unitPriceCurrencyName": "<CZK, USD, etc.>",
"statusName": "<Product status = Active, Inactive>",
"unitsName": "<Product units = ks, md, hrs>",
"vatRateName": "<15 %, 21%, etc.>",
"openingBalanceQty": 0.0000,
"openingBalanceDate": "<2022-09-09T10:10>" // <now> datetime is default, if not provided,
"externalId": [
{
"system": "<system1>",
"id": "<ABCD-EFGH-ijkl-...>""
}, {
"system": "<sytem2>",
"id": "<ABCD-EFGH-ijkl-...>""
}
]
}
Response
on SUCCESS
- productId
- productName
- productRefid
- product.externalId
Function progress
- Find product based on it's externalId OR code + product name, if this does not match, create product
- If existing product is found, values are updated, ie openingBalanceQty
Billing
To export service activities that include billing items, get the following resource:
Request
GET https://<HOST>/crab/crawler/billing?billingStatus=ToBeInvoiced&instance=<instance_name>
Response
[{
"activity": {
"id": "0123000",
"name": "<Activity name>",
"refId": "<Activity REF ID>",
"statusName": "<Activity custom status name>",
"description": "<Activity notes>",
"created": "<2022-09-01T00:00>",
"modified": "<2022-09-14T10:00>"
},
"project": {
"id": "<project id>",
"name": "<Project name>",
"refId": "<Project REF ID>",
"statusName": "<Activity custom status name>",
"description": "<Activity notes>",
"created": "<2022-09-01T00:00>",
"modified": "<2022-09-14T10:00>"
},
"folder": {
"name": "<Folder name>",
"refId": "<Folder REF ID>"
},
"contact": {
"person": {
"firstName": "<name>",
"lastName": "<surname>"
},
"company": {
"companyName": "<company name>"
},
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<sytem2>",
"id": "<Contact old id>"
}],
"regNo": "<registered number of business>",
"vatNo": "<VAT number>"
},
"customer": {
"name": "<Folder name>",
"refId": "<Folder REF ID>"
},
"customerContact": {
"person": {
"firstName": "<name>",
"lastName": "<surname>"
},
"company": {
"companyName": "<company name>"
},
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<sytem2>",
"id": "<Contact old id>"
}],
"regNo": "<registered number of business>",
"vatNo": "<VAT number>"
},
"billingItems": [{
"id": "123456",
"productName": "<Product name1>",
"productRefid": "<Product code>",
"name": "<Billing item text>",
"description": "<Billing item description>",
"quantity": 1.0000,
"unitPrice": 1000.00,
"currency": "<EUR, CZK, ...>",
"billingDate": "<2022-09-14T10:00>",
"billingStatus": "ToBeInvoiced",
"externalId": [{
"system": "<system1>",
"id": "<Product old id>"
}, {
"system": "<sytem2>",
"id": "<Product old id>"
}]
}, {
"id": "123457",
"productName": "<Product name2>",
"productRefid": "<Product code>",
"name": "<Billing item text>",
"description": "<Billing item description>",
"quantity": 1.0000,
"unitPrice": 1000.00,
"currency": "<EUR, CZK, ...>",
"billingDate": "<2022-09-14T10:00>",
"billingStatus": "ToBeInvoiced",
"externalId": [{
"system": "<system1>",
"id": "<Product old id>"
}, {
"system": "<sytem2>",
"id": "<Product old id>"
}]
}],
"documents": [{
"name": "<Document name>",
"id": "123"
}, {
"name": "<Document name2>",
"id": "456"
}]
}]
Download documents
GET https://<HOST>/crab/crawler/download_document?docId=123123&instance=<instance_name>
You get file in response.
Update billing status of billing items
Run after you have processed the billing items from activity.
You can change status of each of the billing items. If billing items are marked as Invoiced, you can change either activity or project status. Activity status will be changed only if there are no remaining billing items to be invoiced.
Request
PUT https://<HOST>/crab/crawler/billing?instance=<instance_name>
DATA:
[{
"activity": {
"id": "0123000",
"statusName": "<Activity custom status name>"
},
"project": {
"id": "<project id>",
"statusName": "<Project custom status name>"
},
"billingItems": [{
"id": "123456",
"billingStatus": "Billed"
}, {
"id": "123457",
"billingStatus": "Cancelled"
}]
}]
Billing states:
0 |
SalesItems
|
1 |
Pending
|
2 |
ForApproval
|
3 |
ToBeInvoiced
|
4 |
Billed
|
5 |
ApprovedByClient
|
6 |
Postponed
|
7 |
Cancelled
|
Project
Request
Create new project and add technology items:
POST https://<HOST>/crab/crawler/project?instance=<instance_name>
{
"project": {
"id": "<project id>",
"name": "<Project name>",
"refId": "<Project REF ID>",
"statusName": "<Activity custom status name>",
"description": "<Activity notes>",
"created": "<2022-09-01T00:00>",
"modified": "<2022-09-14T10:00>",
"category": "anyProjectCategory",
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<system2>",
"id": "<Contact old id>"
}],
"dimension1Name": "<dimension1Name>",
"dimension2Name": "<dimension2Name>",
"dimension3Name": "<dimension3Name>",
"customer": {
"contactExternalId": [{
"system": "<system1>",
"id": "<customer contact externalid>"
}],
"contextCategory": "anyFolderCategory"
}
},
"folder": {
"name": "<Folder name>",
"refId": "<Folder REF ID>",
"category": "anyFolderCategory"
},
"contact": {
"person": {
"firstName": "<name>",
"lastName": "<surname>"
},
"company": {
"companyName": "<company name>"
},
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<sytem2>",
"id": "<Contact old id>"
}],
"regNo": "<registered number of business>",
"vatNo": "<VAT number>"
},
"technologyItems": [{
"id": "123456",
"productName": "<Product name1>",
"productRefid": "<Product code>",
"name": "<Technology item text>",
"description": "<Technology item description>",
"quantity": 1.0000,
"unitPrice": 1000.00,
"currency": "<EUR, CZK, ...>",
"billingDate": "<2022-09-14T10:00>",
"refId":"<Serial number>",
"externalId": [{
"system": "<system1>",
"id": "<Product old id>"
}, {
"system": "<sytem2>",
"id": "<Product old id>"
}],
"supplier": {
"contactExternalId": [{
"system": "test",
"id": "123"
}]
}
}, {
"id": "123457",
"productName": "<Product name2>",
"productRefid": "<Product code>",
"name": "<Technology item text>",
"description": "<Technology item description>",
"quantity": 1.0000,
"unitPrice": 1000.00,
"currency": "<EUR, CZK, ...>",
"billingDate": "<2022-09-14T10:00>",
"refId":"<Serial number>",
"externalId": [{
"system": "<system1>",
"id": "<Product old id>"
}, {
"system": "<sytem2>",
"id": "<Product old id>"
}]
}],
"formValues": [{
"fieldIdent": "<textFormItem>",
"fieldValue": "<hello>"
}, {
"fieldIdent": "<numberFormItem>",
"fieldValue": 22
}, {
"fieldIdent": "<dateFormItem>",
"fieldValue": "<2023-05-23T00:00:00>"
}]
}
Internal Procedure
- Based on given contact external id, find existing contact, if no contact is found, say ERR
- Based on folder.category, find whether folder for given contact is found, if not, create new contact folder
- Create new project into given category
- Load new technologyItems into the new project (technology items are projectItems with type = 3)
Request
Update project status:
PUT https://<HOST>/crab/crawler/project?instance=<instance_name>
{
"project": {
"id": "<project id>",
"name": "<Project name>",
"refId": "<Project REF ID>",
"statusName": "<Activity custom status name>",
"description": "<Activity notes>",
"created": "<2022-09-01T00:00>",
"modified": "<2022-09-14T10:00>",
"category": "anyProjectCategory",
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<system2>",
"id": "<Contact old id>"
}],
"dimension1Name": "<dimension1Name>",
"dimension2Name": "<dimension2Name>",
"dimension3Name": "<dimension3Name>",
"customer": {
"contactExternalId": [{
"system": "<system1>",
"id": "<customer contact externalid>"
}],
"contextCategory": "anyFolderCategory"
}
},
"technologyItems": [],
"formValues": []
}
Activity
GetActivity
Request
GET https://<HOST>/crab/crawler/project?instance=<instance_name>&id=<activity_id>
Response
{
"acl": "TREE000000228302",
"aclh": "TREE000000228302",
"activityType": 449312101,
"activityTypeName": "Pravideln\u00fd servis",
"created": "2023-08-01T16:53:14.198186",
"createdByName": "admin@pioneer",
"customState": 132412101,
"defaultMessageContainer": 773533101,
"defaultMessageContainerPath": "ABC DESIGN Branch > Servisn\u00ed projekt > Activity > Pravideln\u00fd servis",
"defaultMessageGroup": 773226101,
"folder": 773157101,
"folderName": "ABC DESIGN Branch",
"folderTypeName": "Company Branch",
"formId": 449320101,
"formName": "Service Activity",
"formValues": 773535101,
"id": 773533101,
"modified": "2023-08-01T17:30:14.828457",
"modifiedByName": "admin@pioneer",
"name": "Pravideln\u00fd servis",
"project": 773225101,
"projectName": "Servisn\u00ed projekt",
"refId": "0348",
"state": 1,
"requestHash": "NULL",
"startDate": "2024-09-01T00:00:00.000000",
"finalDate": "2026-01-31T00:00:00.000000",
"EXTERNAL_CONTACTS": {
"count": 0,
"EXTERNAL_CONTACT": []
}
}
ListActivity
Request
Response
[
{
"id": 773460101,
"name": "Pravideln\u00fd servis",
"type": 449312101,
"typeName": "Pravideln\u00fd servis",
"state": 3,
"customState": 132416101,
"customStateName": "Closed",
"created": "2023-08-01T15:55:56.385675",
"createdBy": 131750101,
"createdByName": "admin@pioneer",
"modified": "2023-08-01T16:53:11.718562",
"modifiedBy": 131750101,
"modifiedByName": "admin@pioneer",
"organization": 130946101,
"folder": 773157101,
"folderName": "ABC DESIGN Branch",
"folderParentId": 700827101,
"folderParentName": "ABC DESIGN",
"project": 773225101,
"projectName": "Servisn\u00ed projekt",
"refId": "0347",
"requestHash": "NULL",
"defaultMessageContainer": 773460101,
"defaultMessageGroup": 773226101,
"formId": 449320101,
"formValues": 773462101,
"startDate": "2023-04-01T00:00:00.000000",
"finalDate": "2024-08-31T00:00:00.000000"
},
{
"id": 773533101,
"name": "Pravideln\u00fd servis",
"type": 449312101,
"typeName": "Pravideln\u00fd servis",
"state": 1,
"customState": 132412101,
"customStateName": "Initial",
"created": "2023-08-01T16:53:14.198186",
"createdBy": 131750101,
"createdByName": "admin@pioneer",
"modified": "2023-08-01T17:30:14.828457",
"modifiedBy": 131750101,
"modifiedByName": "admin@pioneer",
"organization": 130946101,
"folder": 773157101,
"folderName": "ABC DESIGN Branch",
"folderParentId": 700827101,
"folderParentName": "ABC DESIGN",
"project": 773225101,
"projectName": "Servisn\u00ed projekt",
"refId": "0348",
"requestHash": "NULL",
"defaultMessageContainer": 773533101,
"defaultMessageGroup": 773226101,
"formId": 449320101,
"formValues": 773535101,
"startDate": "2024-09-01T00:00:00.000000",
"finalDate": "2026-01-31T00:00:00.000000"
}
]
Tracking code
Request
POST https://<HOST>/crab/crawler/tracking_code?instance=<instance_name>
{
"code": "ABC",
"userName": "<-- username@workspace -->",
"trackingCodeTypeName": "<-- Dealer -->",
"contactFolder": {
"id": "<Folder id>",
"name": "<Folder name>",
"refId": "<Folder REF ID>",
"category": "anyFolderCategory",
"contact": {
"person": {
"firstName": "<name>",
"lastName": "<surname>"
},
"company": {
"companyName": "<company name>"
},
"externalId": [{
"system": "<system1>",
"id": "<Contact old id>"
}, {
"system": "<sytem2>",
"id": "<Contact old id>"
}]
}
}
}
Internal process
The service calls service for creating tracking code.
The aim is to file new trackingCode with type "Dealer" or "Partner" with rerefence to folderId having contact's externalId previously entered by contact service.