diff --git a/CHANGELOG.md b/CHANGELOG.md index 647266f..bfa6a99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,22 @@ +## [1.0.0] - 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..863fd18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - monopay-ruby (0.1.1) + monopay-ruby (1.0.0) 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..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 = "0.1.1" + VERSION = "1.0.0" end diff --git a/spec/lib/invoices/simple_invoice_spec.rb b/spec/lib/invoices/simple_invoice_spec.rb index 5d5c6fe..676c5e4 100644 --- a/spec/lib/invoices/simple_invoice_spec.rb +++ b/spec/lib/invoices/simple_invoice_spec.rb @@ -1,6 +1,37 @@ # 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 + + context "without parameters" do + subject { described_class.new } + + it { is_expected.to be_a(described_class) } + end + end + describe "#create" do context "when request is successful" do let(:simple_invoice_instance) { described_class.new }