Sha256: 9e938f1df6182ffd08c1d465e6684783d2fcbee46c301dbbca23ac81b18f9dea

Contents?: true

Size: 740 Bytes

Versions: 1

Compression:

Stored size: 740 Bytes

Contents

module Chargify
  class Product < Base
    def self.find_by_handle(handle)
      Product.new get(:lookup, :handle => handle)
    end
    
    protected

    # Products are created in the scope of a ProductFamily, i.e. /product_families/nnn/products
    #
    # This alters the collection path such that it uses the product_family_id that is set on the
    # attributes.
    def create
      pfid = begin
        self.product_family_id
      rescue NoMethodError
        0
      end
      connection.post("/product_families/#{pfid}/products.#{self.class.format.extension}", encode, self.class.headers).tap do |response|
        self.id = id_from_response(response)
        load_attributes_from_response(response)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chargify_api_ares-0.5.0 lib/chargify_api_ares/resources/product.rb