from typing import List
from lxml.objectify import IntElement, StringElement, BoolElement
from q2_sdk.core.dynamic_imports import (
api_ExecuteStoredProcedure as ExecuteStoredProcedure,
)
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
[docs]
class TemplateRow(RepresentationRowBase):
TemplateID: IntElement = "TemplateID"
TransactionTypeID: IntElement = "TransactionTypeID"
TransactionType: StringElement = "TransactionType"
TransactionTypeDescription: StringElement = "TransactionTypeDescription"
BitFlags: IntElement = "BitFlags"
Name: StringElement = "Name"
Description: StringElement = "Description"
CustomerID: IntElement = "CustomerID"
CreateDate: StringElement = "CreateDate"
LastEditDate: StringElement = "LastEditDate"
IsSinglePayment: BoolElement = "IsSinglePayment"
RecipientCount: IntElement = "RecipientCount"
ACHClassCodeID: IntElement = "ACHClassCodeID"
ACHClasCode: IntElement = "ACHClasCode"
DefaultAccountID: IntElement = "DefaultAccountID"
DefaultSubsidiaryID: IntElement = "DefaultSubsidiaryID"
LastPaymentProcessedDate: StringElement = "LastPaymentProcessedDate"
LastPaymentProcessedAmount: StringElement = "LastPaymentProcessedAmount"
CompanyEntryDescription: StringElement = "CompanyEntryDescription"
[docs]
class TemplateRecipientRow(RepresentationRowBase):
TemplateID: IntElement = "TemplateID"
RecipientID: IntElement = "RecipientID"
[docs]
class Template(DbObject):
GET_BY_NAME_KEY = "Name"
NAME = "Template"
REPRESENTATION_ROW_CLASS = TemplateRow
[docs]
async def get(self, user_id: int) -> List[TemplateRow]:
assert isinstance(user_id, int), "Please supply a valid user id"
response = await self.call_hq(
"Q2_TemplateAccessData",
ExecuteStoredProcedure.SqlParameters([
ExecuteStoredProcedure.SqlParam(
ExecuteStoredProcedure.DataType.Int, "UserID", user_id
)
]),
specific_table="Table1",
)
return response
[docs]
async def get_template_recipients(
self, template_id: int
) -> List[TemplateRecipientRow]:
assert isinstance(template_id, int), "Please supply a valid user id"
response = await self.call_hq(
"sdk_GetTemplateRecipients",
ExecuteStoredProcedure.SqlParameters([
ExecuteStoredProcedure.SqlParam(
ExecuteStoredProcedure.DataType.Int, "template_id", template_id
)
]),
representation_class_override=TemplateRecipientRow,
)
return response