Sha256: 509b5e9875a1c193e0f9fe1f797d358a261c75b774b16062a269272f5ae6149a

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

require 'razorpay/request'
require 'razorpay/entity'

module Razorpay
  # Subscription API allows you to create and
  # manage subscriptions with Razorpay
  class Subscription < Entity
    def self.request
      Razorpay::Request.new('subscriptions')
    end

    def self.create(options)
      request.create options
    end

    def self.fetch(id)
      request.fetch id
    end

    def self.all(options = {})
      request.all options
    end

    def self.cancel(id, options = {})
      request.post "#{id}/cancel", options
    end

    def cancel(options = {})
      self.class.cancel id, options
    end

    def cancel!(options = {})
      with_a_bang { cancel options }
    end

    def edit(options = {})
      self.class.request.patch id, options
    end

    def pending_update
      self.class.request.get "#{id}/retrieve_scheduled_changes"
    end

    def self.cancel_scheduled_changes(id)
      request.post "#{id}/cancel_scheduled_changes"
    end

    def self.pause(id, options = {})
      request.post "#{id}/pause", options
    end

    def self.resume(id, options = {})
      request.post "#{id}/resume", options
    end

    def self.delete_offer(id, offerId)
      request.delete "#{id}/#{offerId}"
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
razorpay-3.2.2 lib/razorpay/subscription.rb
razorpay-3.2.1 lib/razorpay/subscription.rb
razorpay-3.2.0 lib/razorpay/subscription.rb
razorpay-3.1.0 lib/razorpay/subscription.rb
razorpay-3.0.1 lib/razorpay/subscription.rb
razorruby-3.0.4 lib/razorpay/subscription.rb
razorruby-3.0.1 lib/razorpay/subscription.rb
razorpay-3.0.0 lib/razorpay/subscription.rb