Skip to content

Feature/add support for batch api #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
120 changes: 92 additions & 28 deletions CyberSource/__init__.py

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions CyberSource/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from .flex_api_api import FlexAPIApi
from .instrument_identifier_api import InstrumentIdentifierApi
from .interchange_clearing_level_details_api import InterchangeClearingLevelDetailsApi
from .invoice_settings_api import InvoiceSettingsApi
from .invoices_api import InvoicesApi
from .manage_webhooks_api import ManageWebhooksApi
from .merchant_boarding_api import MerchantBoardingApi
from .microform_integration_api import MicroformIntegrationApi
Expand All @@ -26,6 +28,7 @@
from .payer_authentication_api import PayerAuthenticationApi
from .payment_batch_summaries_api import PaymentBatchSummariesApi
from .payment_instrument_api import PaymentInstrumentApi
from .payment_links_api import PaymentLinksApi
from .payouts_api import PayoutsApi
from .plans_api import PlansApi
from .purchase_and_refund_details_api import PurchaseAndRefundDetailsApi
Expand All @@ -39,7 +42,9 @@
from .search_transactions_api import SearchTransactionsApi
from .secure_file_share_api import SecureFileShareApi
from .subscriptions_api import SubscriptionsApi
from .subscriptions_follow_ons_api import SubscriptionsFollowOnsApi
from .token_api import TokenApi
from .tokenized_card_api import TokenizedCardApi
from .transaction_batches_api import TransactionBatchesApi
from .transaction_details_api import TransactionDetailsApi
from .transient_token_data_api import TransientTokenDataApi
Expand All @@ -50,8 +55,6 @@
from .billing_agreements_api import BillingAgreementsApi
from .capture_api import CaptureApi
from .credit_api import CreditApi
from .invoice_settings_api import InvoiceSettingsApi
from .invoices_api import InvoicesApi
from .orders_api import OrdersApi
from .payments_api import PaymentsApi
from .refund_api import RefundApi
Expand Down
97 changes: 51 additions & 46 deletions CyberSource/api/batches_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ..configuration import Configuration
from ..api_client import ApiClient
import CyberSource.logging.log_factory as LogFactory
from CyberSource.utilities.MultipartHelpers import MultipartHelpers
from authenticationsdk.util.MLEUtility import MLEUtility
from authenticationsdk.util.GlobalLabelParameters import GlobalLabelParameters
from authenticationsdk.util.Utility import process_body
Expand Down Expand Up @@ -62,7 +63,7 @@ def get_batch_report(self, batch_id, **kwargs):
:param callback function: The callback function
for asynchronous request. (optional)
:param str batch_id: Unique identification number assigned to the submitted request. (required)
:return: InlineResponse2004
:return: InlineResponse2007
If the method is called asynchronously,
returns the request thread.
"""
Expand Down Expand Up @@ -92,7 +93,7 @@ def get_batch_report_with_http_info(self, batch_id, **kwargs):
:param callback function: The callback function
for asynchronous request. (optional)
:param str batch_id: Unique identification number assigned to the submitted request. (required)
:return: InlineResponse2004
:return: InlineResponse2007
If the method is called asynchronously,
returns the request thread.
"""
Expand Down Expand Up @@ -133,23 +134,25 @@ def get_batch_report_with_http_info(self, batch_id, **kwargs):
form_params = []
local_var_files = {}

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

body_params = None
if 'GET' in ('POST'):
body_params = '{}'

if 'GET' == GlobalLabelParameters.POST or 'GET' == GlobalLabelParameters.PUT or 'GET' == GlobalLabelParameters.PATCH:
body_params = process_body(body_params)

file_post_body_and_delimiter = MultipartHelpers.build_post_body_for_files(local_var_files)
if file_post_body_and_delimiter is not None:
body_params = file_post_body_and_delimiter[0]
header_params['Content-Type'] = f"multipart/form-data; boundary={file_post_body_and_delimiter[1]}"

is_mle_supported_by_cybs_for_api = False
if MLEUtility.check_is_mle_for_api(self.api_client.mconfig, is_mle_supported_by_cybs_for_api, "get_batch_report,get_batch_report_with_http_info"):
body_params = MLEUtility.encrypt_request_payload(self.api_client.mconfig, body_params)

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

