-
Notifications
You must be signed in to change notification settings - Fork 403
Expand file tree
/
Copy pathshare_and_social_stream.rb
More file actions
133 lines (124 loc) · 4.8 KB
/
share_and_social_stream.rb
File metadata and controls
133 lines (124 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
module LinkedIn
module Api
# Share and Social Stream APIs
#
# @see http://developer.linkedin.com/documents/share-and-social-stream
# @see http://developer.linkedin.com/documents/share-api Share API
#
# The following API actions do not have corresponding methods in
# this module
#
# * GET Network Statistics
# * POST Post Network Update
#
# [(contribute here)](https://github.com/hexgnu/linkedin)
module ShareAndSocialStream
# Retrieve the authenticated users network updates
#
# Permissions: rw_nus
#
# @see http://developer.linkedin.com/documents/get-network-updates-and-statistics-api
# @see http://developer.linkedin.com/documents/network-update-types Network Update Types
#
# @macro person_path_options
# @option options [String] :scope
# @option options [String] :type
# @option options [String] :count
# @option options [String] :start
# @option options [String] :after
# @option options [String] :before
# @option options [String] :show-hidden-members
# @return [LinkedIn::Mash]
def network_updates(options={})
path = "#{person_path(options)}/network/updates"
simple_query(path, options)
end
# TODO refactor to use #network_updates
def shares(options={})
path = "#{person_path(options)}/network/updates"
simple_query(path, {:type => "SHAR", :scope => "self"}.merge(options))
end
# Retrieve all comments for a particular network update
#
# @note The first 5 comments are included in the response to #network_updates
#
# Permissions: rw_nus
#
# @see http://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates
#
# @param [String] update_key a update/update-key representing a
# particular network update
# @macro person_path_options
# @return [LinkedIn::Mash]
def share_comments(update_key, options={})
path = "#{person_path(options)}/network/updates/key=#{update_key}/update-comments"
simple_query(path, options)
end
# Retrieve all likes for a particular network update
#
# @note Some likes are included in the response to #network_updates
#
# Permissions: rw_nus
#
# @see http://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates
#
# @param [String] update_key a update/update-key representing a
# particular network update
# @macro person_path_options
# @return [LinkedIn::Mash]
def share_likes(update_key, options={})
path = "#{person_path(options)}/network/updates/key=#{update_key}/likes"
simple_query(path, options)
end
# Create a share for the authenticated user
#
# Permissions: rw_nus
#
# @see http://developer.linkedin.com/documents/share-api
#
# @macro share_input_fields
# @return [void]
def add_share(share)
path = "people/~/shares"
defaults = {:visibility => {:code => "anyone"}}
post(path, MultiJson.dump(defaults.merge(share)), "Content-Type" => "application/json")
end
# Create a comment on an update from the authenticated user
#
# @see http://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates
#
# @param [String] update_key a update/update-key representing a
# particular network update
# @param [String] comment The text of the comment
# @return [void]
def update_comment(update_key, comment)
path = "people/~/network/updates/key=#{update_key}/update-comments"
body = {'comment' => comment}
post(path, MultiJson.dump(body), "Content-Type" => "application/json")
end
# (Update) like an update as the authenticated user
#
# @see http://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates
#
# @param [String] update_key a update/update-key representing a
# particular network update
# @return [void]
def like_share(update_key)
path = "people/~/network/updates/key=#{update_key}/is-liked"
put(path, 'true', "Content-Type" => "application/json")
end
# (Destroy) unlike an update the authenticated user previously
# liked
#
# @see http://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates
#
# @param [String] update_key a update/update-key representing a
# particular network update
# @return [void]
def unlike_share(update_key)
path = "people/~/network/updates/key=#{update_key}/is-liked"
put(path, 'false', "Content-Type" => "application/json")
end
end
end
end