-
Notifications
You must be signed in to change notification settings - Fork 403
Expand file tree
/
Copy pathcompanies.rb
More file actions
128 lines (119 loc) · 4.3 KB
/
companies.rb
File metadata and controls
128 lines (119 loc) · 4.3 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
module LinkedIn
module Api
# Companies API
#
# @see http://developer.linkedin.com/documents/companies Companies API
# @see http://developer.linkedin.com/documents/company-lookup-api-and-fields Company Fields
#
# The following API actions do not have corresponding methods in
# this module
#
# * Permissions Checking Endpoints for Company Shares
# * GET Suggested Companies to Follow
# * GET Company Products
#
# [(contribute here)](https://github.com/hexgnu/linkedin)
module Companies
# Retrieve a Company Profile
#
# @see http://developer.linkedin.com/documents/company-lookup-api-and-fields
#
# @macro company_path_options
# @option options [String] :scope
# @option options [String] :type
# @option options [String] :count
# @option options [String] :start
# @return [LinkedIn::Mash]
def company(options = {})
path = company_path(options)
simple_query(path, options)
end
# Retrieve a feed of event items for a Company
#
# @see http://developer.linkedin.com/reading-company-shares
#
# @macro company_path_options
# @option options [String] :event-type
# @option options [String] :count
# @option options [String] :start
# @return [LinkedIn::Mash]
def company_updates(options={})
path = "#{company_path(options)}/updates"
simple_query(path, options)
end
# Retrieve statistics for a particular company page
#
# Permissions: rw_company_admin
#
# @see http://developer.linkedin.com/documents/company-statistics
#
# @macro company_path_options
# @return [LinkedIn::Mash]
def company_statistics(options={})
path = "#{company_path(options)}/company-statistics"
simple_query(path, options)
end
# Retrieve comments on a particular company update:
#
# @see http://developer.linkedin.com/reading-company-shares
#
# @param [String] update_key a update/update-key representing a
# particular company update
# @macro company_path_options
# @return [LinkedIn::Mash]
def company_updates_comments(update_key, options={})
path = "#{company_path(options)}/updates/key=#{update_key}/update-comments"
simple_query(path, options)
end
# Retrieve likes on a particular company update:
#
# @see http://developer.linkedin.com/reading-company-shares
#
# @param [String] update_key a update/update-key representing a
# particular company update
# @macro company_path_options
# @return [LinkedIn::Mash]
def company_updates_likes(update_key, options={})
path = "#{company_path(options)}/updates/key=#{update_key}/likes"
simple_query(path, options)
end
# Create a share for a company that the authenticated user
# administers
#
# Permissions: rw_company_admin
#
# @see http://developer.linkedin.com/creating-company-shares
# @see http://developer.linkedin.com/documents/targeting-company-shares Targeting Company Shares
#
# @param [String] company_id Company ID
# @macro share_input_fields
# @return [void]
def add_company_share(company_id, share)
path = "companies/#{company_id}/shares"
defaults = {:visibility => {:code => "anyone"}}
post(path, MultiJson.dump(defaults.merge(share)), "Content-Type" => "application/json")
end
# (Create) authenticated user starts following a company
#
# @see http://developer.linkedin.com/documents/company-follow-and-suggestions
#
# @param [String] company_id Company ID
# @return [void]
def follow_company(company_id)
path = "people/~/following/companies"
body = {:id => company_id }
post(path, MultiJson.dump(body), "Content-Type" => "application/json")
end
# (Destroy) authenticated user stops following a company
#
# @see http://developer.linkedin.com/documents/company-follow-and-suggestions
#
# @param [String] company_id Company ID
# @return [void]
def unfollow_company(company_id)
path = "people/~/following/companies/id=#{company_id}"
delete(path)
end
end
end
end