diff --git a/openapi.yaml b/openapi.yaml index e37d0bc..6cfce67 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -64,6 +64,44 @@ paths: $ref: '#/components/schemas/Account' security: - jwt: ['secret'] + /v1/tenants: + get: + tags: [ "Tenant" ] + summary: Return all normalized tenants + operationId: account.getTenants + responses: + '200': + description: tenant response + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/Tenant' + security: + - jwt: ['secret'] + /v1/tenants/{tenantId}: + get: + tags: [ "Tenant" ] + summary: Return the normalized tenant with given id + operationId: account.getTenant + parameters: + - name: tenantId + in: path + required: true + schema: + type: integer + responses: + '200': + description: tenants response + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/Tenant' + security: + - jwt: ['secret'] components: securitySchemes: @@ -119,6 +157,3 @@ components: type: string account: type: integer - TenantJoint: - description: TenantJoint - type: object \ No newline at end of file diff --git a/tenant.py b/tenant.py new file mode 100644 index 0000000..a272342 --- /dev/null +++ b/tenant.py @@ -0,0 +1,29 @@ +from db import dbGetMany, dbGetOne + +def getTenants(user, token_info): + return dbGetMany(user, token_info, + { + "statement": """ +SELECT id, salutation, firstname, lastname, + address1, address2, address3, zip, city, + phone1, phone2, iban, account + FROM tenant_t + """, + "params": () + } + ) + +def getTenant(user, token_info, tenantId=None): + return dbGetOne(user, token_info, + { + "statement": """ +SELECT id, salutation, firstname, lastname, + address1, address2, address3, zip, city, + phone1, phone2, iban, account + FROM tenant_t + WHERE id = %s + """, + "params": (tenantId, ) + } + ) +