# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Add recurring ach by number of occurrences
"""
from typing import List, Optional
from q2_sdk.core.q2_logging.logger import Q2LoggerType
from q2_sdk.hq.models.hq_response import HqResponse
from q2_sdk.hq.models.hq_credentials import HqCredentials
from q2_sdk.hq.models.hq_params.q2_api import Q2ApiParamsObj
from q2_sdk.hq.models.hq_request.q2_api import Q2ApiRequest
[docs]
class ParamsObj(Q2ApiParamsObj):
"""Parameters definition for AddRecurringAchByCountByUserId"""
def __init__(
self,
logger: Q2LoggerType,
user_id: int,
originating_account_id: int,
transaction_amount: float,
currency_code_id: int,
is_ppd: bool,
subsidiary_id: int,
recurring_transaction_type: str,
every_xweeks_or_months: int,
frequency_bit_flags: int,
start_date: str,
number_of_occurrences: int,
transaction_type_short_name: Optional[str] = None,
description: Optional[str] = None,
transaction_details_xml: Optional[str] = None,
hq_credentials: Optional[HqCredentials] = None,
):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param user_id: Q2_User.UserID
:param originating_account_id: Q2_HostAccount.HostAccountID
:param transaction_amount: ex. 2.43
:param currency_code_id: Q2_CurrentyCode.CurrencyCodeID
:param is_ppd:
:param subsidiary_id: Q2_Subsidiary.SubsidiaryID
:param recurring_transaction_type: Value from `q2_sdk.hq.models.transaction_info.RecurringTransactionType`
:param every_xweeks_or_months: Applies to Weeks or Months based on the value in recurring_transaction_type
:param frequency_bit_flags: Calculated using `q2_sdk.hq.api_helpers.get_frequency_bit_flags`
:param start_date: ex. 1980-10-23. Some HQ endpoints require a timestamp as well (1980-10-23T00:00:00)
:param number_of_occurrences:
:param transaction_type_short_name:
:param description: Free form text
:param transaction_details_xml:
:param hq_credentials: Defaults to settings.HQ_CREDENTIALS
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"UserId": user_id,
"OriginatingAccountId": originating_account_id,
"TransactionTypeShortName": transaction_type_short_name,
"TransactionAmount": transaction_amount,
"CurrencyCodeId": currency_code_id,
"Description": description,
"IsPpd": is_ppd,
"SubsidiaryId": subsidiary_id,
"TransactionDetailsXml": transaction_details_xml,
"RecurringTransactionType": recurring_transaction_type,
"EveryXweeksOrMonths": every_xweeks_or_months,
"FrequencyBitFlags": frequency_bit_flags,
"StartDate": start_date,
"NumberOfOccurrences": number_of_occurrences,
})
[docs]
async def execute(params_obj: ParamsObj, use_json=False, **kwargs) -> HqResponse:
"""
This is the default way to submit the request to HQ.
In theory, both json and soap payloads are equally accepted by HQ, though
several variables may affect that (HQ version, Q2SDK implementation bugs, etc).
This should not affect anything about the way your code deals with the data. In fact,
the only difference to consuming extensions is the logging.
Basically, call this with default parameters unless you find a compelling
reason not to.
:param params_obj: Object containing everything necessary to call this HQ endpoint
:param use_json: If True, will call HQ's .ashx (json) endpoint instead of .asmx (soap)
"""
request = Q2ApiRequest(
"AddRecurringAchByCountByUserId", use_json=use_json, **kwargs
)
return await request.execute(params_obj, **kwargs)
[docs]
async def get_soap(params_obj: ParamsObj, **kwargs) -> HqResponse:
"""Deprecated. Please use execute instead"""
params_obj.logger.warning(
"AddRecurringAchByCountByUserId.get_soap is deprecated. Please use AddRecurringAchByCountByUserId.execute instead."
)
return await execute(params_obj, **kwargs)
[docs]
async def get_json(params_obj: ParamsObj, **kwargs) -> HqResponse:
"""Deprecated. Please use execute instead"""
params_obj.logger.warning(
"AddRecurringAchByCountByUserId.get_json is deprecated. Please use AddRecurringAchByCountByUserId.execute instead."
)
return await execute(params_obj, use_json=True, **kwargs)
[docs]
def build_json(params_obj: ParamsObj):
return Q2ApiRequest.build_json(params_obj)
[docs]
def build_soap(params_obj: ParamsObj):
return Q2ApiRequest("AddRecurringAchByCountByUserId", use_json=False).build_soap(
params_obj
)