Skip to content

Modifications for Batch upload #182

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 2 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions generator/cybersource-php-template/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use \{{invokerPackage}}\Configuration;
use \{{invokerPackage}}\ObjectSerializer;
use \{{invokerPackage}}\Logging\LogFactory as LogFactory;
use \{{invokerPackage}}\Authentication\Util\MLEUtility;
use \{{invokerPackage}}\Utilities\MultipartHelpers\MultipartHelper;
use \Exception;

/**
Expand Down Expand Up @@ -151,11 +152,14 @@ use \Exception;
$queryParams = [];
$headerParams = [];
$formParams = [];
{{#formParams}}$boundary = uniqid();
$delimiter = '-------------' . $boundary;{{/formParams}}
$_header_accept = $this->apiClient->selectHeaderAccept([{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType([{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]);
{{#formParams}}$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['multipart/form-data; boundary=' . $delimiter]);{{/formParams}}
{{^formParams}}$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType([{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]);{{/formParams}}

{{#queryParams}}
// query params
Expand Down Expand Up @@ -197,18 +201,7 @@ use \Exception;
{{#formParams}}
// form params
if (${{paramName}} !== null) {
{{#isFile}}
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
// See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
$formParams['{{baseName}}'] = curl_file_create($this->apiClient->getSerializer()->toFormValue(${{paramName}}));
} else {
$formParams['{{baseName}}'] = '@' . $this->apiClient->getSerializer()->toFormValue(${{paramName}});
}
{{/isFile}}
{{^isFile}}
$formParams['{{baseName}}'] = $this->apiClient->getSerializer()->toFormValue(${{paramName}});
{{/isFile}}
$formParams[basename(${{paramName}})] = file_get_contents(${{paramName}});
}
{{/formParams}}
{{#bodyParams}}
Expand All @@ -230,10 +223,10 @@ use \Exception;
{{/bodyParams}}

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand Down Expand Up @@ -274,7 +267,7 @@ use \Exception;
{{#queryParams}}
self::$logger->debug("Query Parameters :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($queryParams));
{{/queryParams}}
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down
33 changes: 21 additions & 12 deletions lib/Api/BatchesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use \CyberSource\ObjectSerializer;
use \CyberSource\Logging\LogFactory as LogFactory;
use \CyberSource\Authentication\Util\MLEUtility;
use \CyberSource\Utilities\MultipartHelpers\MultipartHelper;
use \Exception;

/**
Expand Down Expand Up @@ -135,10 +136,12 @@ public function getBatchReportWithHttpInfo($batchId)
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// path params
Expand All @@ -154,10 +157,10 @@ public function getBatchReportWithHttpInfo($batchId)
}

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -174,7 +177,7 @@ public function getBatchReportWithHttpInfo($batchId)

// Logging
self::$logger->debug("Resource : GET $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down Expand Up @@ -257,10 +260,12 @@ public function getBatchStatusWithHttpInfo($batchId)
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// path params
Expand All @@ -276,10 +281,10 @@ public function getBatchStatusWithHttpInfo($batchId)
}

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -296,7 +301,7 @@ public function getBatchStatusWithHttpInfo($batchId)

// Logging
self::$logger->debug("Resource : GET $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down Expand Up @@ -380,10 +385,12 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// query params
Expand All @@ -407,10 +414,10 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa
}

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -431,7 +438,7 @@ public function getBatchesListWithHttpInfo($offset = '0', $limit = '20', $fromDa
self::$logger->debug("Query Parameters :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($queryParams));
self::$logger->debug("Query Parameters :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($queryParams));
self::$logger->debug("Query Parameters :\n" . \CyberSource\Utilities\Helpers\ListHelper::toString($queryParams));
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down Expand Up @@ -518,10 +525,12 @@ public function postBatchWithHttpInfo($body)
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// body params
Expand All @@ -536,10 +545,10 @@ public function postBatchWithHttpInfo($body)
$_tempBody = $sdkTracker->insertDeveloperIdTracker($_tempBody, end($modelClassLocation), $this->apiClient->merchantConfig->getRunEnvironment(), $this->apiClient->merchantConfig->getDefaultDeveloperId());

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -556,7 +565,7 @@ public function postBatchWithHttpInfo($body)

// Logging
self::$logger->debug("Resource : POST $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down
25 changes: 16 additions & 9 deletions lib/Api/BillingAgreementsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use \CyberSource\ObjectSerializer;
use \CyberSource\Logging\LogFactory as LogFactory;
use \CyberSource\Authentication\Util\MLEUtility;
use \CyberSource\Utilities\MultipartHelpers\MultipartHelper;
use \Exception;

/**
Expand Down Expand Up @@ -142,10 +143,12 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/hal+json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// path params
Expand All @@ -168,10 +171,10 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem
$_tempBody = $sdkTracker->insertDeveloperIdTracker($_tempBody, end($modelClassLocation), $this->apiClient->merchantConfig->getRunEnvironment(), $this->apiClient->merchantConfig->getDefaultDeveloperId());

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -188,7 +191,7 @@ public function billingAgreementsDeRegistrationWithHttpInfo($modifyBillingAgreem

// Logging
self::$logger->debug("Resource : PATCH $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down Expand Up @@ -282,10 +285,12 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/hal+json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// path params
Expand All @@ -308,10 +313,10 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen
$_tempBody = $sdkTracker->insertDeveloperIdTracker($_tempBody, end($modelClassLocation), $this->apiClient->merchantConfig->getRunEnvironment(), $this->apiClient->merchantConfig->getDefaultDeveloperId());

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -328,7 +333,7 @@ public function billingAgreementsIntimationWithHttpInfo($intimateBillingAgreemen

// Logging
self::$logger->debug("Resource : POST $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down Expand Up @@ -415,10 +420,12 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/hal+json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// body params
Expand All @@ -433,10 +440,10 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen
$_tempBody = $sdkTracker->insertDeveloperIdTracker($_tempBody, end($modelClassLocation), $this->apiClient->merchantConfig->getRunEnvironment(), $this->apiClient->merchantConfig->getDefaultDeveloperId());

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -453,7 +460,7 @@ public function billingAgreementsRegistrationWithHttpInfo($createBillingAgreemen

// Logging
self::$logger->debug("Resource : POST $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down
9 changes: 6 additions & 3 deletions lib/Api/BinLookupApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use \CyberSource\ObjectSerializer;
use \CyberSource\Logging\LogFactory as LogFactory;
use \CyberSource\Authentication\Util\MLEUtility;
use \CyberSource\Utilities\MultipartHelpers\MultipartHelper;
use \Exception;

/**
Expand Down Expand Up @@ -137,10 +138,12 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest)
$queryParams = [];
$headerParams = [];
$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json;charset=utf-8']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json;charset=utf-8']);

// body params
Expand All @@ -155,10 +158,10 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest)
$_tempBody = $sdkTracker->insertDeveloperIdTracker($_tempBody, end($modelClassLocation), $this->apiClient->merchantConfig->getRunEnvironment(), $this->apiClient->merchantConfig->getDefaultDeveloperId());

// for model (json/xml)
if (isset($_tempBody)) {
if (isset($_tempBody) and count($formParams) <= 0) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
$httpBody = MultipartHelper::build_data_files($boundary, $formParams); // for HTTP post (form)
}

//MLE check and mle encryption for req body
Expand All @@ -175,7 +178,7 @@ public function getAccountInfoWithHttpInfo($createBinLookupRequest)

// Logging
self::$logger->debug("Resource : POST $resourcePath");
if (isset($httpBody)) {
if (isset($httpBody) and count($formParams) <= 0) {
if ($this->apiClient->merchantConfig->getLogConfiguration()->isMaskingEnabled()) {
$printHttpBody = \CyberSource\Utilities\Helpers\DataMasker::maskData($httpBody);
} else {
Expand Down
Loading