Sha256: 1a77030200cbfb4108504406407d9029b49a122442fbb89e67f71d47cb527e9b

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 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 = 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((full_path + path), options)
      end
      
      def get_profile_category(path, options = {})
        session.get_profile_category((full_path + path), options)
      end
      
      def update_profile_item(path, fields)
        session.update_profile_item((full_path + 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

7 entries across 7 versions & 1 rubygems

Version Path
hookercookerman-amee-0.0.6 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.0.7 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.0.8 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.0.9 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.1.0 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.1.1 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.1.2 lib/amee/profile_api/profile.rb