From 787f5cda1951e98010c502e70d4d40328c99eb82 Mon Sep 17 00:00:00 2001 From: popovycj Date: Tue, 27 Jun 2023 00:50:59 +0300 Subject: [PATCH 1/6] refactor: use keyword params instead named ones --- CHANGELOG.md | 14 ++++++++++++-- Gemfile.lock | 2 +- lib/monopay-ruby/invoices/simple_invoice.rb | 2 +- lib/monopay-ruby/version.rb | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 647266f..1b805f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,18 @@ +## [1.1.1] - 2023-06-27 + +### Changed + +- **Breaking Change**: Updated method signatures in the gem to use keyword arguments instead of named arguments. + +- Specifically, `MonopayRuby::Invoices::SimpleInvoice::new` method was affected by this change. +- Previously, the method was called like `new("redirect/url", "webhook/url")`. Now, it should be called like `new(redirect_url: "redirect/url", webhook_url: "webhook/url")`. +- Note: This is a breaking change and will require updating your code if you are updating to this version of the gem from an earlier version. + ## [0.1.1] - 2023-06-19 - Fix typo in a `README.md` file -- add ability to pass reference to an invoice by `reference` parameter in a `MonopayRuby::Invoices::SimpleInvoice::create` method -- Use named parameter of `destionation` for "MonopayRuby::Invoices::SimpleInvoice::create" method +- Add ability to pass reference to an invoice by `reference` parameter in a `MonopayRuby::Invoices::SimpleInvoice::create` method +- Use keyword parameter of `destination` for "MonopayRuby::Invoices::SimpleInvoice::create" method ## [0.1.0] - 2023-06-18 diff --git a/Gemfile.lock b/Gemfile.lock index c95ea4c..b24a2fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - monopay-ruby (0.1.1) + monopay-ruby (1.1.1) base64 (~> 0.1.1) json (~> 2.5) money (~> 6.13) diff --git a/lib/monopay-ruby/invoices/simple_invoice.rb b/lib/monopay-ruby/invoices/simple_invoice.rb index c8fa0c6..9d6cf8a 100644 --- a/lib/monopay-ruby/invoices/simple_invoice.rb +++ b/lib/monopay-ruby/invoices/simple_invoice.rb @@ -17,7 +17,7 @@ class SimpleInvoice < MonopayRuby::Base # # @param [String] redirect_url - url where user will be redirected after payment # @param [String] webhook_url - url where Monobank will send webhook after payment - def initialize(redirect_url = nil, webhook_url = nil) + def initialize(redirect_url: nil, webhook_url: nil) @redirect_url = redirect_url @webhook_url = webhook_url diff --git a/lib/monopay-ruby/version.rb b/lib/monopay-ruby/version.rb index c8194d3..6c88940 100644 --- a/lib/monopay-ruby/version.rb +++ b/lib/monopay-ruby/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module MonopayRuby - VERSION = "0.1.1" + VERSION = "1.1.1" end From 1445906818883d9a2f8816280e6c439b2b05cdba Mon Sep 17 00:00:00 2001 From: popovycj Date: Thu, 29 Jun 2023 18:19:41 +0300 Subject: [PATCH 2/6] docs: fix current version --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/monopay-ruby/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b805f6..b1b4fd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.1.1] - 2023-06-27 +## [1.0.0] - 2023-06-27 ### Changed diff --git a/Gemfile.lock b/Gemfile.lock index b24a2fc..863fd18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - monopay-ruby (1.1.1) + monopay-ruby (1.0.0) base64 (~> 0.1.1) json (~> 2.5) money (~> 6.13) diff --git a/lib/monopay-ruby/version.rb b/lib/monopay-ruby/version.rb index 6c88940..e55885d 100644 --- a/lib/monopay-ruby/version.rb +++ b/lib/monopay-ruby/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module MonopayRuby - VERSION = "1.1.1" + VERSION = "1.0.0" end From cfa3b2bee586d5bb7ca44ea39bedbbd1f7cdcdf6 Mon Sep 17 00:00:00 2001 From: popovycj Date: Mon, 3 Jul 2023 00:04:53 +0300 Subject: [PATCH 3/6] test: provide tests for SimpleInvoice new method --- spec/lib/invoices/simple_invoice_spec.rb | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/lib/invoices/simple_invoice_spec.rb b/spec/lib/invoices/simple_invoice_spec.rb index 5d5c6fe..3cd7624 100644 --- a/spec/lib/invoices/simple_invoice_spec.rb +++ b/spec/lib/invoices/simple_invoice_spec.rb @@ -1,6 +1,31 @@ # frozen_string_literal: true RSpec.describe MonopayRuby::Invoices::SimpleInvoice do + describe "#new" do + let!(:redirect_url) { "https://redirect.example.com" } + let!(:webhook_url) { "https://webhook.example.com" } + + context "with keyword parameters" do + subject { described_class.new(redirect_url: redirect_url, webhook_url: webhook_url) } + + it "initializes with correct redirect_url" do + expect(subject.redirect_url).to eq(redirect_url) + end + + it "initializes with correct webhook_url" do + expect(subject.webhook_url).to eq(webhook_url) + end + end + + context "without keyword parameters" do + subject { described_class.new(redirect_url, webhook_url) } + + it "raises an ArgumentError" do + expect { subject }.to raise_error(ArgumentError) + end + end + end + describe "#create" do context "when request is successful" do let(:simple_invoice_instance) { described_class.new } From 9ff9a2ab3b5bba34b1719a297294232ae0232544 Mon Sep 17 00:00:00 2001 From: popovycj Date: Mon, 3 Jul 2023 00:17:07 +0300 Subject: [PATCH 4/6] test: add tests for SimpleInvoice.new without params --- spec/lib/invoices/simple_invoice_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/lib/invoices/simple_invoice_spec.rb b/spec/lib/invoices/simple_invoice_spec.rb index 3cd7624..3be830c 100644 --- a/spec/lib/invoices/simple_invoice_spec.rb +++ b/spec/lib/invoices/simple_invoice_spec.rb @@ -24,6 +24,18 @@ expect { subject }.to raise_error(ArgumentError) end end + + context "without parameters" do + subject { described_class.new } + + it "initializes with nil redirect_url" do + expect(subject.redirect_url).to be_nil + end + + it "initializes with nil webhook_url" do + expect(subject.webhook_url).to be_nil + end + end end describe "#create" do From bfd72abf509260c1283d42cac0c6812b74ae83e9 Mon Sep 17 00:00:00 2001 From: loqimean Date: Sat, 22 Jul 2023 08:53:14 +0300 Subject: [PATCH 5/6] chore: use simpler spec --- spec/lib/invoices/simple_invoice_spec.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spec/lib/invoices/simple_invoice_spec.rb b/spec/lib/invoices/simple_invoice_spec.rb index 3be830c..676c5e4 100644 --- a/spec/lib/invoices/simple_invoice_spec.rb +++ b/spec/lib/invoices/simple_invoice_spec.rb @@ -28,13 +28,7 @@ context "without parameters" do subject { described_class.new } - it "initializes with nil redirect_url" do - expect(subject.redirect_url).to be_nil - end - - it "initializes with nil webhook_url" do - expect(subject.webhook_url).to be_nil - end + it { is_expected.to be_a(described_class) } end end From 8438d8068bee745384ff85556576eb62ae404cf1 Mon Sep 17 00:00:00 2001 From: loqimean Date: Sat, 22 Jul 2023 08:55:54 +0300 Subject: [PATCH 6/6] chore: update changelog --- CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1b4fd6..bfa6a99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,15 @@ ### Changed -- **Breaking Change**: Updated method signatures in the gem to use keyword arguments instead of named arguments. +### Breaking Change +Updated method signatures in the gem to use keyword arguments instead of named arguments. -- Specifically, `MonopayRuby::Invoices::SimpleInvoice::new` method was affected by this change. -- Previously, the method was called like `new("redirect/url", "webhook/url")`. Now, it should be called like `new(redirect_url: "redirect/url", webhook_url: "webhook/url")`. -- Note: This is a breaking change and will require updating your code if you are updating to this version of the gem from an earlier version. +###### Specifically +`MonopayRuby::Invoices::SimpleInvoice::new` method was affected by this change. +###### Previously +the method was called like `new("redirect/url", "webhook/url")`. Now, it should be called like `new(redirect_url: "redirect/url", webhook_url: "webhook/url")`. +#### Note +This is a breaking change and will require updating your code if you are updating to this version of the gem from an earlier version. ## [0.1.1] - 2023-06-19