Sha256: d61e2748893f9f0e9fcf4a4a6296ccbaf8d8e246fbb9624bb14643fae02f0a47

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hookercookerman-amee-0.0.2 lib/amee/profile_api/profile.rb
hookercookerman-amee-0.0.3 lib/amee/profile_api/profile.rb