Visma API Connector#
Use the visma connector to interact with Visma.
Import module#
from spec_utils import VismaClient
Client settings#
URL = '<your-url>'
ADMIN_URL = '<your-admin-url>'
USERNAME = '<your-username>'
PWD = '<your-password>'
Start session manually#
client = VismaClient(url=URL, username=USERNAME, pwd=PWD, admin_url=ADMIN_URL)
client.start_session()
client.is_connected
See out...
True
Close session manually#
client.close_session()
client.is_connected
See out...
False
Get employees#
with VismaClient(url=URL, username=USERNAME, pwd=PWD, admin_url=ADMIN_URL) as client:
employees = client.get_employees(pageSize=5)
# check result
employees
See out...
{
"totalCount": 747,
"values": [
{
"dateOfBirth": "1961-07-16",
"externalId": "51",
"familyName": "",
"firstName": "HUGO OSVALDO",
"imageUrl": None,
"lastName": "MARZIOLI",
"middleName": "",
"isActive": True,
"hiringDate": "1979-08-01",
"id": 3278,
},
{
"dateOfBirth": "1979-08-01",
"externalId": "59",
"familyName": "",
"firstName": "CARLOS SEBASTIAN",
"imageUrl": None,
"lastName": "PEREZ",
"middleName": "",
"isActive": True,
"hiringDate": "1999-05-01",
"id": 3279,
},
{
"dateOfBirth": "1980-08-18",
"externalId": "66",
"familyName": "",
"firstName": "JUAN NICOLAS",
# show more (open the raw output data in a text editor) ...
"imageUrl": None,
"lastName": "VALERIO",
"middleName": "",
"isActive": True,
"hiringDate": "2004-06-01",
"id": 3282,
},
],
}
Recursive pages#
with VismaClient(url=URL, username=USERNAME, pwd=PWD, admin_url=ADMIN_URL) as client:
employees = client.get_employees(
active=True,
pageSize=100,
orderBy="hiringDate-desc",
all_pages=True
)
Get detail#
with VismaClient(url=URL, username=USERNAME, pwd=PWD, admin_url=ADMIN_URL) as client:
employee_detail = client.get_employees(employee=1377)
employee_detail
See out...
{
"countryOfBirth": "EXTRANJERO",
"dateOfCountryEntry": "1995-09-01",
"email": "",
"fiscalNumbers": [
{
"number": "20-12345678-6",
"type": {"initials": "CUIL", "description": "CUIL", "id": 10},
"country": {
"description": "Argentina",
"isDefault": False,
"codeBank": None,
"codeISO": None,
"id": 3,
},
"emissionDate": None,
"dueDate": None,
"legalPersonality": "Fisica",
"certifiedInstitution": "Registro Nacional de las Perso",
"id": 20,
}
],
"genre": "Male",
"maritalStatus": {"date": None, "description": "CASADO/A", "id": 2},
"nationalIdentificationNumbers": [
{
"number": "12345678",
"type": {"initials": "DNI", "description": "Doc. Nac. de Identid", "id": 1},
"country": {
"description": "Argentina",
"isDefault": False,
"codeBank": None,
"codeISO": None,
"id": 3,
},
"emissionDate": None,
}
],
# show more (open the raw output data in a text editor) ...
"familyName": " ",
"firstName": "John",
"imageUrl": None,
"lastName": "Doe",
"middleName": " ",
"id": 6407,
}
Get extension#
with VismaClient(url=URL, username=USERNAME, pwd=PWD, admin_url=ADMIN_URL) as client:
employee_structures = client.get_employees(
employee=1377,
extension="structures"
)
employee_structures
See out...
{
"totalCount": 30,
"values": [
{
"structureId": 7,
"dateFrom": "1995-09-01",
"dateTo": None,
"description": "CLUB REC. EMP. ACEITEROS",
"externalId": "10553",
"type": {"description": "Sucursal", "id": 1},
"reason": {"id": 0, "description": "Sucursal", "reason": None},
"model": {"description": "Completo", "id": 1},
"id": 2,
},
{
"structureId": 17,
"dateFrom": "1995-09-01",
"dateTo": None,
"description": "CREA",
"externalId": "09",
"type": {"description": "Sector", "id": 2},
"reason": {"id": 0, "description": "Sector", "reason": None},
"model": {"description": "Completo", "id": 1},
"id": 1631,
},
{
"structureId": 123,
"dateFrom": "1995-09-01",
"dateTo": None,
"description": "Maestranza",
"externalId": "95",
"type": {"description": "Categoria", "id": 3},
"reason": {"id": 0, "description": "Categoria", "reason": None},
"model": {"description": "Completo", "id": 1},
"id": 3341,
},
{
"structureId": 137,
"dateFrom": "1995-09-01",
"dateTo": None,
"description": "Asignado x Sistema",
"externalId": "1",
"type": {"description": "Puesto", "id": 4},
"reason": {"id": 0, "description": "Puesto", "reason": None},
"model": {"description": "Completo", "id": 1},
"id": 4904,
},
{
"structureId": 2241,
"dateFrom": "2008-03-19",
"dateTo": None,
"description": "Produccion",
"externalId": " ",
"type": {"description": "Area", "id": 48},
"reason": {"id": 0, "description": "Area", "reason": None},
"model": {"description": "Completo", "id": 1},
"id": 50686,
},
{
"structureId": 430,
"dateFrom": "2012-06-25",
"dateTo": None,
"description": "REPARTO",
"externalId": "14",
"type": {"description": "Caja de Jubilacion", "id": 15},
"reason": {"id": 0, "description": "Caja de Jubilacion", "reason": None},
"model": {"description": "Completo", "id": 1},
"id": 93461,
},
],
}