Skip to content

Commit f0d01c4

Browse files
committed
more yardoc'age
1 parent 06c7d8a commit f0d01c4

File tree

6 files changed

+49
-39
lines changed

6 files changed

+49
-39
lines changed

lib/intercom/impression.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module Intercom
77
#
88
# An impressions contains user_ip, user_agent and location.
99
#
10+
# == Examples
11+
#
1012
# impression = Intercom::Impression.create(:email => "person@example.com", :location => "/pricing/upgrade",
1113
# :user_ip => '1.2.3.4', :user_agent => "my-service-iphone-app-1.2")
1214
# The impression response will contain {#unread_messages}

lib/intercom/message_thread.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
module Intercom
44
# A conversation with a user. Either started by the users sending a message to your application using Intercom, or by an Admin sending a message to the user.
5+
# == Examples
6+
#
7+
# Fetching all {MessageThread}'s for a user
8+
# message_threads = Intercom::MessageThread.find_all(:email => "bob@example.com")
9+
# message_threads.size
10+
# message_thread = message_threads[0]
11+
#
12+
# Fetching a particular {MessageThread}
13+
# message_thread = Intercom::MessageThread.find(:email => "bob@example.com", :thread_id => 123)
14+
# message_thread.messages.map{|message| message.html }
15+
#
16+
# Creating a {MessageThread} on behalf of a user:
17+
# message_thread = Intercom::MessageThread.create(:email => "bob@example.com", :body => "Hello, I need some help....")
18+
#
519
class MessageThread < UserResource
620
include UnixTimestampUnwrapper
721

lib/intercom/social_profile.rb

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,24 @@
11
require 'intercom/user_resource'
22

33
module Intercom
4-
##
5-
# object representing a social profile for the User (see )http://docs.intercom.io/#SocialProfiles)
6-
class SocialProfile < UserResource
7-
def for_wire #:nodoc:
8-
@attributes
9-
end
10-
11-
def type
12-
@attributes["type"]
13-
end
14-
15-
def type=(type)
16-
@attributes["type"]=type
17-
end
18-
19-
def id
20-
@attributes["id"]
21-
end
22-
23-
def id=(id)
24-
@attributes["id"]=id
25-
end
26-
27-
def url
28-
@attributes["url"]
29-
end
30-
31-
def url=(url)
32-
@attributes["url"]=url
33-
end
34-
35-
def username
36-
@attributes["username"]
37-
end
38-
39-
def username=(username)
40-
@attributes["username"]=username
4+
# object representing a social profile for the User (see )http://docs.intercom.io/#SocialProfiles).
5+
# Read only part of the {User} object
6+
class SocialProfile
7+
# @return [String] type e.g. twitter, facebook etc.
8+
attr_reader :type
9+
# @return [String] id
10+
attr_reader :id
11+
# @return [String] url
12+
attr_reader :url
13+
# @return [String] username
14+
attr_reader :username
15+
16+
# @private
17+
def initialize(params)
18+
@type = params["type"]
19+
@id = params["id"]
20+
@url = params["url"]
21+
@username = params["username"]
4122
end
4223
end
4324
end

lib/intercom/unix_timestamp_unwrapper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module Intercom
2+
# Our api returns date as unix time stamps. This module helps marshall to and from {Time} objects.
23
module UnixTimestampUnwrapper
34
def time_at(attribute_name)
45
Time.at(@attributes[attribute_name]) if @attributes[attribute_name]

lib/intercom/user.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class User < UserResource
1313
#
1414
# returns Intercom::User object representing the state on our servers.
1515
#
16+
# @return [User]
1617
def self.find(params)
1718
response = Intercom.get("users", params)
1819
User.from_api(response)
@@ -26,17 +27,19 @@ def self.find(params)
2627
# returns Intercom::User object representing the state on our servers.
2728
#
2829
# This operation is idempotent.
30+
# @return [User]
2931
def self.create(params)
3032
User.new(params).save
3133
end
3234

33-
##
3435
# instance method alternative to #create
36+
# @return [User]
3537
def save
3638
response = Intercom.post("users", to_hash)
3739
self.update_from_api_response(response)
3840
end
3941

42+
# @return {User}
4043
def name
4144
@attributes["name"]
4245
end
@@ -45,6 +48,7 @@ def name=(name)
4548
@attributes["name"]=name
4649
end
4750

51+
# @return [String]
4852
def last_seen_ip
4953
@attributes["last_seen_ip"]
5054
end
@@ -53,6 +57,7 @@ def last_seen_ip=(last_seen_ip)
5357
@attributes["last_seen_ip"]=last_seen_ip
5458
end
5559

60+
# @return [String]
5661
def last_seen_user_agent
5762
@attributes["last_seen_user_agent"]
5863
end
@@ -61,22 +66,26 @@ def last_seen_user_agent=(last_seen_user_agent)
6166
@attributes["last_seen_user_agent"]=last_seen_user_agent
6267
end
6368

69+
# @return [Integer]
6470
def relationship_score
6571
@attributes["relationship_score"]
6672
end
6773

74+
# @return [Integer]
6875
def session_count
6976
@attributes["session_count"]
7077
end
7178

7279
##
7380
# Get last time this User interacted with your application
81+
# @return [Time]
7482
def last_impression_at
7583
time_at("last_impression_at")
7684
end
7785

7886
##
7987
# Get Time at which this User started using your application.
88+
# @return [Time]
8089
def created_at
8190
time_at("created_at")
8291
end
@@ -91,6 +100,7 @@ def created_at=(time)
91100
# Get array of Intercom::SocialProfile objects attached to this Intercom::User
92101
#
93102
# See http://docs.intercom.io/#SocialProfiles for more information
103+
# @return [Array<SocialProfile>]
94104
def social_profiles
95105
@social_profiles ||= [].freeze
96106
end
@@ -105,6 +115,7 @@ def social_profiles
105115
# {"city_name"=>"Santiago", "continent_code"=>"SA", "country_code"=>"CHL", "country_name"=>"Chile",
106116
# "latitude"=>-33.44999999999999, "longitude"=>-70.6667, "postal_code"=>"", "region_name"=>"12",
107117
# "timezone"=>"Chile/Continental"}
118+
# @return [Hash]
108119
def location_data
109120
@location_data ||= {}.freeze
110121
end
@@ -113,6 +124,7 @@ def location_data
113124
# Get hash of custom attributes stored for this Intercom::User
114125
#
115126
# See http://docs.intercom.io/#CustomData for more information
127+
# @return [Hash]
116128
def custom_data
117129
@attributes["custom_data"] ||= ShallowHash.new
118130
end

spec/unit/intercom/user_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
end
4646

4747
it "has read-only social accounts" do
48-
user = Intercom::User.new(:social_profiles => [:url => "http://twitter.com/abc", "username" => "abc", "type" => "twitter"])
48+
user = Intercom::User.new(:social_profiles => ["url" => "http://twitter.com/abc", "username" => "abc", "type" => "twitter"])
4949
user.social_profiles.size.must_equal 1
5050
twitter = user.social_profiles.first
5151
twitter.type.must_equal "twitter"

0 commit comments

Comments
 (0)