umami-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f2bf01e43c4999e6c89a262b523fa26fc9c365e7c3b22c8e40e5ae4235859299
4
+ data.tar.gz: 3ba600eacacb24d3836d54ded7cdd5264a1af4f85da3f84a4a49dde022d87fe8
5
+ SHA512:
6
+ metadata.gz: 44f9bd1f3362ee5d671f88ecd3ff2525303fbfde7c46360df90182b8ffc01c028dbe45679c3db9d87724e3a4993f6a96f37d3198938cdcc8f4c5415fde55c27b
7
+ data.tar.gz: 39211469acd7173916112aad2348222351b85ef4cfd00525483eedb0bbe145e49cdc48bcce4494db549037dfffc553d3efac48de9375461129e9c92b03296de9
data/.yardopts ADDED
@@ -0,0 +1,10 @@
1
+ --no-private
2
+ --protected
3
+ --markup-provider=redcarpet
4
+ --markup=markdown
5
+ --output-dir docs
6
+ lib/**/*.rb
7
+ -
8
+ README.md
9
+ CHANGELOG.md
10
+ LICENSE.txt
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-07-22
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Rameerez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # Umami Ruby
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/umami-ruby.svg)](https://badge.fury.io/rb/umami-ruby)
4
+
5
+ A Ruby wrapper for the Umami analytics API.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'umami-ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```
18
+ $ bundle install
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```
24
+ $ gem install umami-ruby
25
+ ```
26
+
27
+ ## Documentation
28
+
29
+ Full API documentation is available [online](https://rameerez.github.io/umami-ruby/) or can be generated using YARD:
30
+
31
+ ```bash
32
+ yard doc
33
+ yard server
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### Configuration
39
+
40
+ You can put this config in a handy location within your Rails project, like `config/initializers/umami.rb`
41
+
42
+ #### For self-hosted Umami instances:
43
+
44
+ ```ruby
45
+ # With username and password
46
+ Umami.configure do |config|
47
+ config.uri_base = "https://your-umami-instance.com"
48
+ config.credentials = {
49
+ username: "your_username",
50
+ password: "your_password"
51
+ }
52
+ end
53
+
54
+ # Or with an access token
55
+ Umami.configure do |config|
56
+ config.uri_base = "https://your-umami-instance.com"
57
+ config.access_token = "your_access_token"
58
+ end
59
+ ```
60
+
61
+ #### For Umami Cloud:
62
+
63
+ ```ruby
64
+ Umami.configure do |config|
65
+ config.access_token = "your_api_key"
66
+ # No need to specify uri_base for Umami Cloud
67
+ end
68
+ ```
69
+
70
+ ### Using the Client
71
+
72
+ After configuration, you can use the client to interact with the Umami API:
73
+
74
+ ```ruby
75
+ client = Umami::Client.new
76
+
77
+ # Get all websites
78
+ websites = client.websites
79
+
80
+ # Get a specific website
81
+ website = client.website("website_id")
82
+
83
+ # Get website stats
84
+ stats = client.website_stats("website_id", { startAt: 1656679719687, endAt: 1656766119687 })
85
+
86
+ # Verify token
87
+ token_info = client.verify_token
88
+ ```
89
+
90
+ ## Error Handling
91
+
92
+ The gem defines several custom error classes:
93
+
94
+ - `Umami::ConfigurationError`: Raised for configuration-related issues.
95
+ - `Umami::AuthenticationError`: Raised for authentication-related issues.
96
+ - `Umami::APIError`: Raised for API request failures.
97
+
98
+ ## Logging
99
+
100
+ The gem uses a logger that can be configured:
101
+
102
+ ```ruby
103
+ Umami.logger.level = Logger::DEBUG
104
+ ```
105
+
106
+ ## Development
107
+
108
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
109
+
110
+ To install this gem onto your local machine, run `bundle exec rake install`.
111
+
112
+ ## Contributing
113
+
114
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rameerez/umami-ruby. Our code of conduct is: just be nice and make your mom proud of what you do and post online.
115
+
116
+ ## License
117
+
118
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,146 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Exception: Umami::APIError
8
+
9
+ &mdash; Documentation by YARD 0.9.36
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Umami::APIError";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Umami.html" title="Umami (module)">Umami</a></span></span>
41
+ &raquo;
42
+ <span class="title">APIError</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Exception: Umami::APIError
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Error.html" title="Umami::Error (class)">Error</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">StandardError</li>
78
+
79
+ <li class="next"><span class='object_link'><a href="Error.html" title="Umami::Error (class)">Error</a></span></li>
80
+
81
+ <li class="next">Umami::APIError</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+ </dl>
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <dl>
100
+ <dt>Defined in:</dt>
101
+ <dd>lib/umami/errors.rb</dd>
102
+ </dl>
103
+
104
+ </div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+ <p>Base error class for API-related errors</p>
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+
116
+ </div><div id="subclasses">
117
+ <h2>Direct Known Subclasses</h2>
118
+ <p class="children"><span class='object_link'><a href="ClientError.html" title="Umami::ClientError (class)">ClientError</a></span>, <span class='object_link'><a href="NotFoundError.html" title="Umami::NotFoundError (class)">NotFoundError</a></span>, <span class='object_link'><a href="ServerError.html" title="Umami::ServerError (class)">ServerError</a></span></p>
119
+ </div>
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ </div>
137
+
138
+ <div id="footer">
139
+ Generated on Mon Jul 22 17:42:41 2024 by
140
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
141
+ 0.9.36 (ruby-3.2.2).
142
+ </div>
143
+
144
+ </div>
145
+ </body>
146
+ </html>
@@ -0,0 +1,142 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Exception: Umami::AuthenticationError
8
+
9
+ &mdash; Documentation by YARD 0.9.36
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Umami::AuthenticationError";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Umami.html" title="Umami (module)">Umami</a></span></span>
41
+ &raquo;
42
+ <span class="title">AuthenticationError</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Exception: Umami::AuthenticationError
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Error.html" title="Umami::Error (class)">Error</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">StandardError</li>
78
+
79
+ <li class="next"><span class='object_link'><a href="Error.html" title="Umami::Error (class)">Error</a></span></li>
80
+
81
+ <li class="next">Umami::AuthenticationError</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+ </dl>
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <dl>
100
+ <dt>Defined in:</dt>
101
+ <dd>lib/umami/errors.rb</dd>
102
+ </dl>
103
+
104
+ </div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+ <p>Error raised when authentication fails</p>
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+
116
+ </div>
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ </div>
133
+
134
+ <div id="footer">
135
+ Generated on Mon Jul 22 17:42:41 2024 by
136
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
137
+ 0.9.36 (ruby-3.2.2).
138
+ </div>
139
+
140
+ </div>
141
+ </body>
142
+ </html>