Sha256: 030c44fb5b2312795e36cabe7699fbb0faea01bc6d966a62bf2b6eb9d93d9d06

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module Conekta
  class Subscription < APIResource
    include Conekta::APIOperations::Update
    include Conekta::APIOperations::ModifyMember

    attr_accessor :customer
    
    def customer
      @customer
    end

    def customer=(customer)
      @customer = customer
    end

    def cancel
      self.modify_member("subscription", "cancel")
    end

    def pause
      subscription = self.modify_member("subscription", "pause")
    end

    def resume
      subscription = self.modify_member("subscription", "resume")
    end

    def url
      unless customer = self.customer
        raise ParameterValidationError.new("Could not determine which URL to request: #{self.class} instance has invalid customer: #{customer.inspect}", 'customer')
      end
      "#{Conekta::Customer.url}/#{CGI.escape(customer.id)}/subscription"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conekta-0.3.3 lib/conekta/subscription.rb