Skip to content

Add mle flag #137

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 4 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
4 changes: 2 additions & 2 deletions generator/cybersource-ruby-template/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ module {{moduleName}}
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, '{{dataType}}', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
{{/bodyParam}}
is_mle_supported_by_cybs_for_api = {{#vendorExtensions.x-devcenter-metaData.isMLEsupported}}true{{/vendorExtensions.x-devcenter-metaData.isMLEsupported}}{{^vendorExtensions.x-devcenter-metaData.isMLEsupported}}false{{/vendorExtensions.x-devcenter-metaData.isMLEsupported}}
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["{{operationId}}","{{operationId}}_with_http_info"])
inbound_mle_status = "{{#vendorExtensions.x-devcenter-metaData.inboundMLEStatus}}{{vendorExtensions.x-devcenter-metaData.inboundMLEStatus}}{{/vendorExtensions.x-devcenter-metaData.inboundMLEStatus}}{{^vendorExtensions.x-devcenter-metaData.inboundMLEStatus}}false{{/vendorExtensions.x-devcenter-metaData.inboundMLEStatus}}"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["{{operationId}}","{{operationId}}_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
Expand Down
32 changes: 25 additions & 7 deletions lib/AuthenticationSDK/core/MerchantConfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ def initialize(cybsPropertyObj)
@pemFileDirectory = cybsPropertyObj['pemFileDirectory']
@mleKeyAlias = cybsPropertyObj['mleKeyAlias']
@useMLEGlobally = cybsPropertyObj['useMLEGlobally']
@enableRequestMLEForOptionalApisGlobally = !!(cybsPropertyObj['enableRequestMLEForOptionalApisGlobally'] || cybsPropertyObj['useMLEGlobally'])
@disableRequestMLEForMandatoryApisGlobally = cybsPropertyObj['disableRequestMLEForMandatoryApisGlobally']
@mapToControlMLEonAPI = cybsPropertyObj['mapToControlMLEonAPI']
validateMerchantDetails
logAllProperties(cybsPropertyObj)
validateMLEConfiguration
validateMLEConfiguration(cybsPropertyObj)
end

#fall back logic
Expand Down Expand Up @@ -237,16 +239,30 @@ def validateMerchantDetails()
end
end

def validateMLEConfiguration
if @useMLEGlobally.nil?
@useMLEGlobally = false
def validateMLEConfiguration(cybsPropertyObj)

if !@useMLEGlobally.nil? && !cybsPropertyObj['enableRequestMLEForOptionalApisGlobally'].nil?
if @useMLEGlobally != cybsPropertyObj['enableRequestMLEForOptionalApisGlobally']
raise StandardError.new(Constants::ERROR_PREFIX + "useMLEGlobally and enableRequestMLEForOptionalApisGlobally must have the same value if both are set")
end
end

unless [true, false].include?(@useMLEGlobally)
err = StandardError.new(Constants::ERROR_PREFIX + "useMLEGlobally must be a boolean")
if @disableRequestMLEForMandatoryApisGlobally.nil?
@disableRequestMLEForMandatoryApisGlobally = false
end

unless [true, false].include?(@disableRequestMLEForMandatoryApisGlobally)
err = StandardError.new(Constants::ERROR_PREFIX + "disableRequestMLEForMandatoryApisGlobally must be a boolean")
@log_obj.logger.error(ExceptionHandler.new.new_api_exception err)
raise err
end

unless [true, false].include?(@enableRequestMLEForOptionalApisGlobally)
err = StandardError.new(Constants::ERROR_PREFIX + "enableRequestMLEForOptionalApisGlobally must be a boolean")
@log_obj.logger.error(ExceptionHandler.new.new_api_exception err)
raise err
end

unless @mapToControlMLEonAPI.nil?
unless @mapToControlMLEonAPI.is_a?(Hash) && @mapToControlMLEonAPI.keys.all? {|k| k.is_a?(String)} && @mapToControlMLEonAPI.values.all? { |v| [true, false].include?(v) }
err = StandardError.new(Constants::ERROR_PREFIX + "mapToControlMLEonAPI must be a map with boolean values")
Expand All @@ -264,7 +280,7 @@ def validateMLEConfiguration
@mleKeyAlias = Constants::DEFAULT_ALIAS_FOR_MLE_CERT
end

mle_configured = @useMLEGlobally
mle_configured = @enableRequestMLEForOptionalApisGlobally
if !@mapToControlMLEonAPI.nil? && !@mapToControlMLEonAPI.empty?
@mapToControlMLEonAPI.each do |_, value|
unless [true, false].include?(value) && value
Expand Down Expand Up @@ -337,6 +353,8 @@ def logAllProperties(merchantPropertyObj)
attr_accessor :defaultCustomHeaders
attr_accessor :pemFileDirectory
attr_accessor :useMLEGlobally
attr_accessor :enableRequestMLEForOptionalApisGlobally
attr_accessor :disableRequestMLEForMandatoryApisGlobally
attr_accessor :mapToControlMLEonAPI
attr_accessor :mleKeyAlias
end
10 changes: 8 additions & 2 deletions lib/AuthenticationSDK/util/MLEUtility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
public
class MLEUtility
@log_obj = nil
def self.check_is_mle_for_API(merchant_config, is_mle_supported_by_cybs_for_api, operation_ids)
def self.check_is_mle_for_API(merchant_config, inbound_mle_status, operation_ids)
is_mle_for_api = false
if is_mle_supported_by_cybs_for_api && merchant_config.useMLEGlobally

if inbound_mle_status&.casecmp('optional') == 0 && merchant_config.enableRequestMLEForOptionalApisGlobally
is_mle_for_api = true
end

if inbound_mle_status&.casecmp('mandatory') == 0
is_mle_for_api = !merchant_config.disableRequestMLEForMandatoryApisGlobally
end

if merchant_config.mapToControlMLEonAPI && operation_ids
operation_ids.each do |operation_id|
if merchant_config.mapToControlMLEonAPI.key?(operation_id)
Expand Down
16 changes: 8 additions & 8 deletions lib/cybersource_rest_client/api/batches_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def get_batch_report_with_http_info(batch_id, opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_batch_report","get_batch_report_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_batch_report","get_batch_report_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -155,8 +155,8 @@ def get_batch_status_with_http_info(batch_id, opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_batch_status","get_batch_status_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_batch_status","get_batch_status_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -236,8 +236,8 @@ def get_batches_list_with_http_info(opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_batches_list","get_batches_list_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_batches_list","get_batches_list_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -309,8 +309,8 @@ def post_batch_with_http_info(body, opts = {})
post_body = @api_client.object_to_http_body(body)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'Body', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["post_batch","post_batch_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["post_batch","post_batch_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
12 changes: 6 additions & 6 deletions lib/cybersource_rest_client/api/billing_agreements_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def billing_agreements_de_registration_with_http_info(modify_billing_agreement,
post_body = @api_client.object_to_http_body(modify_billing_agreement)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'ModifyBillingAgreement', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = true
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["billing_agreements_de_registration","billing_agreements_de_registration_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["billing_agreements_de_registration","billing_agreements_de_registration_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -155,8 +155,8 @@ def billing_agreements_intimation_with_http_info(intimate_billing_agreement, id,
post_body = @api_client.object_to_http_body(intimate_billing_agreement)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'IntimateBillingAgreement', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = true
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["billing_agreements_intimation","billing_agreements_intimation_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["billing_agreements_intimation","billing_agreements_intimation_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -228,8 +228,8 @@ def billing_agreements_registration_with_http_info(create_billing_agreement, opt
post_body = @api_client.object_to_http_body(create_billing_agreement)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'CreateBillingAgreement', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = true
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["billing_agreements_registration","billing_agreements_registration_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["billing_agreements_registration","billing_agreements_registration_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
4 changes: 2 additions & 2 deletions lib/cybersource_rest_client/api/bin_lookup_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def get_account_info_with_http_info(create_bin_lookup_request, opts = {})
post_body = @api_client.object_to_http_body(create_bin_lookup_request)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'CreateBinLookupRequest', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_account_info","get_account_info_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_account_info","get_account_info_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
4 changes: 2 additions & 2 deletions lib/cybersource_rest_client/api/capture_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def capture_payment_with_http_info(capture_payment_request, id, opts = {})
post_body = @api_client.object_to_http_body(capture_payment_request)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'CapturePaymentRequest', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = true
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["capture_payment","capture_payment_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["capture_payment","capture_payment_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
4 changes: 2 additions & 2 deletions lib/cybersource_rest_client/api/chargeback_details_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def get_chargeback_details_with_http_info(start_time, end_time, opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_chargeback_details","get_chargeback_details_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_chargeback_details","get_chargeback_details_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
4 changes: 2 additions & 2 deletions lib/cybersource_rest_client/api/chargeback_summaries_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def get_chargeback_summaries_with_http_info(start_time, end_time, opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_chargeback_summaries","get_chargeback_summaries_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_chargeback_summaries","get_chargeback_summaries_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
4 changes: 2 additions & 2 deletions lib/cybersource_rest_client/api/conversion_details_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def get_conversion_detail_with_http_info(start_time, end_time, opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["get_conversion_detail","get_conversion_detail_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["get_conversion_detail","get_conversion_detail_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
12 changes: 6 additions & 6 deletions lib/cybersource_rest_client/api/create_new_webhooks_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def find_products_to_subscribe_with_http_info(organization_id, opts = {})
else
post_body = nil
end
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["find_products_to_subscribe","find_products_to_subscribe_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["find_products_to_subscribe","find_products_to_subscribe_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -141,8 +141,8 @@ def notification_subscriptions_v2_webhooks_post_with_http_info(opts = {})
post_body = @api_client.object_to_http_body(opts[:'create_webhook'])
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'CreateWebhook', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["notification_subscriptions_v2_webhooks_post","notification_subscriptions_v2_webhooks_post_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["notification_subscriptions_v2_webhooks_post","notification_subscriptions_v2_webhooks_post_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down Expand Up @@ -235,8 +235,8 @@ def save_sym_egress_key_with_http_info(v_c_sender_organization_id, v_c_permissio
post_body = @api_client.object_to_http_body(opts[:'save_sym_egress_key'])
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'SaveSymEgressKey', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = false
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["save_sym_egress_key","save_sym_egress_key_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["save_sym_egress_key","save_sym_egress_key_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
4 changes: 2 additions & 2 deletions lib/cybersource_rest_client/api/credit_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def create_credit_with_http_info(create_credit_request, opts = {})
post_body = @api_client.object_to_http_body(create_credit_request)
sdk_tracker = SdkTracker.new
post_body = sdk_tracker.insert_developer_id_tracker(post_body, 'CreateCreditRequest', @api_client.config.host, @api_client.merchantconfig.defaultDeveloperId)
is_mle_supported_by_cybs_for_api = true
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, is_mle_supported_by_cybs_for_api, ["create_credit","create_credit_with_http_info"])
inbound_mle_status = "false"
if MLEUtility.check_is_mle_for_API(@api_client.merchantconfig, inbound_mle_status, ["create_credit","create_credit_with_http_info"])
post_body = MLEUtility.encrypt_request_payload(@api_client.merchantconfig, post_body)
end
auth_names = []
Expand Down
Loading