Class: Intercom::UserResource
- Inherits:
-
Object
- Object
- Intercom::UserResource
- Extended by:
- RequiresParameters
- Includes:
- UnixTimestampUnwrapper
- Defined in:
- lib/intercom/user_resource.rb
Overview
Base class for resources tied off a User, all of which are scoped by either the users :email or :user_id.
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (String) email
Email address.
- - (String) email=(email)
-
- (UserResource) initialize(attributes = {})
constructor
A new instance of UserResource.
-
- (Hash) to_hash
Hash of all the attributes in the structure they will be sent to the api.
-
- (UserResource) update_from_api_response(api_response)
updates the internal state of this UserResource based on the response from the API.
-
- (String) user_id
User_id.
- - (String) user_id=(user_id)
Methods included from RequiresParameters
Methods included from UnixTimestampUnwrapper
Constructor Details
- (UserResource) initialize(attributes = {})
A new instance of UserResource
10 11 12 |
# File 'lib/intercom/user_resource.rb', line 10 def initialize(attributes={}) self.attributes = attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block) (private)
77 78 79 80 |
# File 'lib/intercom/user_resource.rb', line 77 def method_missing(method, *args, &block) return @attributes[method.to_s] if @attributes.has_key?(method.to_s) super end |
Instance Method Details
- (String) email
Email address
20 21 22 |
# File 'lib/intercom/user_resource.rb', line 20 def email @attributes["email"] end |
- (String) email=(email)
26 27 28 |
# File 'lib/intercom/user_resource.rb', line 26 def email=(email) @attributes["email"] = email end |
- (Hash) to_hash
Hash of all the attributes in the structure they will be sent to the api
15 16 17 |
# File 'lib/intercom/user_resource.rb', line 15 def to_hash UserResource.for_wire(@attributes) end |
- (UserResource) update_from_api_response(api_response)
updates the internal state of this Intercom::UserResource based on the response from the API
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/intercom/user_resource.rb', line 43 def update_from_api_response(api_response) api_response.each do |key, value| setter_method = "#{key.to_s}=" if self.respond_to?(setter_method) self.send(setter_method, value) else @attributes[key.to_s] = value end end self end |
- (String) user_id
User_id
31 32 33 |
# File 'lib/intercom/user_resource.rb', line 31 def user_id @attributes["user_id"] end |
- (String) user_id=(user_id)
37 38 39 |
# File 'lib/intercom/user_resource.rb', line 37 def user_id=(user_id) @attributes["user_id"] = user_id end |