Module: EspressoPath
- Defined in:
- lib/espresso_path.rb,
lib/espresso_path/version.rb,
lib/espresso_path/geo_path.rb,
lib/espresso_path/configuration.rb,
lib/generators/espresso_path/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Configuration, GeoPath
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
9
10
11
|
# File 'lib/espresso_path.rb', line 9
def configuration
@configuration
end
|
Class Method Details
20
21
22
|
# File 'lib/espresso_path.rb', line 20
def self.configure
yield(configuration)
end
|
.login ⇒ Object
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
|
# File 'lib/espresso_path.rb', line 24
def self.login
uri = URI.parse("https://insights-api.geopath.org/login")
puts uri
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
puts EspressoPath.configuration.user_name
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({ :username => EspressoPath.configuration.user_name, :password => EspressoPath.configuration.password })
response = http.request(request)
puts response.body
puts "here"
body = JSON.parse(response.body)
EspressoPath.configuration.client_token = body["access_token"]
EspressoPath.configuration.options = {
headers: {
"Authorization"=> "Bearer #{EspressoPath.configuration.client_token}"
}
}
end
|
.reset ⇒ Object
16
17
18
|
# File 'lib/espresso_path.rb', line 16
def self.reset
@configuration = Configuration.new
end
|