Sha256: 50cedaea0eac520b315779919eb740a9b00fcdee8fef2f64a538bd00eff8c75f

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

module Charger

  class Product
    include Resource

    attribute :id, Integer
    attribute :price_in_cents, Integer
    attribute :name, String
    attribute :handle, String
    attribute :description, String
    attribute :product_family, ProductFamily
    attribute :accounting_code, String
    attribute :interval_unit, String
    attribute :interval, Integer
    attribute :initial_charge_in_cents, Integer
    attribute :trial_price_in_cents, Integer
    attribute :trial_interval, Integer
    attribute :trial_interval_unit, String
    attribute :expiration_interval, Integer
    attribute :expiration_interval_unit, String
    attribute :return_url, String
    attribute :return_params, String
    attribute :required_credit_card, Boolean
    attribute :request_credit_card, Boolean
    attribute :created_at, DateTime
    attribute :updated_at, DateTime
    attribute :archived_at, DateTime

    def self.find_by_product_family_id id
      products = []
      client.get("product_families/#{id}/products") do |data|
        products << new(data['product'])
      end
      products
    end

    def persisted?
      !!id
    end

    def self.client
      Charger.client
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
charger-0.2.0 lib/charger/product.rb
charger-0.1.1 lib/charger/product.rb
charger-0.1.0 lib/charger/product.rb
charger-0.0.3 lib/charger/product.rb