From d8982eefef6c5e60a99b2144c46add3b6e1d6746 Mon Sep 17 00:00:00 2001 From: Matthew Lewis Date: Mon, 21 Aug 2023 11:44:58 +1000 Subject: [PATCH 1/3] Added resource for Mastercard ClickToPay Registrations. --- lib/fat_zebra.rb | 5 +++ .../mastercard/click_to_pay/registration.rb | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb diff --git a/lib/fat_zebra.rb b/lib/fat_zebra.rb index f164102..a483f19 100644 --- a/lib/fat_zebra.rb +++ b/lib/fat_zebra.rb @@ -1,3 +1,5 @@ +$LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__) + # Libraries require 'securerandom' require 'json' @@ -38,6 +40,9 @@ require 'fat_zebra/web_hook' require 'fat_zebra/batch' +# Utilities/Mastercard +require 'fat_zebra/utilities/mastercard/click_to_pay/registration' + # Paypal API Resources require 'fat_zebra/paypal/billing_agreement' require 'fat_zebra/paypal/order' diff --git a/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb b/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb new file mode 100644 index 0000000..6ac9368 --- /dev/null +++ b/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module FatZebra + module Utilities + module Mastercard + module ClickToPay + class Registration < APIResource + + ENDPOINT_URL = '/v1.0/utilities/mastercard/click_to_pay/registration' + + class << self + + ## + # Register with Mastercard Click To Pay + # + # @return [FatZebra::Utilities::Mastercard::ClickToPay::Registration] response + def register! + response = request(:post, ENDPOINT_URL) + initialize_from(response) + end + + ## + # Lookup regisrtation with Mastercard Click To Pay + # + # @return [FatZebra::Utilities::Mastercard::ClickToPay::Registration] response + def registered? + response = request(:get, ENDPOINT_URL) + initialize_from(response) + end + end + end + end + end + end +end \ No newline at end of file From 6b7a9909dafc02f609fa7b59ab3ec5d59e8a5983 Mon Sep 17 00:00:00 2001 From: Matthew Lewis Date: Mon, 21 Aug 2023 11:47:23 +1000 Subject: [PATCH 2/3] Added ruby 3.2 to build targets. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 144b74b..46db112 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ rvm: - 2.5 - 2.6 - 2.7 + - 3.2 script: - bundle exec rspec spec - bundle exec rubocop From fb4386926c8af955ca04fb1952dfcde894b09178 Mon Sep 17 00:00:00 2001 From: Matthew Lewis Date: Mon, 21 Aug 2023 12:32:13 +1000 Subject: [PATCH 3/3] bump rubocop, support ruby 3.x --- .rubocop.yml | 4 ++-- .tool-versions | 1 + .travis.yml | 4 ---- Gemfile | 2 ++ Rakefile | 2 ++ fat_zebra.gemspec | 6 +++++- lib/fat_zebra.rb | 2 ++ lib/fat_zebra/api_helper.rb | 11 +++++++---- lib/fat_zebra/api_operation/delete.rb | 2 ++ lib/fat_zebra/api_operation/find.rb | 2 ++ lib/fat_zebra/api_operation/save.rb | 2 ++ lib/fat_zebra/api_operation/search.rb | 2 ++ lib/fat_zebra/api_operation/void.rb | 2 ++ lib/fat_zebra/api_resource.rb | 18 +++++++++++------- lib/fat_zebra/authenticate.rb | 2 ++ lib/fat_zebra/bank_account.rb | 2 ++ lib/fat_zebra/batch.rb | 7 +++++-- lib/fat_zebra/card.rb | 2 ++ lib/fat_zebra/config.rb | 4 +++- lib/fat_zebra/customer.rb | 2 ++ lib/fat_zebra/direct_credit.rb | 2 ++ lib/fat_zebra/direct_debit.rb | 2 ++ lib/fat_zebra/errors.rb | 7 +++---- lib/fat_zebra/fat_zebra_object.rb | 2 ++ lib/fat_zebra/information.rb | 2 ++ lib/fat_zebra/object_helper.rb | 2 ++ lib/fat_zebra/payment_plan.rb | 2 ++ lib/fat_zebra/paypal/authorization.rb | 4 +++- lib/fat_zebra/paypal/billing_agreement.rb | 4 +++- lib/fat_zebra/paypal/capture.rb | 4 +++- lib/fat_zebra/paypal/order.rb | 4 +++- lib/fat_zebra/paypal/refund.rb | 4 +++- lib/fat_zebra/purchase.rb | 7 +++++-- lib/fat_zebra/refund.rb | 2 ++ lib/fat_zebra/request.rb | 13 ++++++++----- lib/fat_zebra/request/multipart/epilogue.rb | 2 ++ lib/fat_zebra/request/multipart/file_io.rb | 2 ++ lib/fat_zebra/request/multipart/param.rb | 2 ++ lib/fat_zebra/request/multipart/part.rb | 4 +++- lib/fat_zebra/request/multipart/stream.rb | 3 +++ lib/fat_zebra/util.rb | 6 ++++-- .../mastercard/click_to_pay/registration.rb | 2 +- lib/fat_zebra/validation.rb | 10 ++++++---- lib/fat_zebra/version.rb | 4 +++- lib/fat_zebra/web_hook.rb | 2 ++ 45 files changed, 131 insertions(+), 46 deletions(-) create mode 100644 .tool-versions diff --git a/.rubocop.yml b/.rubocop.yml index 104c1a4..d915cde 100755 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,7 +7,7 @@ Layout/EmptyLinesAroundBlockBody: Style/MissingRespondToMissing: Enabled: false -Style/MethodMissingSuper: +Lint/MissingSuper: Enabled: false Style/NumericPredicate: Enabled: false @@ -34,7 +34,7 @@ Documentation: Enabled: false AllCops: - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.7 Exclude: - bin/**/* - vendor/**/* diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..f2a971a --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.2.2 diff --git a/.travis.yml b/.travis.yml index 46db112..5869704 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,6 @@ cache: bundler language: ruby rvm: - - 2.3 - - 2.4 - - 2.5 - - 2.6 - 2.7 - 3.2 script: diff --git a/Gemfile b/Gemfile index 7cbc750..56d08bf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' # Specify your gem's dependencies in FatZebra.gemspec diff --git a/Rakefile b/Rakefile index c341043..3c0eadc 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/gem_tasks' require 'rspec/core/rake_task' diff --git a/fat_zebra.gemspec b/fat_zebra.gemspec index 11d9935..651aef4 100644 --- a/fat_zebra.gemspec +++ b/fat_zebra.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) @@ -16,10 +18,12 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- {spec}/*`.split("\n") s.require_paths = %w[lib] + s.required_ruby_version = '>= 2.7' + s.add_development_dependency 'byebug' s.add_development_dependency 'rake' s.add_development_dependency 'rspec', '~> 3.6' - s.add_development_dependency 'rubocop', '~> 0.58.1' + s.add_development_dependency 'rubocop' s.add_development_dependency 'vcr', '~> 3.0' s.add_development_dependency 'webmock', '~> 3.0' end diff --git a/lib/fat_zebra.rb b/lib/fat_zebra.rb index a483f19..a4a4041 100644 --- a/lib/fat_zebra.rb +++ b/lib/fat_zebra.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__) # Libraries diff --git a/lib/fat_zebra/api_helper.rb b/lib/fat_zebra/api_helper.rb index e70a50c..94b8ad3 100644 --- a/lib/fat_zebra/api_helper.rb +++ b/lib/fat_zebra/api_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Helper @@ -40,20 +42,21 @@ def build_endpoint_url(base_url, path, params = nil, options = {}) port = port.to_i if port url_params = Util.compact( - host: host, - path: path, - port: port, + host: host, + path: path, + port: port, query: params ) return URI::HTTPS.build(url_params) if options[:http_secure] + URI::HTTP.build(url_params) end def default_headers { headers: { - accept: 'application/json', + accept: 'application/json', content_type: 'application/json' } } diff --git a/lib/fat_zebra/api_operation/delete.rb b/lib/fat_zebra/api_operation/delete.rb index cf7f513..385378b 100644 --- a/lib/fat_zebra/api_operation/delete.rb +++ b/lib/fat_zebra/api_operation/delete.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra class APIOperation ## diff --git a/lib/fat_zebra/api_operation/find.rb b/lib/fat_zebra/api_operation/find.rb index ee6c531..017e820 100644 --- a/lib/fat_zebra/api_operation/find.rb +++ b/lib/fat_zebra/api_operation/find.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra class APIOperation ## diff --git a/lib/fat_zebra/api_operation/save.rb b/lib/fat_zebra/api_operation/save.rb index 894caf4..cd3dc5f 100644 --- a/lib/fat_zebra/api_operation/save.rb +++ b/lib/fat_zebra/api_operation/save.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra class APIOperation ## diff --git a/lib/fat_zebra/api_operation/search.rb b/lib/fat_zebra/api_operation/search.rb index c7f1a31..81f9e1c 100644 --- a/lib/fat_zebra/api_operation/search.rb +++ b/lib/fat_zebra/api_operation/search.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra class APIOperation ## diff --git a/lib/fat_zebra/api_operation/void.rb b/lib/fat_zebra/api_operation/void.rb index a8a5026..fa73a76 100644 --- a/lib/fat_zebra/api_operation/void.rb +++ b/lib/fat_zebra/api_operation/void.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra class APIOperation ## diff --git a/lib/fat_zebra/api_resource.rb b/lib/fat_zebra/api_resource.rb index 13e2f10..edc777f 100644 --- a/lib/fat_zebra/api_resource.rb +++ b/lib/fat_zebra/api_resource.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \API \Resource @@ -30,16 +32,17 @@ def request(method, path, payload = {}, options = {}) uri = build_endpoint_url(configurations.gateway, path, url_params, http_secure: configurations.http_secure) request_options = Util.compact( - method: method, - url: uri.to_s, + method: method, + url: uri.to_s, payload: payload, - proxy: configurations.proxy, + proxy: configurations.proxy, use_ssl: configurations.http_secure ).merge(authentication).merge(default_headers).merge(configurations.global_options).merge(options) Request.execute(request_options).body - rescue FatZebra::RequestError => error - return error.http_body if error.http_status == 422 + rescue FatZebra::RequestError => e + return e.http_body if e.http_status == 422 + raise end # rubocop:enable Metrics/AbcSize @@ -48,8 +51,9 @@ def request(method, path, payload = {}, options = {}) def ssl_options return {} unless configurations.http_secure + { - ca_file: File.expand_path(File.dirname(__FILE__) + '/../../vendor/cacert.pem'), + ca_file: File.expand_path("#{File.dirname(__FILE__)}/../../vendor/cacert.pem"), verify_mode: OpenSSL::SSL::VERIFY_PEER } end @@ -57,7 +61,7 @@ def ssl_options def authentication { basic_auth: { - user: configurations.username, + user: configurations.username, password: configurations.token } } diff --git a/lib/fat_zebra/authenticate.rb b/lib/fat_zebra/authenticate.rb index 273bfdd..69d58d8 100644 --- a/lib/fat_zebra/authenticate.rb +++ b/lib/fat_zebra/authenticate.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Authenticate diff --git a/lib/fat_zebra/bank_account.rb b/lib/fat_zebra/bank_account.rb index 4f043c3..daa3ada 100644 --- a/lib/fat_zebra/bank_account.rb +++ b/lib/fat_zebra/bank_account.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Bank \Account diff --git a/lib/fat_zebra/batch.rb b/lib/fat_zebra/batch.rb index 49436a0..253600d 100644 --- a/lib/fat_zebra/batch.rb +++ b/lib/fat_zebra/batch.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Batch @@ -51,8 +53,9 @@ def create(params, options = {}) # @return [String] formated as CSV def result(params = {}, options = {}) request(:get, "#{resource_path}/#{id}/result.csv", params, options) - rescue FatZebra::RequestError => error - return error.http_body if error.http_status == 422 + rescue FatZebra::RequestError => e + return e.http_body if e.http_status == 422 + raise end diff --git a/lib/fat_zebra/card.rb b/lib/fat_zebra/card.rb index 6b2c743..a045d5b 100644 --- a/lib/fat_zebra/card.rb +++ b/lib/fat_zebra/card.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Card diff --git a/lib/fat_zebra/config.rb b/lib/fat_zebra/config.rb index 3e5c735..141d6ab 100644 --- a/lib/fat_zebra/config.rb +++ b/lib/fat_zebra/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Config @@ -7,7 +9,7 @@ class Config GATEWAY_URLS = { production: 'gateway.fatzebra.com.au', - sandbox: 'gateway.sandbox.fatzebra.com.au' + sandbox: 'gateway.sandbox.fatzebra.com.au' }.freeze ## diff --git a/lib/fat_zebra/customer.rb b/lib/fat_zebra/customer.rb index c34a5bb..dd978e6 100644 --- a/lib/fat_zebra/customer.rb +++ b/lib/fat_zebra/customer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Customer diff --git a/lib/fat_zebra/direct_credit.rb b/lib/fat_zebra/direct_credit.rb index 264f63c..9114964 100644 --- a/lib/fat_zebra/direct_credit.rb +++ b/lib/fat_zebra/direct_credit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Direct \Credit diff --git a/lib/fat_zebra/direct_debit.rb b/lib/fat_zebra/direct_debit.rb index 958b531..64e0ea9 100644 --- a/lib/fat_zebra/direct_debit.rb +++ b/lib/fat_zebra/direct_debit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Direct \Debit diff --git a/lib/fat_zebra/errors.rb b/lib/fat_zebra/errors.rb index 8f14874..20ad285 100644 --- a/lib/fat_zebra/errors.rb +++ b/lib/fat_zebra/errors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## @@ -16,10 +18,7 @@ class UnknownRequestMethod < StandardError; end # Request to API Error class RequestError < StandardError - attr_reader :http_body - attr_reader :http_status - attr_reader :http_status_type - attr_reader :http_message + attr_reader :http_body, :http_status, :http_status_type, :http_message def initialize(response, message: nil) @http_status = response.code.to_i diff --git a/lib/fat_zebra/fat_zebra_object.rb b/lib/fat_zebra/fat_zebra_object.rb index d7251e4..6466f50 100644 --- a/lib/fat_zebra/fat_zebra_object.rb +++ b/lib/fat_zebra/fat_zebra_object.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Object diff --git a/lib/fat_zebra/information.rb b/lib/fat_zebra/information.rb index 311148a..2d9c013 100644 --- a/lib/fat_zebra/information.rb +++ b/lib/fat_zebra/information.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Information diff --git a/lib/fat_zebra/object_helper.rb b/lib/fat_zebra/object_helper.rb index c7a680a..4e45f27 100644 --- a/lib/fat_zebra/object_helper.rb +++ b/lib/fat_zebra/object_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == Object \Helper diff --git a/lib/fat_zebra/payment_plan.rb b/lib/fat_zebra/payment_plan.rb index ecc287d..9cf6f5e 100644 --- a/lib/fat_zebra/payment_plan.rb +++ b/lib/fat_zebra/payment_plan.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Payment \Plan diff --git a/lib/fat_zebra/paypal/authorization.rb b/lib/fat_zebra/paypal/authorization.rb index 5450626..12abc7a 100644 --- a/lib/fat_zebra/paypal/authorization.rb +++ b/lib/fat_zebra/paypal/authorization.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Paypal::Authorization @@ -16,7 +18,7 @@ class Authorization < APIResource class << self def base_path - super + '/paypal/' + "#{super}/paypal/" end ## diff --git a/lib/fat_zebra/paypal/billing_agreement.rb b/lib/fat_zebra/paypal/billing_agreement.rb index 2c5c4af..cd2db82 100644 --- a/lib/fat_zebra/paypal/billing_agreement.rb +++ b/lib/fat_zebra/paypal/billing_agreement.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Paypal::BillingAgreement @@ -21,7 +23,7 @@ class BillingAgreement < APIResource class << self def base_path - super + '/paypal/' + "#{super}/paypal/" end ## diff --git a/lib/fat_zebra/paypal/capture.rb b/lib/fat_zebra/paypal/capture.rb index 95e8413..9b0ac5e 100644 --- a/lib/fat_zebra/paypal/capture.rb +++ b/lib/fat_zebra/paypal/capture.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Paypal::Capture @@ -15,7 +17,7 @@ class Capture < APIResource class << self def base_path - super + '/paypal/' + "#{super}/paypal/" end ## diff --git a/lib/fat_zebra/paypal/order.rb b/lib/fat_zebra/paypal/order.rb index f48a2d4..0e62be9 100644 --- a/lib/fat_zebra/paypal/order.rb +++ b/lib/fat_zebra/paypal/order.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Paypal::Order @@ -14,7 +16,7 @@ class Order < APIResource class << self def base_path - super + '/paypal/' + "#{super}/paypal/" end end end diff --git a/lib/fat_zebra/paypal/refund.rb b/lib/fat_zebra/paypal/refund.rb index 7907588..20a169e 100644 --- a/lib/fat_zebra/paypal/refund.rb +++ b/lib/fat_zebra/paypal/refund.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Paypal::Refund @@ -14,7 +16,7 @@ class Refund < APIResource class << self def base_path - super + '/paypal/' + "#{super}/paypal/" end end end diff --git a/lib/fat_zebra/purchase.rb b/lib/fat_zebra/purchase.rb index 897df71..9d35dc2 100644 --- a/lib/fat_zebra/purchase.rb +++ b/lib/fat_zebra/purchase.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Purchase @@ -71,8 +73,8 @@ def settlement(params = {}, options = {}) def refund(params = {}, options = {}) Refund.create({ transaction_id: id, - amount: amount, - reference: reference + amount: amount, + reference: reference }.merge(params), options) end @@ -112,6 +114,7 @@ def extend!(options = {}) # @return [Response] Purchase response object def increment!(additional_amount, options = {}) raise ArgumentError, 'Amount must be a positive amount' unless additional_amount > 0 + response = request(:put, resource_path("purchases/#{id}"), { amount: amount + additional_amount }, options) update_from(response) end diff --git a/lib/fat_zebra/refund.rb b/lib/fat_zebra/refund.rb index eaee208..4b13657 100644 --- a/lib/fat_zebra/refund.rb +++ b/lib/fat_zebra/refund.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Refund diff --git a/lib/fat_zebra/request.rb b/lib/fat_zebra/request.rb index 0012443..627e70a 100644 --- a/lib/fat_zebra/request.rb +++ b/lib/fat_zebra/request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'fat_zebra/request/multipart/part' require 'fat_zebra/request/multipart/stream' require 'fat_zebra/request/multipart/epilogue' @@ -15,13 +17,14 @@ class << self def execute(params = {}) klass = new(params) - if params[:method] == :post + case params[:method] + when :post klass.post - elsif params[:method] == :put + when :put klass.put - elsif params[:method] == :delete + when :delete klass.delete - elsif params[:method] == :get + when :get klass.get else raise FatZebra::UnknownRequestMethod, "#{params[:method]} haven't been implemented" @@ -131,7 +134,7 @@ def build_multipart_post parts << Multipart::Epilogue.new request.content_length = parts.inject(0) { |sum, part| sum + part.length } - request.content_type = 'multipart/form-data; boundary=' + parts.first.boundary + request.content_type = "multipart/form-data; boundary=#{parts.first.boundary}" request.body_stream = Multipart::Stream.new(parts.map(&:to_io)) end diff --git a/lib/fat_zebra/request/multipart/epilogue.rb b/lib/fat_zebra/request/multipart/epilogue.rb index eff633f..5b20e33 100644 --- a/lib/fat_zebra/request/multipart/epilogue.rb +++ b/lib/fat_zebra/request/multipart/epilogue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Request \Multipart \Epilogue diff --git a/lib/fat_zebra/request/multipart/file_io.rb b/lib/fat_zebra/request/multipart/file_io.rb index 68ddfa3..090f17e 100644 --- a/lib/fat_zebra/request/multipart/file_io.rb +++ b/lib/fat_zebra/request/multipart/file_io.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Request \Multipart \FileIO diff --git a/lib/fat_zebra/request/multipart/param.rb b/lib/fat_zebra/request/multipart/param.rb index 043d749..4b1bf26 100644 --- a/lib/fat_zebra/request/multipart/param.rb +++ b/lib/fat_zebra/request/multipart/param.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Request \Multipart \Param diff --git a/lib/fat_zebra/request/multipart/part.rb b/lib/fat_zebra/request/multipart/part.rb index d2b76be..b4fb0b7 100644 --- a/lib/fat_zebra/request/multipart/part.rb +++ b/lib/fat_zebra/request/multipart/part.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra ## # == FatZebra \Request \Multipart \Part @@ -7,7 +9,7 @@ class Request module Multipart module Part - LINE_BREAK = "\r\n".freeze + LINE_BREAK = "\r\n" def boundary '----FatZebraMultipartPost' diff --git a/lib/fat_zebra/request/multipart/stream.rb b/lib/fat_zebra/request/multipart/stream.rb index 5b23c2a..2b4ec87 100644 --- a/lib/fat_zebra/request/multipart/stream.rb +++ b/lib/fat_zebra/request/multipart/stream.rb @@ -1,3 +1,4 @@ +# rubocop:disable Style/FrozenStringLiteralComment module FatZebra ## # == FatZebra \Request \Multipart \Stream @@ -55,3 +56,5 @@ def next_io end end end + +# rubocop:enable Style/FrozenStringLiteralComment diff --git a/lib/fat_zebra/util.rb b/lib/fat_zebra/util.rb index 781b3e6..0e4c8b8 100644 --- a/lib/fat_zebra/util.rb +++ b/lib/fat_zebra/util.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + module FatZebra module Util class << self - DATE_FORMAT = '%Y/%m/%d'.freeze - REGEXP_HTTP = %r{http[s]?\:\/\/} + DATE_FORMAT = '%Y/%m/%d' + REGEXP_HTTP = %r{https?://}.freeze def cleanup_host(uri) uri.to_s.gsub(REGEXP_HTTP, '') diff --git a/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb b/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb index 6ac9368..cf5652c 100644 --- a/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb +++ b/lib/fat_zebra/utilities/mastercard/click_to_pay/registration.rb @@ -32,4 +32,4 @@ def registered? end end end -end \ No newline at end of file +end diff --git a/lib/fat_zebra/validation.rb b/lib/fat_zebra/validation.rb index 1161909..7600ed3 100644 --- a/lib/fat_zebra/validation.rb +++ b/lib/fat_zebra/validation.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FatZebra module Validation @@ -39,7 +41,7 @@ def validate_required(field, options, params) errors << "'#{field}' is required" if params[field].nil? || params[field] == '' end - # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/CyclomaticComplexity, Lint/MixedRegexpCaptureTypes def validate_type(field, options, params) regexp = case options @@ -50,9 +52,9 @@ def validate_type(field, options, params) when :positive_integer /\A\d*\z/ when :batch_filename - /\ABATCH-(?v\d)-(?[A-Z]*)-((?[A-Z0-9]*\-?[A-Z0-9]*)-)?(?\d{8})-(?[a-zA-Z0-9\-_]*).csv\z/i + /\ABATCH-(?v\d)-(?[A-Z]*)-((?[A-Z0-9]*-?[A-Z0-9]*)-)?(?\d{8})-(?[a-zA-Z0-9\-_]*).csv\z/i when :file_type - /\A\#\