# Authentication setting
auth_settings = []

Expand All @@ -160,7 +163,7 @@ def get_batch_report_with_http_info(self, batch_id, **kwargs):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='InlineResponse2004',
response_type='InlineResponse2007',
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'),
Expand All @@ -183,7 +186,7 @@ def get_batch_status(self, batch_id, **kwargs):
:param callback function: The callback function
for asynchronous request. (optional)
:param str batch_id: Unique identification number assigned to the submitted request. (required)
:return: InlineResponse2003
:return: InlineResponse2006
If the method is called asynchronously,
returns the request thread.
"""
Expand Down Expand Up @@ -213,7 +216,7 @@ def get_batch_status_with_http_info(self, batch_id, **kwargs):
:param callback function: The callback function
for asynchronous request. (optional)
:param str batch_id: Unique identification number assigned to the submitted request. (required)
:return: InlineResponse2003
:return: InlineResponse2006
If the method is called asynchronously,
returns the request thread.
"""
Expand Down Expand Up @@ -254,23 +257,25 @@ def get_batch_status_with_http_info(self, batch_id, **kwargs):
form_params = []
local_var_files = {}

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

body_params = None
if 'GET' in ('POST'):
body_params = '{}'

if 'GET' == GlobalLabelParameters.POST or 'GET' == GlobalLabelParameters.PUT or 'GET' == GlobalLabelParameters.PATCH:
body_params = process_body(body_params)

file_post_body_and_delimiter = MultipartHelpers.build_post_body_for_files(local_var_files)
if file_post_body_and_delimiter is not None:
body_params = file_post_body_and_delimiter[0]
header_params['Content-Type'] = f"multipart/form-data; boundary={file_post_body_and_delimiter[1]}"

is_mle_supported_by_cybs_for_api = False
if MLEUtility.check_is_mle_for_api(self.api_client.mconfig, is_mle_supported_by_cybs_for_api, "get_batch_status,get_batch_status_with_http_info"):
body_params = MLEUtility.encrypt_request_payload(self.api_client.mconfig, body_params)

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

# Authentication setting
auth_settings = []

Expand All @@ -281,7 +286,7 @@ def get_batch_status_with_http_info(self, batch_id, **kwargs):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='InlineResponse2003',
response_type='InlineResponse2006',
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'),
Expand All @@ -307,7 +312,7 @@ def get_batches_list(self, **kwargs):
:param int limit: The maximum number that can be returned in the array starting from the offset record in zero-based dataset.
:param str from_date: ISO-8601 format: yyyyMMddTHHmmssZ
:param str to_date: ISO-8601 format: yyyyMMddTHHmmssZ
:return: InlineResponse2002
:return: InlineResponse2005
If the method is called asynchronously,
returns the request thread.
"""
Expand Down Expand Up @@ -340,7 +345,7 @@ def get_batches_list_with_http_info(self, **kwargs):
:param int limit: The maximum number that can be returned in the array starting from the offset record in zero-based dataset.
:param str from_date: ISO-8601 format: yyyyMMddTHHmmssZ
:param str to_date: ISO-8601 format: yyyyMMddTHHmmssZ
:return: InlineResponse2002
:return: InlineResponse2005
If the method is called asynchronously,
returns the request thread.
"""
Expand Down Expand Up @@ -381,23 +386,25 @@ def get_batches_list_with_http_info(self, **kwargs):
form_params = []
local_var_files = {}

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

body_params = None
if 'GET' in ('POST'):
body_params = '{}'

if 'GET' == GlobalLabelParameters.POST or 'GET' == GlobalLabelParameters.PUT or 'GET' == GlobalLabelParameters.PATCH:
body_params = process_body(body_params)

file_post_body_and_delimiter = MultipartHelpers.build_post_body_for_files(local_var_files)
if file_post_body_and_delimiter is not None:
body_params = file_post_body_and_delimiter[0]
header_params['Content-Type'] = f"multipart/form-data; boundary={file_post_body_and_delimiter[1]}"

is_mle_supported_by_cybs_for_api = False
if MLEUtility.check_is_mle_for_api(self.api_client.mconfig, is_mle_supported_by_cybs_for_api, "get_batches_list,get_batches_list_with_http_info"):
body_params = MLEUtility.encrypt_request_payload(self.api_client.mconfig, body_params)

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

# Authentication setting
auth_settings = []

Expand All @@ -408,7 +415,7 @@ def get_batches_list_with_http_info(self, **kwargs):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='InlineResponse2002',
response_type='InlineResponse2005',
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'),
Expand All @@ -419,7 +426,7 @@ def get_batches_list_with_http_info(self, **kwargs):
def post_batch(self, body, **kwargs):
"""
Create a Batch
**Create a Batch**<br>This resource accepts TMS tokens ids of a Customer, Payment Instrument or Instrument Identifier. <br> The card numbers for the supplied tokens ids are then sent to the relevant card associations to check for updates.<br>The following type of batches can be submitted: - **oneOff** batch containing tokens id for Visa or MasterCard card numbers. - **amexRegistration** batch containing tokens id for Amex card numbers. A batch id will be returned on a successful response which can be used to get the batch status and the batch report.
**Create a Batch**<br>This resource accepts TMS tokens ids of a Customer, Payment Instrument or Instrument Identifier. <br> The card numbers for the supplied tokens ids are then sent to the relevant card associations to check for updates.<br>The following type of batches can be submitted: - **oneOff** batch containing tokens id for Visa or MasterCard card numbers. - **amexRegistration** batch containing tokens id for Amex card numbers. A batch id will be returned on a successful response which can be used to get the batch status and the batch report. The availability of API features for a merchant may depend on the portfolio configuration and may need to be enabled at the portfolio level before they can be added to merchant accounts.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
Expand Down Expand Up @@ -449,7 +456,7 @@ def post_batch(self, body, **kwargs):
def post_batch_with_http_info(self, body, **kwargs):
"""
Create a Batch
**Create a Batch**<br>This resource accepts TMS tokens ids of a Customer, Payment Instrument or Instrument Identifier. <br> The card numbers for the supplied tokens ids are then sent to the relevant card associations to check for updates.<br>The following type of batches can be submitted: - **oneOff** batch containing tokens id for Visa or MasterCard card numbers. - **amexRegistration** batch containing tokens id for Amex card numbers. A batch id will be returned on a successful response which can be used to get the batch status and the batch report.
**Create a Batch**<br>This resource accepts TMS tokens ids of a Customer, Payment Instrument or Instrument Identifier. <br> The card numbers for the supplied tokens ids are then sent to the relevant card associations to check for updates.<br>The following type of batches can be submitted: - **oneOff** batch containing tokens id for Visa or MasterCard card numbers. - **amexRegistration** batch containing tokens id for Amex card numbers. A batch id will be returned on a successful response which can be used to get the batch status and the batch report. The availability of API features for a merchant may depend on the portfolio configuration and may need to be enabled at the portfolio level before they can be added to merchant accounts.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
Expand Down Expand Up @@ -499,26 +506,24 @@ def post_batch_with_http_info(self, body, **kwargs):
form_params = []
local_var_files = {}

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

body_params = None
if 'body' in params:
body_params = params['body']

sdkTracker = SdkTracker()
body_params = sdkTracker.insert_developer_id_tracker(body_params, 'body', self.api_client.mconfig.run_environment, self.api_client.mconfig.defaultDeveloperId)

if 'POST' == GlobalLabelParameters.POST or 'POST' == GlobalLabelParameters.PUT or 'POST' == GlobalLabelParameters.PATCH:
body_params = process_body(body_params)

is_mle_supported_by_cybs_for_api = False
if MLEUtility.check_is_mle_for_api(self.api_client.mconfig, is_mle_supported_by_cybs_for_api, "post_batch,post_batch_with_http_info"):
body_params = MLEUtility.encrypt_request_payload(self.api_client.mconfig, body_params)

# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(['application/json;charset=utf-8'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8'])

# Authentication setting
auth_settings = []

Expand Down
Loading