lib/ezlinkedin/api/query_methods.rb in ezlinkedin-0.1.2 vs lib/ezlinkedin/api/query_methods.rb in ezlinkedin-0.2.2
- old
+ new
@@ -46,17 +46,29 @@
# @param options={} [Hash] parameters to search by, includes:
# id, universal-name(pass it in as :name), email-domain(:domain).
# options can also include a string array of fields to return. See
# the linkedin api for available fields
#
- # @return [type] [description]
+ # @return [Mash] Mash hash of results
def company(options={})
path = company_path(options)
- fields = options.include?(:fields)
- make_query(path, options, fields)
+ use_fields = options.include?(:fields)
+ make_query(path, options, use_fields)
end
+
+ #
+ # Returns the groups the current user is a member of
+ # @param options={} [Hash] can include a string array
+ # containing the names of fields to get from each group
+ #
+ # @return [Mash] Mash hash of results
+ def group_memberships(options={})
+ path = "#{person_path(options)}/group-memberships#{group_options(options)}"
+ make_query(path, options.merge({member: true}), false)
+ end
+
private
def person_path(options)
path = "/people/"
if id = options.delete(:id)
@@ -82,10 +94,11 @@
elsif domain
path += "?email-domain=#{domain}"
end
end
+
#
# create a valid path to make a restful request
# @param path [String] current path
# @param options [Hash] set of options
# @param use_fields |boolean| does request need fields?
@@ -98,10 +111,12 @@
path += ":(#{fields.join(',')})"
elsif path.end_with? "network/updates"
path += network_options(options).to_s # if getting updates, add relevant options to the path
elsif count = options.delete(:count)
path += "?count=#{count}"
+ elsif member = options.delete(:member)
+ path += "?membership-state=member"
end
Mash.from_json(get(path, options))
end
@@ -136,9 +151,15 @@
def add_to_path(option, options_path)
if options_path.nil?
options_path = option
else
options_path += "&#{option}"
+ end
+ end
+
+ def group_options(options)
+ if fields = options.delete(:fields)
+ path = ":(group:(#{fields.join(',')}))"
end
end
end
end