From c301251e836f67418406a77252afb1053dd14237 Mon Sep 17 00:00:00 2001 From: Hector Carrillo Date: Sat, 31 Jan 2026 00:06:29 -0300 Subject: [PATCH 1/3] solidgate ci included --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..717c809 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + pull_request: + branches: [master, main] + push: + branches: [master, main] + +jobs: + test: + name: Ruby Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + bundler-cache: true # Caches gems for faster builds + + - name: Install dependencies + run: bundle install --jobs 4 --retry 3 + + - name: Run RSpec tests + run: bundle exec rspec --format documentation --color + + lint: + name: RuboCop Lint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + + - name: Install dependencies + run: bundle install --jobs 4 --retry 3 + + - name: Run RuboCop + run: bundle exec rubocop --parallel + continue-on-error: true # Don't fail the build on lint warnings From 66ded2a94ce09de4cf39a1f10b0ba1206e5284ba Mon Sep 17 00:00:00 2001 From: Hector Carrillo Date: Tue, 3 Feb 2026 18:04:15 -0300 Subject: [PATCH 2/3] Add restore_subscription documentation, README update, and tests - bump to v0.1.9 --- CHANGELOG.md | 5 +++++ README.md | 5 +++++ lib/solidgate/client.rb | 18 ++++++++++++++++++ lib/solidgate/version.rb | 2 +- spec/solidgate/client_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f53c87..233848a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.9] - 2026-02-03 +- Added documentation for restore_subscription method +- Added restore_subscription to README.md usage examples +- Added tests for restore_subscription method + ## [0.1.4] - 2026-01-14 - Client Specs enhancements diff --git a/README.md b/README.md index 93c2e2a..3c5f548 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,11 @@ client.cancel_subscription( cancel_at_period_end: true, reason: 'Customer requested cancellation' ) + +# Restore a cancelled subscription +client.restore_subscription( + subscription_id: 'sub_123' +) ``` ### Subscription Pause Scheduling diff --git a/lib/solidgate/client.rb b/lib/solidgate/client.rb index ded6b1d..468c33f 100644 --- a/lib/solidgate/client.rb +++ b/lib/solidgate/client.rb @@ -307,6 +307,24 @@ def generate_signature(json_string, public_key: config.public_key, private_key: Base64.strict_encode64(instance.hexdigest) end + # Restores a previously cancelled subscription. + # Use this to reactivate a subscription that was cancelled but is still within + # the restoration period. + # + # @param params [Hash] restoration parameters: + # - :subscription_id [String] the subscription identifier to restore + # @return [Hash] restored subscription details including: + # - :id [String] subscription identifier + # - :status [String] new subscription status (typically 'active') + # @raise [InvalidRequestError] if subscription cannot be restored (expired, already active, etc.) + # + # @example Restore a cancelled subscription + # client.restore_subscription(subscription_id: 'sub_12345') + # + def restore_subscription(params) + post("/api/v1/subscription/restore", params) + end + private # Builds a Configuration object from the provided options. diff --git a/lib/solidgate/version.rb b/lib/solidgate/version.rb index 86313b3..f826a80 100644 --- a/lib/solidgate/version.rb +++ b/lib/solidgate/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Solidgate - VERSION = "0.1.8" + VERSION = "0.1.9" end diff --git a/spec/solidgate/client_spec.rb b/spec/solidgate/client_spec.rb index fa6e4cf..058b988 100644 --- a/spec/solidgate/client_spec.rb +++ b/spec/solidgate/client_spec.rb @@ -329,6 +329,40 @@ end end + describe "#restore_subscription" do + let(:restore_params) do + { + subscription_id: "sub_123" + } + end + + it "sends POST request to /api/v1/subscription/restore" do + client.restore_subscription(restore_params) + + expect(WebMock).to have_requested(:post, "https://subscriptions.solidgate.com/api/v1/subscription/restore") + .with(body: restore_params.to_json) + end + + it "includes Merchant header with public key" do + client.restore_subscription(restore_params) + + expect(WebMock).to have_requested(:post, "https://subscriptions.solidgate.com/api/v1/subscription/restore") + .with(headers: { "Merchant" => public_key }) + end + + it "includes Signature header" do + client.restore_subscription(restore_params) + + expect(WebMock).to have_requested(:post, "https://subscriptions.solidgate.com/api/v1/subscription/restore") + .with { |req| !req.headers["Signature"].nil? && !req.headers["Signature"].empty? } + end + + it "returns restored subscription response" do + result = client.restore_subscription(restore_params) + expect(result).to eq(success_response) + end + end + # ==================== Product Methods ==================== describe "#create_product" do From 2bd62382c9a40fc7c0adde86dc2f7e7651b7b0cc Mon Sep 17 00:00:00 2001 From: Hector Carrillo Date: Tue, 3 Feb 2026 18:04:55 -0300 Subject: [PATCH 3/3] Update Gemfile.lock for v0.1.9 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7529df8..543e5c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - solidgate-ruby-sdk (0.1.8) + solidgate-ruby-sdk (0.1.9) faraday faraday-multipart