Sha256: e4d100e62d17ed167df647e4a057c053741c1ebe8e48c2423f099b81d911654f

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

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

module Razorpay
  # Product API allows you to enable sub-merchants request for a product.
  class Product < Entity

    @@versions = "v2"

    def self.request
      Razorpay::Request.new('accounts')
    end

    def self.request_product_configuration(account_id, options)
      if(!options.is_a?(String) && options.key?(:tnc_accepted))
        options[:tnc_accepted] = (options[:tnc_accepted] ? 1 : 0)
      end
      request.post "#{account_id}/products", options, @@versions
    end

    def self.fetch(account_id, id)
      request.fetch "#{account_id}/products/#{id}", @@versions
    end 

    def self.edit(account_id, id, options = {})
      if(!options.is_a?(String) && options.key?(:tnc_accepted))
        options[:tnc_accepted] = (options[:tnc_accepted] ? 1 : 0)
      end
      request.patch "#{account_id}/products/#{id}", options, @@versions
    end

    def self.fetch_tnc(productName)
      r = request
      r.request :get, "/#{@@versions}/products/#{productName}/tnc", {}
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
razorpay-3.2.2 lib/razorpay/product.rb
razorpay-3.2.1 lib/razorpay/product.rb
razorpay-3.2.0 lib/razorpay/product.rb
razorpay-3.1.0 lib/razorpay/product.rb