access_watch 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ module AccessWatch
2
+ end
3
+
4
+ require "access_watch/version"
5
+ require "access_watch/client"
@@ -0,0 +1,42 @@
1
+ require "json/ext"
2
+ require "net/http"
3
+ require "uri"
4
+ require "openssl"
5
+
6
+ module AccessWatch
7
+ class Client
8
+ attr_reader :api_key, :api_secret, :api_endpoint
9
+
10
+ def initialize(options)
11
+ @api_secret = options[:api_secret]
12
+ @api_key = options[:api_key] or raise "AccessWatch api_key is mandatory."
13
+ @api_endpoint = options[:api_endpoint] || "https://access.watch/api/1.0/"
14
+ end
15
+
16
+ HTTPS = "https".freeze
17
+ CERTIFICATE_AUTHORITIES_PATH = File.expand_path("../../../cacert.pem", __FILE__)
18
+
19
+ def post(path, data)
20
+ uri = URI(api_endpoint + path)
21
+ http = Net::HTTP.new(uri.host, uri.port)
22
+
23
+ if uri.scheme == HTTPS
24
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
25
+ http.ca_file = CERTIFICATE_AUTHORITIES_PATH
26
+ http.use_ssl = true
27
+ end
28
+
29
+ post = Net::HTTP::Post.new(uri.path, default_headers)
30
+ post.body = data.to_json
31
+ resp = http.request(post)
32
+ end
33
+
34
+ def default_headers
35
+ {
36
+ "Api-Key" => api_key,
37
+ "Accept" => "application/json",
38
+ "Content-Type" => "application/json",
39
+ }
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module AccessWatch
2
+ VERSION = "0.0.2".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: access_watch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Alexis Bernard
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A Ruby library to log and analyse HTTP requests using the Access Watch
42
+ cloud service.
43
+ email:
44
+ - alexis@bernard.io
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - LICENSE
51
+ - README.md
52
+ - access_watch.gemspec
53
+ - cacert.pem
54
+ - lib/access_watch.rb
55
+ - lib/access_watch/client.rb
56
+ - lib/access_watch/version.rb
57
+ homepage: https://access.watch/
58
+ licenses:
59
+ - MIT
60
+ metadata:
61
+ allowed_push_host: https://rubygems.org
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.5.1
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A Ruby library to log and analyse HTTP requests using the Access Watch cloud
82
+ service.
83
+ test_files: []
84
+ has_rdoc: