Module: Viadeo
- Defined in:
- lib/viadeo.rb,
lib/viadeo/user.rb,
lib/viadeo/util.rb,
lib/viadeo/error.rb,
lib/viadeo/search.rb,
lib/viadeo/status.rb,
lib/viadeo/request.rb,
lib/viadeo/version.rb,
lib/viadeo/newsfeed.rb,
lib/viadeo/recommend.rb,
lib/viadeo/graph_object.rb,
lib/viadeo/configuration.rb,
lib/viadeo/operations/get.rb,
lib/viadeo/reference_data.rb,
lib/viadeo/operations/list.rb,
lib/viadeo/graph_connection.rb,
lib/viadeo/operations/create.rb,
lib/viadeo/operations/update.rb
Defined Under Namespace
Modules: Operations
Classes: Configuration, Error, GraphConnection, GraphObject, MissingAccessTokenError, MissingResourceError, Newsfeed, Recommend, ReferenceData, Search, Status, User, Util
Constant Summary
collapse
- VERSION =
"0.0.2"
Class Method Summary
collapse
Class Method Details
Configure Viadeo parameters by passing block
Example
Viadeo.configure do |config|
config.logger = logger
config.timeout = 30
config.open_timeout = 30
config.url = "https://api.viadeo.com"
end
43
44
45
|
# File 'lib/viadeo.rb', line 43
def configure(&block)
block.call(config) if block_given?
end
|
.log(message) ⇒ Object
51
52
53
54
|
# File 'lib/viadeo.rb', line 51
def log message
return if config.logger.nil? || message.nil?
config.logger.debug message
end
|
.request(method, options = {}) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/viadeo/request.rb', line 2
def self.request(method, options={})
= {
:user_agent => "Viadeo gem/#{Viadeo::VERSION}",
:authorization => "Bearer #{options[:access_token]}",
:content_type => "application/x-www-form-urlencoded;charset=UTF-8"
}
timeout_options = {timeout: Viadeo.config.timeout, open_timeout: Viadeo.config.open_timeout}
conn = Faraday.new(:url => Viadeo.config.url) do |faraday|
faraday.request :url_encoded faraday.response :logger faraday.adapter Faraday.default_adapter end
response = conn.send(method) do |req|
req.url(options[:id].nil? ? options[:url] : options[:id])
req. =
req.options = timeout_options
req.params = options[:params] if options[:params]
end
Viadeo.log "response : body : " + response.body
Viadeo::Util.filter_response(response)
end
|
.version_string ⇒ Object
31
32
33
|
# File 'lib/viadeo.rb', line 31
def version_string
"Viadeo version #{Viadeo::VERSION}"
end
|