Sha256: c947ef04aaff3eddd658a1cba145b7040792e097cb821d57a41e69bf4ce995d8

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Nusii
  class LineItem < Resource
    extend Nusii::Crud::List
    extend Nusii::Crud::Destroy
    include Nusii::Crud::DestroySelf

    attr_accessor :id, :section_id, :name, :position, :cost_type,
                  :recurring_type, :per_type, :quantity, :currency,
                  :amount_in_cents, :amount_formatted, :total_in_cents,
                  :total_formatted, :updated_at, :created_at, :amount

    def self.list_by_section section_id, options={}
      requester = Nusii::Request.new
      requester.nested_index_call self, section_id, Nusii::Section, options
    end

    def self.create_with_section section_id, params
      requester = Nusii::Request.new
      requester.nested_create_call self, section_id, Nusii::Section, params
    end

    def save
      raise(ArgumentError, 'You can\'t update a line item without id') if self.id.blank?

      requester = Nusii::Request.new
      requester.update_call self.class, self
    end

  private

    def editable_attributes
      [ :name, :cost_type, :recurring_type, :per_type,
        :position, :quantity, :amount ]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nusii-0.1.1 lib/nusii/line_item.rb