Sha256: 6494574a01684b5e640ef4e2eafbc328039d6edaed1da3777f2bc0b07f57be38

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module Billimatic
  module Resources
    class Subscription < Base
      crud :create

      def show(token:)
        http.get("#{resource_base_path}/token/#{token}") do |response|
          respond_with_entity(response)
        end
      end

      def checkout(params, token:)
        http.post(
          "#{resource_base_path}/checkout/#{token}", body: { subscription: params }
        ) do |response|
          respond_with_entity response
        end
      end

      def change_plan(token:, new_plan_id:)
        http.patch(
          "#{resource_base_path}/#{token}/change_plan",
          body: { subscription: { new_plan_id: new_plan_id } }
        ) do |response|
          respond_with_entity response
        end
      end

      def update_payment_information(params, token:)
        http.patch(
          "#{resource_base_path}/#{token}/update_payment_information",
          body: { subscription: params }
        ) do |response|
          respond_with_entity response
        end
      end

      def cancel(token:)
        http.patch("#{resource_base_path}/#{token}/cancel") do |response|
          respond_with_entity response
        end
      end

      def checkout_url(token:)
        "#{Billimatic.configuration.host}#{resource_base_path}/checkout/#{token}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
billimatic-client-0.10.1 lib/billimatic/resources/subscription.rb
billimatic-client-0.10.0 lib/billimatic/resources/subscription.rb