<commit_before>module EzLinkedin
	module Api

		module QueryMethods

			
			# 
			# Retrieve a certain profile depending on the options passed in.
			# @param  options={} [Hash] can be an array of fields and an id,
			# 	and a url to a public profile. This can also contain request 
			#   headers
			# 
			# @return [Mash] a Mash hash representing the found profile
			def profile(options={})
				path = person_path(options)
				make_query(path, options, true)
			end


			# 
			# Retrieve the authenticated user's connections
			# @param  options={} [Hash] see profile options
			# 
			# @return [Mash] Mash hash of connections
			def connections(options={})
				path = "#{person_path(options)}/connections"
				make_query(path, options, true)
			end

			# 
			# Retrieve the user's social feed
			# @param  options={} [Hash] visit Linkedin's api to
			# 	see possible options. it will default to an 
			#   aggregated feed unless :scope => self. 
			#   :types => [:shar, :recu, :apps] 
			#   :count => 5
			#   :hidden_members => true                        
			# 
			# @return [Mash] Mash hash of updates 
			def network_updates(options={})
				path = "#{person_path(options)}/network/updates"
				make_query(path, options, false)
			end

			private

				def person_path(options)
					path = "/people/"
					if id = options.delete(:id)
						path += "id=#{id}"
					elsif url = options.delete(:url)
						path += "url=#{CGI.escape(url)}"
					else
						path += '~'
					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?
				#
				# @return [Mash] hash object with results
				def make_query(path, options, use_fields)

					fields = options.delete(:fields) || EzLinkedin.default_profile_fields if use_fields
					if fields
						path += ":(#{fields.join(',')})"
					elsif path.end_with? "network/updates"
						path += network_options(options).to_s # if getting updates, add relevant options to the path
					end

					Mash.from_json(get(path, options))
				end

				def network_options(options)
					path = "?"
					options_path = nil

					if types = options.delete(:types)
						types = types.map { |type| "type=#{type.to_s.upcase}" }
						options_path = types.join('&')
					end	

					unless options.empty?
						opts = []<commit_msg>improving some documentation in Api module<commit_after>module EzLinkedin
	module Api

		module QueryMethods

			
			# 
			# Retrieve a certain profile depending on the options passed in.
			# @param  options={} [Hash] can be an array of fields as strings and an id,
			# 	and a url to a public profile. This can also contain request 
			#   headers
			# 
			# @return [Mash] a Mash hash representing the found profile
			def profile(options={})
				path = person_path(options)
				make_query(path, options, true)
			end


			# 
			# Retrieve the authenticated user's connections
			# @param  options={} [Hash] pass in fields and/or a count
			# 
			# @return [Mash] Mash hash of connections
			def connections(options={})
				path = "#{person_path(options)}/connections"
				make_query(path, options, true)
			end

			# 
			# Retrieve the user's social feed
			# @param  options={} [Hash] visit Linkedin's api to
			# 	see possible options. it will default to an 
			#   aggregated feed unless :scope => 'self'. 
			#   :types => [:shar, :recu, :apps] 
			#   :count => 5
			#   :hidden_members => true                        
			# 
			# @return [Mash] Mash hash of updates 
			def network_updates(options={})
				path = "#{person_path(options)}/network/updates"
				make_query(path, options, false)
			end

			private

				def person_path(options)
					path = "/people/"
					if id = options.delete(:id)
						path += "id=#{id}"
					elsif url = options.delete(:url)
						path += "url=#{CGI.escape(url)}"
					else
						path += '~'
					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?
				#
				# @return [Mash] hash object with results
				def make_query(path, options, use_fields)

					fields = options.delete(:fields) || EzLinkedin.default_profile_fields if use_fields
					if fields
						path += ":(#{fields.join(',')})"
					elsif count = options.delete(:count)
						path += "?count=#{count}"
					elsif path.end_with? "network/updates"
						path += network_options(options).to_s # if getting updates, add relevant options to the path
					end

					Mash.from_json(get(path, options))
				end

				def network_options(options)
					path = "?"
					options_path = nil

					if types = options.delete(:types)
						types = types.map { |type| "type=#{type.to_s.upcase}" }
						options_path = types.join('&')
					end	

					unless options.empty?
						opts = []
{'fraction_non_alphanumeric': 0.11355385235982252, 'fraction_numerical': 0.0004033884630899556, 'mean_word_length': 2.6170678336980306, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5090156', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1552, 'n_words': 477}