lib/intercom/user.rb in intercom-0.0.12 vs lib/intercom/user.rb in intercom-0.1.1

- old
+ new

@@ -1,7 +1,7 @@ require 'intercom/user_resource' -require 'intercom/user_custom_data' +require 'intercom/flat_store' require 'intercom/user_collection_proxy' require 'intercom/social_profile' module Intercom # Represents a user of your application on Intercom. @@ -220,20 +220,43 @@ # Example: Setting some custom data for an existing user # user = Intercom::User.find(:email => "someone@example.com") # user.custom_data[:plan] = "pro" # user.save # - # @return [UserCustomData] + # @return [FlatStore] def custom_data - @attributes["custom_data"] ||= UserCustomData.new + @attributes["custom_data"] ||= FlatStore.new end # Set a {Hash} of custom data attributes to save/update on this user # # @param [Hash] custom_data - # @return [UserCustomData] + # @return [FlatStore] def custom_data=(custom_data) - @attributes["custom_data"] = UserCustomData.new(custom_data) + @attributes["custom_data"] = FlatStore.new(custom_data) + end + + # Custom attributes stored for this Intercom::User + # + # See http://docs.intercom.io/#Companies for more information + # + # Example: Setting a company for an existing user + # user = Intercom::User.find(:email => "someone@example.com") + # user.company[:id] = 6 + # user.company[:name] = "Intercom" + # user.save + # + # @return [FlatStore] + def company + @attributes["company"] ||= FlatStore.new + end + + # Set a {Hash} of company attributes to save/update on this user + # + # @param [Hash] company + # @return [FlatStore] + def company=(company) + @attributes["company"] = FlatStore.new(company) end protected def social_profiles=(social_profiles) #:nodoc: @social_profiles = social_profiles.map { |account| SocialProfile.new(account) }.freeze