Sha256: 8c79f86b76f6c37fea5c2a91a80d1d634347bb79de93c6b987e0097a320c23bb

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require "amee/profile_api/profile_category"
require "amee/profile_api/profile_item"
module Amee
  module ProfileApi
    class Profile
      include ::Amee::Model
      self.path_prefix = "/profiles"
      
      attr_accessor :profile_date, :amount_per_month
      list_populators :profile_categories => {:class => Amee::ProfileApi::ProfileCategory}
      item_populators :data_category => {:class => Amee::ProfileApi::ProfileCategory}
         
      def self.create(session)
         self.from_hash(session.new_profile, session)
       end
      
      def create_profile_data_item(path_or_category, data_item_uid, params = {})
        path = self.full_path + path_or_category.is_a?(String) ? "/#{path_or_category}" : "/#{path_or_category.full_path}"
        Amee::ProfileApi::ProfileDataItem.create(session, path, data_item_uid, params)
      end
      
      def get_profile_item(path, options = {})
        session.get_profile_item(path, options)
      end
      
      def update_profile_item(path, fields)
        session.update_profile_item(full_path, :fields => fields)
      end
 
      def destroy
        session.delete_profile(self.uid)
      end
      
      def full_path
        "#{self.class.path_prefix}/#{self.uid}"
      end
      
      def lazy_loaded
        true
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hookercookerman-amee-0.0.4 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.0.5 lib/amee/profile_api/profile.rb