Sha256: f5d919fd5bd5c68d8ccbd2d170ce541eb4409921349affb902203a53b7214f2f

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require "amee/profile_api/profile_item"
require "amee/data_api/data_category"
module Amee
  module ProfileApi
    class ProfileCategory
      include ::Amee::Model
      self.path_prefix = "/profiles"
      
      
      attr_accessor :profile, :total_amount_per_month, :total_amount
      
      list_populators :profile_items => {:class => Amee::ProfileApi::ProfileItem},
                      :profile_categories => {:class => Amee::ProfileApi::ProfileCategory}
                      
      item_populators :data_category => {:class => Amee::DataApi::DataCategory}
              
      def populate!
        session.api_call(:get, "profile.category", self.full_path) do |response|
          populate_from_hash!(response)
        end
      end
      
      def profile_uid
        profile["uid"]
      end
      
      def total_co2_unit
        total_amount["unit"]
      end
      
      def total_co2_value
        total_amount["value"]
      end
      
      def full_path
        "#{self.class.path_prefix}/#{profile_uid}" + resource_path
      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_category.rb
hookercookerman-amee-0.0.3 lib/amee/profile_api/profile_category.rb