From d2abb3942887da5981c8653614109dcdb6d88081 Mon Sep 17 00:00:00 2001 From: Peter Postma Date: Mon, 5 Jun 2023 21:18:16 +0200 Subject: [PATCH] Fix Style/StringLiterals violation. --- .rubocop.yml | 3 - Gemfile | 2 +- Rakefile | 6 +- bin/console | 6 +- lib/tikkie/api.rb | 110 +++++++++--------- lib/tikkie/api/amount.rb | 2 +- lib/tikkie/api/configuration.rb | 4 +- lib/tikkie/api/request.rb | 14 +-- lib/tikkie/api/resources/payment_request.rb | 14 +-- lib/tikkie/api/resources/payment_requests.rb | 2 +- .../payment_requests_subscription.rb | 4 +- lib/tikkie/api/resources/refund.rb | 4 +- lib/tikkie/api/resources/sandbox_app.rb | 2 +- lib/tikkie/api/version.rb | 2 +- lib/tikkie/notification.rb | 6 +- .../notifications/bundle_notification.rb | 2 +- .../notifications/payment_notification.rb | 2 +- .../notifications/refund_notification.rb | 2 +- spec/spec_helper.rb | 12 +- spec/tikkie/api/amount_spec.rb | 32 ++--- spec/tikkie/api/client_spec.rb | 4 +- .../api/clients/payment_requests_spec.rb | 92 +++++++-------- .../payment_requests_subscription_spec.rb | 16 +-- spec/tikkie/api/clients/payments_spec.rb | 38 +++--- spec/tikkie/api/clients/refunds_spec.rb | 30 ++--- spec/tikkie/api/clients/sandbox_apps_spec.rb | 10 +- spec/tikkie/api/configuration_spec.rb | 14 +-- .../api/resources/payment_request_spec.rb | 18 +-- .../api/resources/payment_requests_spec.rb | 8 +- spec/tikkie/api/resources/payment_spec.rb | 18 +-- spec/tikkie/api/resources/payments_spec.rb | 8 +- spec/tikkie/api/resources/refund_spec.rb | 14 +-- spec/tikkie/api/resources/sandbox_app_spec.rb | 8 +- spec/tikkie/notification_spec.rb | 10 +- .../notifications/bundle_notification_spec.rb | 4 +- .../payment_notification_spec.rb | 4 +- .../notifications/refund_notification_spec.rb | 4 +- tikkie-api.gemspec | 32 ++--- 38 files changed, 280 insertions(+), 283 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d312403..aa24ddb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -47,6 +47,3 @@ RSpec/MultipleExpectations: Style/SafeNavigation: Enabled: false - -Style/StringLiterals: - Enabled: false diff --git a/Gemfile b/Gemfile index f50c72e..3bf11d1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } diff --git a/Rakefile b/Rakefile index 68ff530..88eea32 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,8 @@ # frozen_string_literal: true -require "bundler/gem_tasks" -require "rspec/core/rake_task" -require "rubocop/rake_task" +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' +require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new(:rubocop) diff --git a/bin/console b/bin/console index a311648..858bc0f 100755 --- a/bin/console +++ b/bin/console @@ -1,8 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require "bundler/setup" -require "tikkie/api" +require 'bundler/setup' +require 'tikkie/api' # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. @@ -11,5 +11,5 @@ require "tikkie/api" # require "pry" # Pry.start -require "irb" +require 'irb' IRB.start(__FILE__) diff --git a/lib/tikkie/api.rb b/lib/tikkie/api.rb index b8d3b66..a8141f3 100644 --- a/lib/tikkie/api.rb +++ b/lib/tikkie/api.rb @@ -1,59 +1,59 @@ # frozen_string_literal: true -require "tikkie/api/version" - -require "tikkie/api/amount" -require "tikkie/api/client" -require "tikkie/api/configuration" -require "tikkie/api/exception" -require "tikkie/api/request" -require "tikkie/api/response" - -require "tikkie/api/clients/base" -require "tikkie/api/clients/payment_requests" -require "tikkie/api/clients/payment_requests_subscription" -require "tikkie/api/clients/payments" -require "tikkie/api/clients/refunds" -require "tikkie/api/clients/sandbox_apps" - -require "tikkie/api/resources/base" -require "tikkie/api/resources/error" -require "tikkie/api/resources/list" -require "tikkie/api/resources/payment_request" -require "tikkie/api/resources/payment_requests" -require "tikkie/api/resources/payment_requests_subscription" -require "tikkie/api/resources/payment" -require "tikkie/api/resources/payments" -require "tikkie/api/resources/refund" -require "tikkie/api/resources/sandbox_app" +require 'tikkie/api/version' + +require 'tikkie/api/amount' +require 'tikkie/api/client' +require 'tikkie/api/configuration' +require 'tikkie/api/exception' +require 'tikkie/api/request' +require 'tikkie/api/response' + +require 'tikkie/api/clients/base' +require 'tikkie/api/clients/payment_requests' +require 'tikkie/api/clients/payment_requests_subscription' +require 'tikkie/api/clients/payments' +require 'tikkie/api/clients/refunds' +require 'tikkie/api/clients/sandbox_apps' + +require 'tikkie/api/resources/base' +require 'tikkie/api/resources/error' +require 'tikkie/api/resources/list' +require 'tikkie/api/resources/payment_request' +require 'tikkie/api/resources/payment_requests' +require 'tikkie/api/resources/payment_requests_subscription' +require 'tikkie/api/resources/payment' +require 'tikkie/api/resources/payments' +require 'tikkie/api/resources/refund' +require 'tikkie/api/resources/sandbox_app' # Below the deprecated Tikkie v1 API code which will be removed after 01-01-2021. -require "tikkie/api/v1/access_token" -require "tikkie/api/v1/authentication" -require "tikkie/api/v1/client" -require "tikkie/api/v1/configuration" -require "tikkie/api/v1/exception" -require "tikkie/api/v1/request" - -require "tikkie/api/v1/requests/payment_requests" -require "tikkie/api/v1/requests/platforms" -require "tikkie/api/v1/requests/users" - -require "tikkie/api/v1/responses/base" -require "tikkie/api/v1/responses/bank_account" -require "tikkie/api/v1/responses/error" -require "tikkie/api/v1/responses/pagination" -require "tikkie/api/v1/responses/payment_request_created" -require "tikkie/api/v1/responses/payment_request" -require "tikkie/api/v1/responses/payment_requests" -require "tikkie/api/v1/responses/payment" -require "tikkie/api/v1/responses/platform" -require "tikkie/api/v1/responses/platforms" -require "tikkie/api/v1/responses/user" -require "tikkie/api/v1/responses/users" - -require "tikkie/api/v1/types/payment_request_status" -require "tikkie/api/v1/types/payment_status" -require "tikkie/api/v1/types/platform_status" -require "tikkie/api/v1/types/platform_usage" -require "tikkie/api/v1/types/user_status" +require 'tikkie/api/v1/access_token' +require 'tikkie/api/v1/authentication' +require 'tikkie/api/v1/client' +require 'tikkie/api/v1/configuration' +require 'tikkie/api/v1/exception' +require 'tikkie/api/v1/request' + +require 'tikkie/api/v1/requests/payment_requests' +require 'tikkie/api/v1/requests/platforms' +require 'tikkie/api/v1/requests/users' + +require 'tikkie/api/v1/responses/base' +require 'tikkie/api/v1/responses/bank_account' +require 'tikkie/api/v1/responses/error' +require 'tikkie/api/v1/responses/pagination' +require 'tikkie/api/v1/responses/payment_request_created' +require 'tikkie/api/v1/responses/payment_request' +require 'tikkie/api/v1/responses/payment_requests' +require 'tikkie/api/v1/responses/payment' +require 'tikkie/api/v1/responses/platform' +require 'tikkie/api/v1/responses/platforms' +require 'tikkie/api/v1/responses/user' +require 'tikkie/api/v1/responses/users' + +require 'tikkie/api/v1/types/payment_request_status' +require 'tikkie/api/v1/types/payment_status' +require 'tikkie/api/v1/types/platform_status' +require 'tikkie/api/v1/types/platform_usage' +require 'tikkie/api/v1/types/user_status' diff --git a/lib/tikkie/api/amount.rb b/lib/tikkie/api/amount.rb index 422e810..b77b9b3 100644 --- a/lib/tikkie/api/amount.rb +++ b/lib/tikkie/api/amount.rb @@ -23,7 +23,7 @@ def to_d # Convert the amount to a String with 2 decimals. def to_s - format("%.2f", @amount) + format('%.2f', @amount) end def to_cents diff --git a/lib/tikkie/api/configuration.rb b/lib/tikkie/api/configuration.rb index 5f1bf90..0552fbe 100644 --- a/lib/tikkie/api/configuration.rb +++ b/lib/tikkie/api/configuration.rb @@ -4,8 +4,8 @@ module Tikkie module Api # Tikkie API configuration. class Configuration - SANDBOX_API_URL = "https://api-sandbox.abnamro.com/v2/tikkie/" - PRODUCTION_API_URL = "https://api.abnamro.com/v2/tikkie/" + SANDBOX_API_URL = 'https://api-sandbox.abnamro.com/v2/tikkie/' + PRODUCTION_API_URL = 'https://api.abnamro.com/v2/tikkie/' attr_reader :api_key, :app_token, :sandbox diff --git a/lib/tikkie/api/request.rb b/lib/tikkie/api/request.rb index 62e4d0e..21b184a 100644 --- a/lib/tikkie/api/request.rb +++ b/lib/tikkie/api/request.rb @@ -46,14 +46,14 @@ def request(http_method, path, params = {}, body = {}) raise Tikkie::Api::Exception, "Invalid HTTP method: #{http_method}" end - request["Accept"] = "application/json" - request["Content-Type"] = "application/json" - request["Api-Key"] = config.api_key - request["X-App-Token"] = config.app_token if config.app_token - request["User-Agent"] = "Ruby tikkie-api/#{Tikkie::Api::VERSION}" + request['Accept'] = 'application/json' + request['Content-Type'] = 'application/json' + request['Api-Key'] = config.api_key + request['X-App-Token'] = config.app_token if config.app_token + request['User-Agent'] = "Ruby tikkie-api/#{Tikkie::Api::VERSION}" client = Net::HTTP.new(uri.hostname, uri.port) - client.use_ssl = uri.scheme == "https" + client.use_ssl = uri.scheme == 'https' client.verify_mode = OpenSSL::SSL::VERIFY_PEER begin @@ -67,7 +67,7 @@ def request(http_method, path, params = {}, body = {}) logger.debug("[Tikkie] Response: #{response.http_code}, body: #{response.body}") if ENV['TIKKIE_DEBUG'] - raise Tikkie::Api::Exception, "Invalid payload" if response.invalid? + raise Tikkie::Api::Exception, 'Invalid payload' if response.invalid? raise Tikkie::Api::RequestError, response if response.error? response diff --git a/lib/tikkie/api/resources/payment_request.rb b/lib/tikkie/api/resources/payment_request.rb index 32a514d..5adf017 100644 --- a/lib/tikkie/api/resources/payment_request.rb +++ b/lib/tikkie/api/resources/payment_request.rb @@ -7,11 +7,11 @@ module Api module Resources # Resource for a Payment Request. class PaymentRequest < Base - STATUS_OPEN = "OPEN" - STATUS_CLOSED = "CLOSED" - STATUS_EXPIRED = "EXPIRED" - STATUS_MAX_YIELDED_REACHED = "MAX_YIELD_REACHED" - STATUS_MAX_SUCCESSFUL_PAYMENTS_REACHED = "MAX_SUCCESSFUL_PAYMENTS_REACHED" + STATUS_OPEN = 'OPEN' + STATUS_CLOSED = 'CLOSED' + STATUS_EXPIRED = 'EXPIRED' + STATUS_MAX_YIELDED_REACHED = 'MAX_YIELD_REACHED' + STATUS_MAX_SUCCESSFUL_PAYMENTS_REACHED = 'MAX_SUCCESSFUL_PAYMENTS_REACHED' def initialize(config, options = {}) @payment_request_token = options.delete(:payment_request_token) @@ -86,10 +86,10 @@ def create_resource(attributes) amount = Tikkie::Api::Amount.new(attributes[:amount]) params[:amountInCents] = amount.to_cents end - params[:expiryDate] = attributes[:expiry_date].respond_to?(:strftime) ? attributes[:expiry_date].strftime("%F") : attributes[:expiry_date] if attributes.key?(:expiry_date) + params[:expiryDate] = attributes[:expiry_date].respond_to?(:strftime) ? attributes[:expiry_date].strftime('%F') : attributes[:expiry_date] if attributes.key?(:expiry_date) params[:referenceId] = attributes[:reference_id] if attributes.key?(:reference_id) - request.post("paymentrequests", options, params) + request.post('paymentrequests', options, params) end end end diff --git a/lib/tikkie/api/resources/payment_requests.rb b/lib/tikkie/api/resources/payment_requests.rb index b15a9be..e11a368 100644 --- a/lib/tikkie/api/resources/payment_requests.rb +++ b/lib/tikkie/api/resources/payment_requests.rb @@ -18,7 +18,7 @@ def load_resource params[:fromDate] = options[:from_date].respond_to?(:utc) ? options[:from_date].utc.iso8601 : options[:from_date] if options.key?(:from_date) params[:toDate] = options[:to_date].respond_to?(:utc) ? options[:to_date].utc.iso8601 : options[:to_date] if options.key?(:to_date) - request.get("paymentrequests", params) + request.get('paymentrequests', params) end def payment_requests diff --git a/lib/tikkie/api/resources/payment_requests_subscription.rb b/lib/tikkie/api/resources/payment_requests_subscription.rb index 01c44af..176eea9 100644 --- a/lib/tikkie/api/resources/payment_requests_subscription.rb +++ b/lib/tikkie/api/resources/payment_requests_subscription.rb @@ -12,11 +12,11 @@ def subscription_id private def create_resource(attributes) - request.post("paymentrequestssubscription", options, attributes) + request.post('paymentrequestssubscription', options, attributes) end def delete_resource - request.delete("paymentrequestssubscription", options) + request.delete('paymentrequestssubscription', options) end end end diff --git a/lib/tikkie/api/resources/refund.rb b/lib/tikkie/api/resources/refund.rb index b973811..9323dfa 100644 --- a/lib/tikkie/api/resources/refund.rb +++ b/lib/tikkie/api/resources/refund.rb @@ -7,8 +7,8 @@ module Api module Resources # Resource for a Refund. class Refund < Base - STATUS_PENDING = "PENDING" - STATUS_PAID = "PAID" + STATUS_PENDING = 'PENDING' + STATUS_PAID = 'PAID' attr_reader :payment_request_token, :payment_token diff --git a/lib/tikkie/api/resources/sandbox_app.rb b/lib/tikkie/api/resources/sandbox_app.rb index d74a7cf..bd63076 100644 --- a/lib/tikkie/api/resources/sandbox_app.rb +++ b/lib/tikkie/api/resources/sandbox_app.rb @@ -12,7 +12,7 @@ def app_token private def create_resource(attributes) - request.post("sandboxapps", options, attributes) + request.post('sandboxapps', options, attributes) end end end diff --git a/lib/tikkie/api/version.rb b/lib/tikkie/api/version.rb index 7d4175c..a46d9a0 100644 --- a/lib/tikkie/api/version.rb +++ b/lib/tikkie/api/version.rb @@ -2,6 +2,6 @@ module Tikkie module Api - VERSION = "2.0.0" + VERSION = '2.0.0' end end diff --git a/lib/tikkie/notification.rb b/lib/tikkie/notification.rb index f3cde8a..a2ffd21 100644 --- a/lib/tikkie/notification.rb +++ b/lib/tikkie/notification.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require "tikkie/notifications/bundle_notification" -require "tikkie/notifications/payment_notification" -require "tikkie/notifications/refund_notification" +require 'tikkie/notifications/bundle_notification' +require 'tikkie/notifications/payment_notification' +require 'tikkie/notifications/refund_notification' module Tikkie # Parses the payload for a Notification. diff --git a/lib/tikkie/notifications/bundle_notification.rb b/lib/tikkie/notifications/bundle_notification.rb index a3331d3..74d0bb4 100644 --- a/lib/tikkie/notifications/bundle_notification.rb +++ b/lib/tikkie/notifications/bundle_notification.rb @@ -4,7 +4,7 @@ module Tikkie module Notifications # Bundle notification. class BundleNotification - NOTIFICATION_TYPE = "BUNDLE" + NOTIFICATION_TYPE = 'BUNDLE' attr_reader :body diff --git a/lib/tikkie/notifications/payment_notification.rb b/lib/tikkie/notifications/payment_notification.rb index a8c97d2..c051eeb 100644 --- a/lib/tikkie/notifications/payment_notification.rb +++ b/lib/tikkie/notifications/payment_notification.rb @@ -4,7 +4,7 @@ module Tikkie module Notifications # Payment notification. class PaymentNotification - NOTIFICATION_TYPE = "PAYMENT" + NOTIFICATION_TYPE = 'PAYMENT' attr_reader :body diff --git a/lib/tikkie/notifications/refund_notification.rb b/lib/tikkie/notifications/refund_notification.rb index cac5f62..9a2ba13 100644 --- a/lib/tikkie/notifications/refund_notification.rb +++ b/lib/tikkie/notifications/refund_notification.rb @@ -4,7 +4,7 @@ module Tikkie module Notifications # Refund notification. class RefundNotification - NOTIFICATION_TYPE = "REFUND" + NOTIFICATION_TYPE = 'REFUND' attr_reader :body diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6dd3b53..d9ea405 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "bundler/setup" -require "tikkie/api" -require "tikkie/notification" -require "webmock/rspec" -require "timecop" +require 'bundler/setup' +require 'tikkie/api' +require 'tikkie/notification' +require 'webmock/rspec' +require 'timecop' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" + config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! diff --git a/spec/tikkie/api/amount_spec.rb b/spec/tikkie/api/amount_spec.rb index b2d6b57..3298772 100644 --- a/spec/tikkie/api/amount_spec.rb +++ b/spec/tikkie/api/amount_spec.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Amount do describe '.from_cents' do it 'converts cents as Integer to an amount' do amount = described_class.from_cents(1234) - expect(amount.to_s).to eq("12.34") + expect(amount.to_s).to eq('12.34') end it 'converts cents as String to an amount' do - amount = described_class.from_cents("1234") - expect(amount.to_s).to eq("12.34") + amount = described_class.from_cents('1234') + expect(amount.to_s).to eq('12.34') end it 'converts cents as BigDecimal to an amount' do - amount = described_class.from_cents(BigDecimal("1234")) - expect(amount.to_s).to eq("12.34") + amount = described_class.from_cents(BigDecimal('1234')) + expect(amount.to_s).to eq('12.34') end end @@ -26,47 +26,47 @@ end it 'converts a String to cents' do - expect(described_class.new("42").to_cents).to eq(4200) + expect(described_class.new('42').to_cents).to eq(4200) end it 'converts a String with decimals to cents' do - expect(described_class.new("12.34").to_cents).to eq(1234) + expect(described_class.new('12.34').to_cents).to eq(1234) end it 'converts a BigDecimal to cents' do - expect(described_class.new(BigDecimal("1.23")).to_cents).to eq(123) + expect(described_class.new(BigDecimal('1.23')).to_cents).to eq(123) end end describe '#to_d' do it 'returns the decimal value of an Integer' do - expect(described_class.new(42).to_d).to eq(BigDecimal("42")) + expect(described_class.new(42).to_d).to eq(BigDecimal('42')) end it 'returns the decimal value of a String' do - expect(described_class.new("42").to_d).to eq(BigDecimal("42")) + expect(described_class.new('42').to_d).to eq(BigDecimal('42')) end it 'returns the decimal value of a String with decimals' do - expect(described_class.new("12.34").to_d).to eq(BigDecimal("12.34")) + expect(described_class.new('12.34').to_d).to eq(BigDecimal('12.34')) end end describe '#to_s' do it 'converts an Integer to a String representation' do - expect(described_class.new(42).to_s).to eq("42.00") + expect(described_class.new(42).to_s).to eq('42.00') end it 'converts a String to a String representation' do - expect(described_class.new("42").to_s).to eq("42.00") + expect(described_class.new('42').to_s).to eq('42.00') end it 'converts a String with decimals to a String representation' do - expect(described_class.new("12.34").to_s).to eq("12.34") + expect(described_class.new('12.34').to_s).to eq('12.34') end it 'converts a BigDecimal to a String representation' do - expect(described_class.new(BigDecimal("1.23")).to_s).to eq("1.23") + expect(described_class.new(BigDecimal('1.23')).to_s).to eq('1.23') end end end diff --git a/spec/tikkie/api/client_spec.rb b/spec/tikkie/api/client_spec.rb index 1746daf..bdf3f10 100644 --- a/spec/tikkie/api/client_spec.rb +++ b/spec/tikkie/api/client_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Client do - subject(:client) { described_class.new(api_key: "12345", app_token: "abcdef") } + subject(:client) { described_class.new(api_key: '12345', app_token: 'abcdef') } describe '#payment_requests_subscription' do it 'returns a payment requests subscription client' do diff --git a/spec/tikkie/api/clients/payment_requests_spec.rb b/spec/tikkie/api/clients/payment_requests_spec.rb index f56bc9c..0db68b9 100644 --- a/spec/tikkie/api/clients/payment_requests_spec.rb +++ b/spec/tikkie/api/clients/payment_requests_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Clients::PaymentRequests do subject(:client) { described_class.new(config) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } describe 'error handling' do context 'when response is HTTP 400' do it 'raises an exception and includes the errors' do - data = File.read("spec/fixtures/responses/payment_requests/400.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50").to_return(status: [400, "Bad Request"], body: data) + data = File.read('spec/fixtures/responses/payment_requests/400.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50').to_return(status: [400, 'Bad Request'], body: data) expect { client.list }.to raise_error(Tikkie::Api::RequestError) do |exception| - expect(exception.message).to eq("400 Bad Request: pageNumber was not supplied in the query.") + expect(exception.message).to eq('400 Bad Request: pageNumber was not supplied in the query.') expect(exception.errors).not_to be_empty error = exception.errors.first expect(error).to be_a(Tikkie::Api::Resources::Error) - expect(error.code).to eq("PAGE_NUMBER_MISSING") - expect(error.message).to eq("pageNumber was not supplied in the query.") - expect(error.reference).to eq("https://developer.abnamro.com") + expect(error.code).to eq('PAGE_NUMBER_MISSING') + expect(error.message).to eq('pageNumber was not supplied in the query.') + expect(error.reference).to eq('https://developer.abnamro.com') expect(error.status).to eq(400) end end @@ -29,18 +29,18 @@ context 'when response is HTTP 401' do it 'raises an exception and includes the errors' do - data = File.read("spec/fixtures/responses/payment_requests/401.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50").to_return(status: [401, "Unauthorized"], body: data) + data = File.read('spec/fixtures/responses/payment_requests/401.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50').to_return(status: [401, 'Unauthorized'], body: data) expect { client.list }.to raise_error(Tikkie::Api::RequestError) do |exception| - expect(exception.message).to eq("401 Unauthorized: appToken is in an invalid format.") + expect(exception.message).to eq('401 Unauthorized: appToken is in an invalid format.') expect(exception.errors).not_to be_empty error = exception.errors.first expect(error).to be_a(Tikkie::Api::Resources::Error) - expect(error.code).to eq("APP_TOKEN_INVALID") - expect(error.message).to eq("appToken is in an invalid format.") - expect(error.reference).to eq("https://developer.abnamro.com") + expect(error.code).to eq('APP_TOKEN_INVALID') + expect(error.message).to eq('appToken is in an invalid format.') + expect(error.reference).to eq('https://developer.abnamro.com') expect(error.status).to eq(401) end end @@ -48,18 +48,18 @@ context 'when response is HTTP 403' do it 'raises an exception and includes the errors' do - data = File.read("spec/fixtures/responses/payment_requests/403.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50").to_return(status: [403, "Forbidden"], body: data) + data = File.read('spec/fixtures/responses/payment_requests/403.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50').to_return(status: [403, 'Forbidden'], body: data) expect { client.list }.to raise_error(Tikkie::Api::RequestError) do |exception| - expect(exception.message).to eq("403 Forbidden: appToken does not have permission to create or get payment requests.") + expect(exception.message).to eq('403 Forbidden: appToken does not have permission to create or get payment requests.') expect(exception.errors).not_to be_empty error = exception.errors.first expect(error).to be_a(Tikkie::Api::Resources::Error) - expect(error.code).to eq("PAYMENT_REQUEST_FORBIDDEN") - expect(error.message).to eq("appToken does not have permission to create or get payment requests.") - expect(error.reference).to eq("https://developer.abnamro.com") + expect(error.code).to eq('PAYMENT_REQUEST_FORBIDDEN') + expect(error.message).to eq('appToken does not have permission to create or get payment requests.') + expect(error.reference).to eq('https://developer.abnamro.com') expect(error.status).to eq(403) end end @@ -67,17 +67,17 @@ context 'when response contains invalid payload' do it 'raises an exception' do - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50").to_return(status: [500, "Internal Server Error"], body: "Internal Server Error") + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50').to_return(status: [500, 'Internal Server Error'], body: 'Internal Server Error') - expect { client.list }.to raise_error(Tikkie::Api::Exception, "Invalid payload") + expect { client.list }.to raise_error(Tikkie::Api::Exception, 'Invalid payload') end end end describe '#list' do it 'returns a list of payment requests' do - data = File.read("spec/fixtures/responses/payment_requests/list.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payment_requests/list.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=0&pageSize=50').to_return(status: 200, body: data) payment_requests = client.list expect(payment_requests).to be_a(Tikkie::Api::Resources::PaymentRequests) @@ -87,12 +87,12 @@ payment_request = payment_requests.first expect(payment_request).to be_a(Tikkie::Api::Resources::PaymentRequest) - expect(payment_request.payment_request_token).to eq("qzdnzr8hnVWTgXXcFRLUMc") + expect(payment_request.payment_request_token).to eq('qzdnzr8hnVWTgXXcFRLUMc') end it 'paginates using page_number and page_size as parameters' do - data = File.read("spec/fixtures/responses/payment_requests/list.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=2&pageSize=25").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payment_requests/list.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?pageNumber=2&pageSize=25').to_return(status: 200, body: data) payment_requests = client.list(page_number: 2, page_size: 25) expect(payment_requests).to be_a(Tikkie::Api::Resources::PaymentRequests) @@ -101,8 +101,8 @@ end it 'filters data using from_date and to_date as parameters' do - data = File.read("spec/fixtures/responses/payment_requests/list.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests?fromDate=2018-01-01T00:00:00Z&pageNumber=0&pageSize=50&toDate=2018-01-07T00:00:00Z").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payment_requests/list.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests?fromDate=2018-01-01T00:00:00Z&pageNumber=0&pageSize=50&toDate=2018-01-07T00:00:00Z').to_return(status: 200, body: data) payment_requests = client.list(from_date: Time.utc(2018, 1, 1), to_date: Time.utc(2018, 1, 7)) expect(payment_requests).to be_a(Tikkie::Api::Resources::PaymentRequests) @@ -112,43 +112,43 @@ describe '#get' do it 'returns a single payment request' do - data = File.read("spec/fixtures/responses/payment_requests/get.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payment_requests/get.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc').to_return(status: 200, body: data) - payment_request = client.get("qzdnzr8hnVWTgXXcFRLUMc") + payment_request = client.get('qzdnzr8hnVWTgXXcFRLUMc') expect(payment_request).to be_a(Tikkie::Api::Resources::PaymentRequest) - expect(payment_request.payment_request_token).to eq("qzdnzr8hnVWTgXXcFRLUMc") + expect(payment_request.payment_request_token).to eq('qzdnzr8hnVWTgXXcFRLUMc') end it 'raises an error when the payment was not found' do - data = File.read("spec/fixtures/responses/payment_requests/404.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc").to_return(status: [404, "Not Found"], body: data) + data = File.read('spec/fixtures/responses/payment_requests/404.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc').to_return(status: [404, 'Not Found'], body: data) - expect { client.get("qzdnzr8hnVWTgXXcFRLUMc") }.to raise_error(Tikkie::Api::RequestError, "404 Not Found: No payment request was found for the specified paymentRequestToken.") + expect { client.get('qzdnzr8hnVWTgXXcFRLUMc') }.to raise_error(Tikkie::Api::RequestError, '404 Not Found: No payment request was found for the specified paymentRequestToken.') end end describe '#create' do it 'creates a new payment request' do - data = File.read("spec/fixtures/responses/payment_requests/create.json") - stub_request(:post, "https://api.abnamro.com/v2/tikkie/paymentrequests") - .with(body: { description: "Test", amountInCents: 500, referenceId: "Ref-12345" }.to_json) + data = File.read('spec/fixtures/responses/payment_requests/create.json') + stub_request(:post, 'https://api.abnamro.com/v2/tikkie/paymentrequests') + .with(body: { description: 'Test', amountInCents: 500, referenceId: 'Ref-12345' }.to_json) .to_return(status: 201, body: data) - payment_request = client.create(amount: "5.00", description: "Test", reference_id: "Ref-12345") + payment_request = client.create(amount: '5.00', description: 'Test', reference_id: 'Ref-12345') expect(payment_request).to be_a(Tikkie::Api::Resources::PaymentRequest) - expect(payment_request.payment_request_token).to eq("qzdnzr8hnVWTgXXcFRLUMc") + expect(payment_request.payment_request_token).to eq('qzdnzr8hnVWTgXXcFRLUMc') end it 'creates a payment request with custom expiration date' do - data = File.read("spec/fixtures/responses/payment_requests/create.json") - stub_request(:post, "https://api.abnamro.com/v2/tikkie/paymentrequests") - .with(body: { description: "Test", amountInCents: 500, expiryDate: "2021-01-31" }.to_json) + data = File.read('spec/fixtures/responses/payment_requests/create.json') + stub_request(:post, 'https://api.abnamro.com/v2/tikkie/paymentrequests') + .with(body: { description: 'Test', amountInCents: 500, expiryDate: '2021-01-31' }.to_json) .to_return(status: 201, body: data) - payment_request = client.create(amount: "5.00", description: "Test", expiry_date: Date.new(2021, 1, 31)) + payment_request = client.create(amount: '5.00', description: 'Test', expiry_date: Date.new(2021, 1, 31)) expect(payment_request).to be_a(Tikkie::Api::Resources::PaymentRequest) - expect(payment_request.payment_request_token).to eq("qzdnzr8hnVWTgXXcFRLUMc") + expect(payment_request.payment_request_token).to eq('qzdnzr8hnVWTgXXcFRLUMc') end it 'raises an error when required parameters are missing' do diff --git a/spec/tikkie/api/clients/payment_requests_subscription_spec.rb b/spec/tikkie/api/clients/payment_requests_subscription_spec.rb index b7b8102..4425da0 100644 --- a/spec/tikkie/api/clients/payment_requests_subscription_spec.rb +++ b/spec/tikkie/api/clients/payment_requests_subscription_spec.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Clients::PaymentRequestsSubscription do subject(:client) { described_class.new(config) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } describe '#create' do it 'creates a new payment requests subscription' do - data = File.read("spec/fixtures/responses/payment_requests_subscription/create.json") - stub_request(:post, "https://api.abnamro.com/v2/tikkie/paymentrequestssubscription") - .with(body: { url: "https://www.example.com/notification" }.to_json) + data = File.read('spec/fixtures/responses/payment_requests_subscription/create.json') + stub_request(:post, 'https://api.abnamro.com/v2/tikkie/paymentrequestssubscription') + .with(body: { url: 'https://www.example.com/notification' }.to_json) .to_return(status: 201, body: data) - payment_requests_subscription = client.create(url: "https://www.example.com/notification") + payment_requests_subscription = client.create(url: 'https://www.example.com/notification') expect(payment_requests_subscription).to be_a(Tikkie::Api::Resources::PaymentRequestsSubscription) - expect(payment_requests_subscription.subscription_id).to eq("e0111835-e8df-4070-874a-f12cf3f77e39") + expect(payment_requests_subscription.subscription_id).to eq('e0111835-e8df-4070-874a-f12cf3f77e39') end end describe '#delete' do it 'deletes the current payment requests subscription' do - stub_request(:delete, "https://api.abnamro.com/v2/tikkie/paymentrequestssubscription").to_return(status: 204) + stub_request(:delete, 'https://api.abnamro.com/v2/tikkie/paymentrequestssubscription').to_return(status: 204) payment_requests_subscription = client.delete expect(payment_requests_subscription).to be nil diff --git a/spec/tikkie/api/clients/payments_spec.rb b/spec/tikkie/api/clients/payments_spec.rb index 1e37954..1c7d1f6 100644 --- a/spec/tikkie/api/clients/payments_spec.rb +++ b/spec/tikkie/api/clients/payments_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Clients::Payments do subject(:client) { described_class.new(config) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } describe '#list' do it 'returns a list of payments' do - data = File.read("spec/fixtures/responses/payments/list.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments?pageNumber=0&pageSize=50").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payments/list.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments?pageNumber=0&pageSize=50').to_return(status: 200, body: data) - payments = client.list("qzdnzr8hnVWTgXXcFRLUMc") + payments = client.list('qzdnzr8hnVWTgXXcFRLUMc') expect(payments).to be_a(Tikkie::Api::Resources::Payments) expect(payments.page_number).to eq(0) expect(payments.page_size).to eq(50) @@ -20,24 +20,24 @@ payment = payments.first expect(payment).to be_a(Tikkie::Api::Resources::Payment) - expect(payment.payment_token).to eq("21ef7413-cc3c-4c80-9272-6710fada28e4") + expect(payment.payment_token).to eq('21ef7413-cc3c-4c80-9272-6710fada28e4') end it 'paginates using page_number and page_size as parameters' do - data = File.read("spec/fixtures/responses/payments/list.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments?pageNumber=2&pageSize=25").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payments/list.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments?pageNumber=2&pageSize=25').to_return(status: 200, body: data) - payments = client.list("qzdnzr8hnVWTgXXcFRLUMc", page_number: 2, page_size: 25) + payments = client.list('qzdnzr8hnVWTgXXcFRLUMc', page_number: 2, page_size: 25) expect(payments).to be_a(Tikkie::Api::Resources::Payments) expect(payments.page_number).to eq(2) expect(payments.page_size).to eq(25) end it 'filters data using from_date and to_date as parameters' do - data = File.read("spec/fixtures/responses/payments/list.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments?fromDate=2018-01-01T00:00:00Z&pageNumber=0&pageSize=50&toDate=2018-01-07T00:00:00Z").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payments/list.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments?fromDate=2018-01-01T00:00:00Z&pageNumber=0&pageSize=50&toDate=2018-01-07T00:00:00Z').to_return(status: 200, body: data) - payments = client.list("qzdnzr8hnVWTgXXcFRLUMc", from_date: Time.utc(2018, 1, 1), to_date: Time.utc(2018, 1, 7)) + payments = client.list('qzdnzr8hnVWTgXXcFRLUMc', from_date: Time.utc(2018, 1, 1), to_date: Time.utc(2018, 1, 7)) expect(payments).to be_a(Tikkie::Api::Resources::Payments) expect(payments.count).to eq(1) end @@ -45,19 +45,19 @@ describe '#get' do it 'returns a single payment' do - data = File.read("spec/fixtures/responses/payments/get.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/payments/get.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4').to_return(status: 200, body: data) - payment = client.get("qzdnzr8hnVWTgXXcFRLUMc", "21ef7413-cc3c-4c80-9272-6710fada28e4") + payment = client.get('qzdnzr8hnVWTgXXcFRLUMc', '21ef7413-cc3c-4c80-9272-6710fada28e4') expect(payment).to be_a(Tikkie::Api::Resources::Payment) - expect(payment.payment_token).to eq("21ef7413-cc3c-4c80-9272-6710fada28e4") + expect(payment.payment_token).to eq('21ef7413-cc3c-4c80-9272-6710fada28e4') end it 'raises an error when the payment was not found' do - data = File.read("spec/fixtures/responses/payments/404.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4").to_return(status: [404, "Not Found"], body: data) + data = File.read('spec/fixtures/responses/payments/404.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4').to_return(status: [404, 'Not Found'], body: data) - expect { client.get("qzdnzr8hnVWTgXXcFRLUMc", "21ef7413-cc3c-4c80-9272-6710fada28e4") }.to raise_error(Tikkie::Api::RequestError, "404 Not Found: No payment was found for the specified paymentToken.") + expect { client.get('qzdnzr8hnVWTgXXcFRLUMc', '21ef7413-cc3c-4c80-9272-6710fada28e4') }.to raise_error(Tikkie::Api::RequestError, '404 Not Found: No payment was found for the specified paymentToken.') end end end diff --git a/spec/tikkie/api/clients/refunds_spec.rb b/spec/tikkie/api/clients/refunds_spec.rb index 37f1773..2c344bd 100644 --- a/spec/tikkie/api/clients/refunds_spec.rb +++ b/spec/tikkie/api/clients/refunds_spec.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Clients::Refunds do subject(:client) { described_class.new(config) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } describe '#get' do it 'returns a single refund' do - data = File.read("spec/fixtures/responses/refunds/get.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4/refunds/abcdzr8hnVWTgXXcFRLUMc").to_return(status: 200, body: data) + data = File.read('spec/fixtures/responses/refunds/get.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4/refunds/abcdzr8hnVWTgXXcFRLUMc').to_return(status: 200, body: data) - refund = client.get("qzdnzr8hnVWTgXXcFRLUMc", "21ef7413-cc3c-4c80-9272-6710fada28e4", "abcdzr8hnVWTgXXcFRLUMc") + refund = client.get('qzdnzr8hnVWTgXXcFRLUMc', '21ef7413-cc3c-4c80-9272-6710fada28e4', 'abcdzr8hnVWTgXXcFRLUMc') expect(refund).to be_a(Tikkie::Api::Resources::Refund) - expect(refund.refund_token).to eq("abcdzr8hnVWTgXXcFRLUMc") + expect(refund.refund_token).to eq('abcdzr8hnVWTgXXcFRLUMc') end it 'raises an error when the refund was not found' do - data = File.read("spec/fixtures/responses/refunds/404.json") - stub_request(:get, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4/refunds/abcdzr8hnVWTgXXcFRLUMc").to_return(status: [404, "Not Found"], body: data) + data = File.read('spec/fixtures/responses/refunds/404.json') + stub_request(:get, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4/refunds/abcdzr8hnVWTgXXcFRLUMc').to_return(status: [404, 'Not Found'], body: data) - expect { client.get("qzdnzr8hnVWTgXXcFRLUMc", "21ef7413-cc3c-4c80-9272-6710fada28e4", "abcdzr8hnVWTgXXcFRLUMc") }.to raise_error(Tikkie::Api::RequestError, "404 Not Found: No refund was found for the specified refundToken.") + expect { client.get('qzdnzr8hnVWTgXXcFRLUMc', '21ef7413-cc3c-4c80-9272-6710fada28e4', 'abcdzr8hnVWTgXXcFRLUMc') }.to raise_error(Tikkie::Api::RequestError, '404 Not Found: No refund was found for the specified refundToken.') end end describe '#create' do it 'creates a new refund' do - data = File.read("spec/fixtures/responses/refunds/create.json") - stub_request(:post, "https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4/refunds") - .with(body: { description: "Refunded 10.00 for broken product.", amountInCents: 1000, referenceId: "Ref-12345" }.to_json) + data = File.read('spec/fixtures/responses/refunds/create.json') + stub_request(:post, 'https://api.abnamro.com/v2/tikkie/paymentrequests/qzdnzr8hnVWTgXXcFRLUMc/payments/21ef7413-cc3c-4c80-9272-6710fada28e4/refunds') + .with(body: { description: 'Refunded 10.00 for broken product.', amountInCents: 1000, referenceId: 'Ref-12345' }.to_json) .to_return(status: 201, body: data) - refund = client.create("qzdnzr8hnVWTgXXcFRLUMc", "21ef7413-cc3c-4c80-9272-6710fada28e4", amount: "10.00", description: "Refunded 10.00 for broken product.", reference_id: "Ref-12345") + refund = client.create('qzdnzr8hnVWTgXXcFRLUMc', '21ef7413-cc3c-4c80-9272-6710fada28e4', amount: '10.00', description: 'Refunded 10.00 for broken product.', reference_id: 'Ref-12345') expect(refund).to be_a(Tikkie::Api::Resources::Refund) - expect(refund.refund_token).to eq("abcdzr8hnVWTgXXcFRLUMc") + expect(refund.refund_token).to eq('abcdzr8hnVWTgXXcFRLUMc') end it 'raises an error when required parameters are missing' do - expect { client.create("qzdnzr8hnVWTgXXcFRLUMc", "21ef7413-cc3c-4c80-9272-6710fada28e4") }.to raise_error(KeyError) + expect { client.create('qzdnzr8hnVWTgXXcFRLUMc', '21ef7413-cc3c-4c80-9272-6710fada28e4') }.to raise_error(KeyError) end end end diff --git a/spec/tikkie/api/clients/sandbox_apps_spec.rb b/spec/tikkie/api/clients/sandbox_apps_spec.rb index c8ec0f6..b8593ad 100644 --- a/spec/tikkie/api/clients/sandbox_apps_spec.rb +++ b/spec/tikkie/api/clients/sandbox_apps_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Clients::SandboxApps do subject(:client) { described_class.new(config) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } describe '#create' do it 'creates a new sandbox app' do - data = File.read("spec/fixtures/responses/sandbox_apps/create.json") - stub_request(:post, "https://api.abnamro.com/v2/tikkie/sandboxapps").to_return(status: 201, body: data) + data = File.read('spec/fixtures/responses/sandbox_apps/create.json') + stub_request(:post, 'https://api.abnamro.com/v2/tikkie/sandboxapps').to_return(status: 201, body: data) sandbox_app = client.create expect(sandbox_app).to be_a(Tikkie::Api::Resources::SandboxApp) - expect(sandbox_app.app_token).to eq("935059a6-58b3-4f8d-a021-7bdda0d8d6ad") + expect(sandbox_app.app_token).to eq('935059a6-58b3-4f8d-a021-7bdda0d8d6ad') end end end diff --git a/spec/tikkie/api/configuration_spec.rb b/spec/tikkie/api/configuration_spec.rb index 295a535..a40176f 100644 --- a/spec/tikkie/api/configuration_spec.rb +++ b/spec/tikkie/api/configuration_spec.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Configuration do - subject(:config) { described_class.new(api_key: "12345", app_token: "abcdef") } + subject(:config) { described_class.new(api_key: '12345', app_token: 'abcdef') } describe '#api_key' do it 'returns the API key' do - expect(config.api_key).to eq("12345") + expect(config.api_key).to eq('12345') end end describe '#app_token' do it 'returns the App token' do - expect(config.app_token).to eq("abcdef") + expect(config.app_token).to eq('abcdef') end end describe '#api_url' do it 'returns the production API url' do - expect(config.api_url).to eq("https://api.abnamro.com/v2/tikkie/") + expect(config.api_url).to eq('https://api.abnamro.com/v2/tikkie/') end end context 'when sandboxed' do - subject(:config) { described_class.new(api_key: "12345", app_token: "abcdef", sandbox: true) } + subject(:config) { described_class.new(api_key: '12345', app_token: 'abcdef', sandbox: true) } describe '#api_url' do it 'returns the sandbox API url' do - expect(config.api_url).to eq("https://api-sandbox.abnamro.com/v2/tikkie/") + expect(config.api_url).to eq('https://api-sandbox.abnamro.com/v2/tikkie/') end end end diff --git a/spec/tikkie/api/resources/payment_request_spec.rb b/spec/tikkie/api/resources/payment_request_spec.rb index 40c4872..af9510f 100644 --- a/spec/tikkie/api/resources/payment_request_spec.rb +++ b/spec/tikkie/api/resources/payment_request_spec.rb @@ -1,40 +1,40 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Resources::PaymentRequest do subject(:resource) { described_class.new(config, body: body) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } - let(:body) { JSON.parse(File.read("spec/fixtures/responses/payment_requests/get.json"), symbolize_names: true) } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } + let(:body) { JSON.parse(File.read('spec/fixtures/responses/payment_requests/get.json'), symbolize_names: true) } describe '#payment_request_token' do it 'returns the payment request token' do - expect(resource.payment_request_token).to eq("qzdnzr8hnVWTgXXcFRLUMc") + expect(resource.payment_request_token).to eq('qzdnzr8hnVWTgXXcFRLUMc') end end describe '#url' do it 'returns the URL' do - expect(resource.url).to eq("https://tikkie.me/pay/Tikkie/qzdnzr8hnVWTgXXcFRLUMc") + expect(resource.url).to eq('https://tikkie.me/pay/Tikkie/qzdnzr8hnVWTgXXcFRLUMc') end end describe '#amount' do it 'returns the amount' do - expect(resource.amount).to eq(BigDecimal("15")) + expect(resource.amount).to eq(BigDecimal('15')) end end describe '#description' do it 'returns the description' do - expect(resource.description).to eq("Invoice 1815") + expect(resource.description).to eq('Invoice 1815') end end describe '#reference_id' do it 'returns the reference_id' do - expect(resource.reference_id).to eq("inv_1815") + expect(resource.reference_id).to eq('inv_1815') end end @@ -82,7 +82,7 @@ describe '#total_amount_paid' do it 'returns the total amount paid' do - expect(resource.total_amount_paid).to eq(BigDecimal("30")) + expect(resource.total_amount_paid).to eq(BigDecimal('30')) end end end diff --git a/spec/tikkie/api/resources/payment_requests_spec.rb b/spec/tikkie/api/resources/payment_requests_spec.rb index 5846f2a..8e90fe0 100644 --- a/spec/tikkie/api/resources/payment_requests_spec.rb +++ b/spec/tikkie/api/resources/payment_requests_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Resources::PaymentRequests do subject(:resource) { described_class.new(config, body: data) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } - let(:data) { JSON.parse(File.read("spec/fixtures/responses/payment_requests/list.json"), symbolize_names: true) } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } + let(:data) { JSON.parse(File.read('spec/fixtures/responses/payment_requests/list.json'), symbolize_names: true) } describe 'enumerable' do it 'returns the payment requests' do @@ -14,7 +14,7 @@ expect(resource.first).to be_a(Tikkie::Api::Resources::PaymentRequest) payment_request = resource.first - expect(payment_request.payment_request_token).to eq("qzdnzr8hnVWTgXXcFRLUMc") + expect(payment_request.payment_request_token).to eq('qzdnzr8hnVWTgXXcFRLUMc') end end diff --git a/spec/tikkie/api/resources/payment_spec.rb b/spec/tikkie/api/resources/payment_spec.rb index 4765530..eae50b8 100644 --- a/spec/tikkie/api/resources/payment_spec.rb +++ b/spec/tikkie/api/resources/payment_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Resources::Payment do subject(:resource) { described_class.new(config, body: body) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } - let(:body) { JSON.parse(File.read("spec/fixtures/responses/payments/get.json"), symbolize_names: true) } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } + let(:body) { JSON.parse(File.read('spec/fixtures/responses/payments/get.json'), symbolize_names: true) } describe '#payment_request_token' do it 'returns the payment request token' do @@ -16,37 +16,37 @@ describe '#payment_token' do it 'returns the payment token' do - expect(resource.payment_token).to eq("21ef7413-cc3c-4c80-9272-6710fada28e4") + expect(resource.payment_token).to eq('21ef7413-cc3c-4c80-9272-6710fada28e4') end end describe '#tikkie_id' do it 'returns the tikkie ID' do - expect(resource.tikkie_id).to eq("000012345678") + expect(resource.tikkie_id).to eq('000012345678') end end describe '#counter_party_name' do it 'returns the counter party name' do - expect(resource.counter_party_name).to eq("E. Xample") + expect(resource.counter_party_name).to eq('E. Xample') end end describe '#counter_party_account_number' do it 'returns the counter party acccount number' do - expect(resource.counter_party_account_number).to eq("NL01ABNA1234567890") + expect(resource.counter_party_account_number).to eq('NL01ABNA1234567890') end end describe '#amount' do it 'returns the amount' do - expect(resource.amount).to eq(BigDecimal("15")) + expect(resource.amount).to eq(BigDecimal('15')) end end describe '#description' do it 'returns the description' do - expect(resource.description).to eq("Invoice 1815") + expect(resource.description).to eq('Invoice 1815') end end diff --git a/spec/tikkie/api/resources/payments_spec.rb b/spec/tikkie/api/resources/payments_spec.rb index ecc6f42..9a8847e 100644 --- a/spec/tikkie/api/resources/payments_spec.rb +++ b/spec/tikkie/api/resources/payments_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Resources::Payments do subject(:resource) { described_class.new(config, body: data) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } - let(:data) { JSON.parse(File.read("spec/fixtures/responses/payments/list.json"), symbolize_names: true) } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } + let(:data) { JSON.parse(File.read('spec/fixtures/responses/payments/list.json'), symbolize_names: true) } describe 'enumerable' do it 'returns the payment requests' do @@ -14,7 +14,7 @@ expect(resource.first).to be_a(Tikkie::Api::Resources::Payment) payment = resource.first - expect(payment.payment_token).to eq("21ef7413-cc3c-4c80-9272-6710fada28e4") + expect(payment.payment_token).to eq('21ef7413-cc3c-4c80-9272-6710fada28e4') end end diff --git a/spec/tikkie/api/resources/refund_spec.rb b/spec/tikkie/api/resources/refund_spec.rb index 590deb1..1b9a8d1 100644 --- a/spec/tikkie/api/resources/refund_spec.rb +++ b/spec/tikkie/api/resources/refund_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Resources::Refund do subject(:resource) { described_class.new(config, body: body) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } - let(:body) { JSON.parse(File.read("spec/fixtures/responses/refunds/get.json"), symbolize_names: true) } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } + let(:body) { JSON.parse(File.read('spec/fixtures/responses/refunds/get.json'), symbolize_names: true) } describe '#payment_request_token' do it 'returns the payment request token' do @@ -22,25 +22,25 @@ describe '#refund_token' do it 'returns the refund token' do - expect(resource.refund_token).to eq("abcdzr8hnVWTgXXcFRLUMc") + expect(resource.refund_token).to eq('abcdzr8hnVWTgXXcFRLUMc') end end describe '#amount' do it 'returns the amount' do - expect(resource.amount).to eq(BigDecimal("10")) + expect(resource.amount).to eq(BigDecimal('10')) end end describe '#description' do it 'returns the description' do - expect(resource.description).to eq("Refunded 10.00 for broken product.") + expect(resource.description).to eq('Refunded 10.00 for broken product.') end end describe '#reference_id' do it 'returns the reference ID' do - expect(resource.reference_id).to eq("inv_1815_ref_1") + expect(resource.reference_id).to eq('inv_1815_ref_1') end end diff --git a/spec/tikkie/api/resources/sandbox_app_spec.rb b/spec/tikkie/api/resources/sandbox_app_spec.rb index f108455..93a92b2 100644 --- a/spec/tikkie/api/resources/sandbox_app_spec.rb +++ b/spec/tikkie/api/resources/sandbox_app_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Api::Resources::SandboxApp do subject(:resource) { described_class.new(config, body: body) } - let(:config) { Tikkie::Api::Configuration.new(api_key: "12345", app_token: "abcdef") } - let(:body) { JSON.parse(File.read("spec/fixtures/responses/sandbox_apps/create.json"), symbolize_names: true) } + let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') } + let(:body) { JSON.parse(File.read('spec/fixtures/responses/sandbox_apps/create.json'), symbolize_names: true) } describe '#app_token' do it 'returns the app token' do - expect(resource.app_token).to eq("935059a6-58b3-4f8d-a021-7bdda0d8d6ad") + expect(resource.app_token).to eq('935059a6-58b3-4f8d-a021-7bdda0d8d6ad') end end end diff --git a/spec/tikkie/notification_spec.rb b/spec/tikkie/notification_spec.rb index f6f4f85..2652aee 100644 --- a/spec/tikkie/notification_spec.rb +++ b/spec/tikkie/notification_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Notification do context 'with a bundle notification' do - let(:body) { File.read("spec/fixtures/notifications/bundle.json") } + let(:body) { File.read('spec/fixtures/notifications/bundle.json') } describe '.parse' do it 'returns a bundle notification' do @@ -15,7 +15,7 @@ end context 'with a payment notification' do - let(:body) { File.read("spec/fixtures/notifications/payment.json") } + let(:body) { File.read('spec/fixtures/notifications/payment.json') } describe '.parse' do it 'returns a payment notification' do @@ -26,7 +26,7 @@ end context 'with a refund notification' do - let(:body) { File.read("spec/fixtures/notifications/refund.json") } + let(:body) { File.read('spec/fixtures/notifications/refund.json') } describe '.parse' do it 'returns a refund notification' do @@ -59,7 +59,7 @@ end context 'with an invalid payload' do - let(:body) { "invalid" } + let(:body) { 'invalid' } describe '.parse' do it 'ignores the notification and returns nil' do diff --git a/spec/tikkie/notifications/bundle_notification_spec.rb b/spec/tikkie/notifications/bundle_notification_spec.rb index 1776862..a35855e 100644 --- a/spec/tikkie/notifications/bundle_notification_spec.rb +++ b/spec/tikkie/notifications/bundle_notification_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Notifications::BundleNotification do subject(:notification) { described_class.new(body) } - let(:body) { JSON.parse(File.read("spec/fixtures/notifications/bundle.json"), symbolize_names: true) } + let(:body) { JSON.parse(File.read('spec/fixtures/notifications/bundle.json'), symbolize_names: true) } describe '#subscription_id' do it 'returns the subscription ID' do diff --git a/spec/tikkie/notifications/payment_notification_spec.rb b/spec/tikkie/notifications/payment_notification_spec.rb index a2d89a2..4ffb0c8 100644 --- a/spec/tikkie/notifications/payment_notification_spec.rb +++ b/spec/tikkie/notifications/payment_notification_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Notifications::PaymentNotification do subject(:notification) { described_class.new(body) } - let(:body) { JSON.parse(File.read("spec/fixtures/notifications/payment.json"), symbolize_names: true) } + let(:body) { JSON.parse(File.read('spec/fixtures/notifications/payment.json'), symbolize_names: true) } describe '#subscription_id' do it 'returns the subscription ID' do diff --git a/spec/tikkie/notifications/refund_notification_spec.rb b/spec/tikkie/notifications/refund_notification_spec.rb index 8142265..edbc028 100644 --- a/spec/tikkie/notifications/refund_notification_spec.rb +++ b/spec/tikkie/notifications/refund_notification_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe Tikkie::Notifications::RefundNotification do subject(:notification) { described_class.new(body) } - let(:body) { JSON.parse(File.read("spec/fixtures/notifications/refund.json"), symbolize_names: true) } + let(:body) { JSON.parse(File.read('spec/fixtures/notifications/refund.json'), symbolize_names: true) } describe '#subscription_id' do it 'returns the subscription ID' do diff --git a/tikkie-api.gemspec b/tikkie-api.gemspec index 5e278e2..b5bae1d 100644 --- a/tikkie-api.gemspec +++ b/tikkie-api.gemspec @@ -2,31 +2,31 @@ lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "tikkie/api/version" +require 'tikkie/api/version' Gem::Specification.new do |spec| - spec.name = "tikkie-api" + spec.name = 'tikkie-api' spec.version = Tikkie::Api::VERSION - spec.authors = ["Kentaa BV"] - spec.email = ["support@kentaa.nl"] + spec.authors = ['Kentaa BV'] + spec.email = ['support@kentaa.nl'] - spec.summary = "Ruby library for communicating with the Tikkie API" - spec.homepage = "https://github.com/KentaaNL/tikkie-api" - spec.license = "MIT" + spec.summary = 'Ruby library for communicating with the Tikkie API' + spec.homepage = 'https://github.com/KentaaNL/tikkie-api' + spec.license = 'MIT' spec.files = `git ls-files -z`.split("\x0").reject do |f| f.match(%r{^(test|spec|features)/}) end - spec.bindir = "exe" + spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.required_ruby_version = ">= 2.4.0" + spec.required_ruby_version = '>= 2.4.0' - spec.add_development_dependency "bundler", "~> 2.0" - spec.add_development_dependency "jwt", ">= 1.0" - spec.add_development_dependency "rake", "~> 13.0" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "timecop", "~> 0.9" - spec.add_development_dependency "webmock", "~> 3.18" + spec.add_development_dependency 'bundler', '~> 2.0' + spec.add_development_dependency 'jwt', '>= 1.0' + spec.add_development_dependency 'rake', '~> 13.0' + spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_development_dependency 'timecop', '~> 0.9' + spec.add_development_dependency 'webmock', '~> 3.18' end