everylog_ruby_client 1.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a41febdaeb7e75805abe0fb888b1967757bbeb652ebc6178329f74035a578cfc
4
+ data.tar.gz: '08e6751b3e68e5151769e28b6422ef439be51ca215bf9f2761431539ff5f6b53'
5
+ SHA512:
6
+ metadata.gz: 0ff1922e485792cae0c20d20c889eed0365f6af4cc297685fb7e0a1ca03fb6ce99983ec7321c947a3b4a190533561f712dd28280113248ddd5fd7b19f88fd70d
7
+ data.tar.gz: 072bc8c0756b36d07b110d4bc958f07dc2083c7a19418c2388ac94521474bf4be2f78f10da97bc47443c9e526e513da09744797cc7ae327ae2ca9bc75ad363b9
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2022-04-22
4
+
5
+ - Initial release
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # EveryLog Ruby Client
2
+
3
+ A fantastic (and simple) gem to interact with the EveryLog API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'everylog_ruby_client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install everylog_ruby_client
20
+
21
+ ## Usage
22
+ ```ruby
23
+ require 'everylog_ruby_client'
24
+
25
+ # @param [Hash] options
26
+ # @option options [String] :api_key for authenticate against EveryLog server
27
+ # @option options [String] :everylog_url (https://api.everylog.io/api/v1/log-entries) to reach Everlog server
28
+ $EveryLogClient = EveryLog::Client.instance.setup(api_key: <YOUR_API_KEY>)
29
+
30
+ # @param [Hash] options
31
+ # @option options [String] :projectId name of the project
32
+ # @option options [String] :title to display in the application and if enabled in the notification
33
+ # @option options [String] :summary is a not so long text to display on the application and if enabled in the notification
34
+ # @option options [String] :body it can contain a long text simple formatted, no html to display in the application
35
+ # @option options [Array] :tags it can be used to categorize the notification, must be strings
36
+ # @option options [String] :link it can be used to display on the application and if enabled in the notification
37
+ # @option options [Boolean] :push if True, a push notification is sent to application
38
+ $EveryLogClient.notify(...)
39
+ ```
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/everylogsaas/everylog_ruby_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/everylogsaas/everylog_ruby_client/blob/master/CODE_OF_CONDUCT.md).
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the EveryLog ruby client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/everylogsaas/everylog_ruby_client/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EveryLogRubyClient
4
+ VERSION = "1.0.1"
5
+ end
@@ -0,0 +1,76 @@
1
+ require_relative "everylog_ruby_client/version"
2
+ require "singleton"
3
+ require "uri"
4
+ require "net/http"
5
+ require "json"
6
+
7
+ module EveryLog
8
+ class Client
9
+ include ::Singleton
10
+
11
+ SETUP_DEFAULTS = {
12
+ api_key: nil,
13
+ everylog_url: "https://api.everylog.io/api/v1/log-entries"
14
+ }.freeze
15
+
16
+ NOTIFY_DEFAULTS = {
17
+ projectId: nil,
18
+ title: nil,
19
+ summary: nil,
20
+ body: nil,
21
+ tags: [],
22
+ link: "",
23
+ push: false
24
+ }.freeze
25
+
26
+ attr_reader :options
27
+
28
+ # @param [Hash] options
29
+ # @option options [String] :api_key for authenticate against Everylog server
30
+ # @option options [String] :everylog_url (https://api.everylog.io/api/v1/log-entries) to reach Everlog server
31
+ def setup(options = {})
32
+ @options = _parse_options(options, SETUP_DEFAULTS)
33
+ self
34
+ end
35
+
36
+ # @param [Hash] options
37
+ # @option options [String] :projectId name of the project
38
+ # @option options [String] :title to display in the application and if enabled in the notification
39
+ # @option options [String] :summary is a not so long text to display on the application and if enabled in the notification
40
+ # @option options [String] :body it can contain a long text simple formatted, no html to display in the application
41
+ # @option options [Array] :tags it can be used to categorize the notification, must be strings
42
+ # @option options [String] :link it can be used to display on the application and if enabled in the notification
43
+ # @option options [Boolean] :push if True, a push notification is sent to application
44
+ def notify(notify_options = {})
45
+ @notify_options = _parse_options(notify_options, NOTIFY_DEFAULTS)
46
+ uri = URI(options[:everylog_url])
47
+ req = Net::HTTP::Post.new(uri, {
48
+ "Content-Type": "application/json",
49
+ "Authorization": "Bearer #{options[:api_key]}"
50
+ })
51
+ req.body = @notify_options.to_json
52
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
53
+ http.request(req)
54
+ end
55
+ res.body
56
+ end
57
+
58
+ private
59
+
60
+ def _parse_options(options, defaults_to_dup)
61
+ defaults = defaults_to_dup.dup
62
+ result_parsed_options = options.dup
63
+
64
+ defaults.each_key do |key|
65
+ defaults[key] = defaults[key].call if defaults[key].respond_to?(:call)
66
+ result_parsed_options[key] = result_parsed_options[key.to_s] if result_parsed_options.key?(key.to_s)
67
+ end
68
+
69
+ defaults.each_key do |key|
70
+ result_parsed_options[key] = defaults[key] if result_parsed_options[key].nil?
71
+ end
72
+
73
+ result_parsed_options
74
+ end
75
+ end
76
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: everylog_ruby_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gilberto Maccacaro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-04-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: " A simple Ruby with no external dependencies, to easily integrate
14
+ with Everylog API\n"
15
+ email:
16
+ - gilberto.maccacaro@devinterface.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - README.md
23
+ - lib/everylog_ruby_client.rb
24
+ - lib/everylog_ruby_client/version.rb
25
+ homepage: https://github.com/everylogsaas/everylog_ruby_client
26
+ licenses:
27
+ - MIT
28
+ metadata:
29
+ bug_tracker_uri: https://github.com/everylogsaas/everylog_ruby_client/issues
30
+ changelog_uri: https://github.com/everylogsaas/everylog_ruby_client/blob/master/CHANGELOG.md
31
+ documentation_uri: https://www.rubydoc.info/gems/everylog_ruby_client/1.0.1
32
+ homepage_uri: https://github.com/everylogsaas/everylog_ruby_client
33
+ source_code_uri: https://github.com/everylogsaas/everylog_ruby_client/tree/v1.0.1
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '2.5'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.3.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: A Ruby client library for Everylog API
53
+ test_files: []