|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + CyberSource Merged Spec |
| 5 | +
|
| 6 | + All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html |
| 7 | +
|
| 8 | + OpenAPI spec version: 0.0.1 |
| 9 | + |
| 10 | + Generated by: https://github.com/swagger-api/swagger-codegen.git |
| 11 | +""" |
| 12 | + |
| 13 | +from __future__ import absolute_import |
| 14 | + |
| 15 | +import sys |
| 16 | +import os |
| 17 | +import re |
| 18 | + |
| 19 | +# python 2 and python 3 compatibility library |
| 20 | +from six import iteritems |
| 21 | + |
| 22 | +from ..configuration import Configuration |
| 23 | +from ..api_client import ApiClient |
| 24 | +import CyberSource.logging.log_factory as LogFactory |
| 25 | + |
| 26 | +from ..utilities.tracking.sdk_tracker import SdkTracker |
| 27 | +class FlexAPIApi(object): |
| 28 | + """ |
| 29 | + NOTE: This class is auto generated by the swagger code generator program. |
| 30 | + Do not edit the class manually. |
| 31 | + Ref: https://github.com/swagger-api/swagger-codegen |
| 32 | + """ |
| 33 | + |
| 34 | + def __init__(self, merchant_config, api_client=None): |
| 35 | + config = Configuration() |
| 36 | + if api_client: |
| 37 | + self.api_client = api_client |
| 38 | + else: |
| 39 | + if not config.api_client: |
| 40 | + config.api_client = ApiClient() |
| 41 | + self.api_client = config.api_client |
| 42 | + self.api_client.set_configuration(merchant_config) |
| 43 | + self.logger = LogFactory.setup_logger(self.__class__.__name__, self.api_client.mconfig.log_config) |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + def generate_flex_api_capture_context(self, generate_flex_api_capture_context_request, **kwargs): |
| 48 | + """ |
| 49 | + Establish a Payment Session with a Capture Context |
| 50 | + To establish a payment session, include the API fields you plan to use in that session in the body of the request. The system then returns a JSON Web Token (JWT) that includes the capture context. To determine which fields to include in your capture context, identify the personal information that you wish to isolate from the payment session. **Capture Context Fields**<br> When making a session request, any fields that you request to be added to the capture context are required by default. However, you can choose to make a field optional by setting the required parameter to false. |
| 51 | + This method makes a synchronous HTTP request by default. To make an |
| 52 | + asynchronous HTTP request, please define a `callback` function |
| 53 | + to be invoked when receiving the response. |
| 54 | + >>> def callback_function(response): |
| 55 | + >>> pprint(response) |
| 56 | + >>> |
| 57 | + >>> thread = api.generate_flex_api_capture_context(generate_flex_api_capture_context_request, callback=callback_function) |
| 58 | +
|
| 59 | + :param callback function: The callback function |
| 60 | + for asynchronous request. (optional) |
| 61 | + :param GenerateFlexAPICaptureContextRequest generate_flex_api_capture_context_request: (required) |
| 62 | + :return: str |
| 63 | + If the method is called asynchronously, |
| 64 | + returns the request thread. |
| 65 | + """ |
| 66 | + |
| 67 | + if self.api_client.mconfig.log_config.enable_log: |
| 68 | + self.logger.info("CALL TO METHOD `generate_flex_api_capture_context` STARTED") |
| 69 | + |
| 70 | + kwargs['_return_http_data_only'] = True |
| 71 | + if kwargs.get('callback'): |
| 72 | + return self.generate_flex_api_capture_context_with_http_info(generate_flex_api_capture_context_request, **kwargs) |
| 73 | + else: |
| 74 | + (data) = self.generate_flex_api_capture_context_with_http_info(generate_flex_api_capture_context_request, **kwargs) |
| 75 | + return data |
| 76 | + |
| 77 | + def generate_flex_api_capture_context_with_http_info(self, generate_flex_api_capture_context_request, **kwargs): |
| 78 | + """ |
| 79 | + Establish a Payment Session with a Capture Context |
| 80 | + To establish a payment session, include the API fields you plan to use in that session in the body of the request. The system then returns a JSON Web Token (JWT) that includes the capture context. To determine which fields to include in your capture context, identify the personal information that you wish to isolate from the payment session. **Capture Context Fields**<br> When making a session request, any fields that you request to be added to the capture context are required by default. However, you can choose to make a field optional by setting the required parameter to false. |
| 81 | + This method makes a synchronous HTTP request by default. To make an |
| 82 | + asynchronous HTTP request, please define a `callback` function |
| 83 | + to be invoked when receiving the response. |
| 84 | + >>> def callback_function(response): |
| 85 | + >>> pprint(response) |
| 86 | + >>> |
| 87 | + >>> thread = api.generate_flex_api_capture_context_with_http_info(generate_flex_api_capture_context_request, callback=callback_function) |
| 88 | +
|
| 89 | + :param callback function: The callback function |
| 90 | + for asynchronous request. (optional) |
| 91 | + :param GenerateFlexAPICaptureContextRequest generate_flex_api_capture_context_request: (required) |
| 92 | + :return: str |
| 93 | + If the method is called asynchronously, |
| 94 | + returns the request thread. |
| 95 | + """ |
| 96 | + |
| 97 | + all_params = ['generate_flex_api_capture_context_request'] |
| 98 | + all_params.append('callback') |
| 99 | + all_params.append('_return_http_data_only') |
| 100 | + all_params.append('_preload_content') |
| 101 | + all_params.append('_request_timeout') |
| 102 | + |
| 103 | + params = locals() |
| 104 | + for key, val in iteritems(params['kwargs']): |
| 105 | + if key not in all_params: |
| 106 | + raise TypeError( |
| 107 | + "Got an unexpected keyword argument '%s'" |
| 108 | + " to method generate_flex_api_capture_context" % key |
| 109 | + ) |
| 110 | + params[key] = val |
| 111 | + del params['kwargs'] |
| 112 | + # verify the required parameter 'generate_flex_api_capture_context_request' is set |
| 113 | + if ('generate_flex_api_capture_context_request' not in params) or (params['generate_flex_api_capture_context_request'] is None): |
| 114 | + if self.api_client.mconfig.log_config.enable_log: |
| 115 | + self.logger.error("InvalidArgumentException : Missing the required parameter `generate_flex_api_capture_context_request` when calling `generate_flex_api_capture_context`") |
| 116 | + raise ValueError("Missing the required parameter `generate_flex_api_capture_context_request` when calling `generate_flex_api_capture_context`") |
| 117 | + |
| 118 | + |
| 119 | + collection_formats = {} |
| 120 | + |
| 121 | + path_params = {} |
| 122 | + |
| 123 | + query_params = [] |
| 124 | + |
| 125 | + header_params = {} |
| 126 | + |
| 127 | + form_params = [] |
| 128 | + local_var_files = {} |
| 129 | + |
| 130 | + body_params = None |
| 131 | + if 'generate_flex_api_capture_context_request' in params: |
| 132 | + body_params = params['generate_flex_api_capture_context_request'] |
| 133 | + |
| 134 | + sdkTracker = SdkTracker() |
| 135 | + body_params = sdkTracker.insert_developer_id_tracker(body_params, 'generate_flex_api_capture_context_request', self.api_client.mconfig.run_environment) |
| 136 | + # HTTP header `Accept` |
| 137 | + header_params['Accept'] = self.api_client.select_header_accept(['application/jwt']) |
| 138 | + |
| 139 | + # HTTP header `Content-Type` |
| 140 | + header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json;charset=utf-8']) |
| 141 | + |
| 142 | + # Authentication setting |
| 143 | + auth_settings = [] |
| 144 | + |
| 145 | + return self.api_client.call_api(f'/flex/v2/sessions', 'POST', |
| 146 | + path_params, |
| 147 | + query_params, |
| 148 | + header_params, |
| 149 | + body=body_params, |
| 150 | + post_params=form_params, |
| 151 | + files=local_var_files, |
| 152 | + response_type='str', |
| 153 | + auth_settings=auth_settings, |
| 154 | + callback=params.get('callback'), |
| 155 | + _return_http_data_only=params.get('_return_http_data_only'), |
| 156 | + _preload_content=params.get('_preload_content', True), |
| 157 | + _request_timeout=params.get('_request_timeout'), |
| 158 | + collection_formats=collection_formats) |
0 commit comments