umami-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,77 @@
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
+ File: CHANGELOG
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 = "CHANGELOG";
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="file_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> &raquo;
40
+ <span class="title">File: CHANGELOG</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h2 id="unreleased">[Unreleased]</h2>
61
+
62
+ <h2 id="0-1-0-2024-07-22">[0.1.0] - 2024-07-22</h2>
63
+
64
+ <ul>
65
+ <li>Initial release</li>
66
+ </ul>
67
+ </div></div>
68
+
69
+ <div id="footer">
70
+ Generated on Mon Jul 22 17:42:41 2024 by
71
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
72
+ 0.9.36 (ruby-3.2.2).
73
+ </div>
74
+
75
+ </div>
76
+ </body>
77
+ </html>
@@ -0,0 +1,70 @@
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
+ File: LICENSE
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 = "LICENSE";
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="file_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> &raquo;
40
+ <span class="title">File: LICENSE</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2024 Rameerez<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
61
+
62
+ <div id="footer">
63
+ Generated on Mon Jul 22 17:42:41 2024 by
64
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
65
+ 0.9.36 (ruby-3.2.2).
66
+ </div>
67
+
68
+ </div>
69
+ </body>
70
+ </html>
@@ -0,0 +1,182 @@
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
+ File: README
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 = "README";
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="file_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> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1 id="umami-ruby">Umami Ruby</h1>
61
+
62
+ <p><a href="https://badge.fury.io/rb/umami-ruby"><img src="https://badge.fury.io/rb/umami-ruby.svg" alt="Gem Version"></a></p>
63
+
64
+ <p>A Ruby wrapper for the Umami analytics API.</p>
65
+
66
+ <h2 id="installation">Installation</h2>
67
+
68
+ <p>Add this line to your application&#39;s Gemfile:</p>
69
+
70
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>umami-ruby</span><span class='tstring_end'>&#39;</span></span>
71
+ </code></pre>
72
+
73
+ <p>And then execute:</p>
74
+
75
+ <pre class="code ruby"><code class="ruby">$ bundle install
76
+ </code></pre>
77
+
78
+ <p>Or install it yourself as:</p>
79
+
80
+ <pre class="code ruby"><code class="ruby">$ gem install umami-ruby
81
+ </code></pre>
82
+
83
+ <h2 id="documentation">Documentation</h2>
84
+
85
+ <p>Full API documentation is available <a href="https://rameerez.github.io/umami-ruby/">online</a> or can be generated using YARD:</p>
86
+
87
+ <pre class="code bash"><code class="bash">yard doc
88
+ yard server
89
+ </code></pre>
90
+
91
+ <h2 id="usage">Usage</h2>
92
+
93
+ <h3 id="configuration">Configuration</h3>
94
+
95
+ <p>You can put this config in a handy location within your Rails project, like <code>config/initializers/umami.rb</code></p>
96
+
97
+ <h4 id="for-self-hosted-umami-instances">For self-hosted Umami instances:</h4>
98
+
99
+ <pre class="code ruby"><code class="ruby"><span class='comment'># With username and password
100
+ </span><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="Umami.html#configure-class_method" title="Umami.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
101
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_uri_base'>uri_base</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://your-umami-instance.com</span><span class='tstring_end'>&quot;</span></span>
102
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_credentials'>credentials</span> <span class='op'>=</span> <span class='lbrace'>{</span>
103
+ <span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_username</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
104
+ <span class='label'>password:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_password</span><span class='tstring_end'>&quot;</span></span>
105
+ <span class='rbrace'>}</span>
106
+ <span class='kw'>end</span>
107
+
108
+ <span class='comment'># Or with an access token
109
+ </span><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="Umami.html#configure-class_method" title="Umami.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
110
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_uri_base'>uri_base</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://your-umami-instance.com</span><span class='tstring_end'>&quot;</span></span>
111
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_access_token</span><span class='tstring_end'>&quot;</span></span>
112
+ <span class='kw'>end</span>
113
+ </code></pre>
114
+
115
+ <h4 id="for-umami-cloud">For Umami Cloud:</h4>
116
+
117
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="Umami.html#configure-class_method" title="Umami.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
118
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_api_key</span><span class='tstring_end'>&quot;</span></span>
119
+ <span class='comment'># No need to specify uri_base for Umami Cloud
120
+ </span><span class='kw'>end</span>
121
+ </code></pre>
122
+
123
+ <h3 id="using-the-client">Using the Client</h3>
124
+
125
+ <p>After configuration, you can use the client to interact with the Umami API:</p>
126
+
127
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Umami/Client.html" title="Umami::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Umami/Client.html#initialize-instance_method" title="Umami::Client#initialize (method)">new</a></span></span>
128
+
129
+ <span class='comment'># Get all websites
130
+ </span><span class='id identifier rubyid_websites'>websites</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_websites'>websites</span>
131
+
132
+ <span class='comment'># Get a specific website
133
+ </span><span class='id identifier rubyid_website'>website</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_website'>website</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website_id</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
134
+
135
+ <span class='comment'># Get website stats
136
+ </span><span class='id identifier rubyid_stats'>stats</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_website_stats'>website_stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website_id</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>startAt:</span> <span class='int'>1656679719687</span><span class='comma'>,</span> <span class='label'>endAt:</span> <span class='int'>1656766119687</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
137
+
138
+ <span class='comment'># Verify token
139
+ </span><span class='id identifier rubyid_token_info'>token_info</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_verify_token'>verify_token</span>
140
+ </code></pre>
141
+
142
+ <h2 id="error-handling">Error Handling</h2>
143
+
144
+ <p>The gem defines several custom error classes:</p>
145
+
146
+ <ul>
147
+ <li><code>Umami::ConfigurationError</code>: Raised for configuration-related issues.</li>
148
+ <li><code>Umami::AuthenticationError</code>: Raised for authentication-related issues.</li>
149
+ <li><code>Umami::APIError</code>: Raised for API request failures.</li>
150
+ </ul>
151
+
152
+ <h2 id="logging">Logging</h2>
153
+
154
+ <p>The gem uses a logger that can be configured:</p>
155
+
156
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_logger'><span class='object_link'><a href="Umami.html#logger-class_method" title="Umami.logger (method)">logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>DEBUG</span>
157
+ </code></pre>
158
+
159
+ <h2 id="development">Development</h2>
160
+
161
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake spec</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
162
+
163
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>.</p>
164
+
165
+ <h2 id="contributing">Contributing</h2>
166
+
167
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/rameerez/umami-ruby">https://github.com/rameerez/umami-ruby</a>. Our code of conduct is: just be nice and make your mom proud of what you do and post online.</p>
168
+
169
+ <h2 id="license">License</h2>
170
+
171
+ <p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
172
+ </div></div>
173
+
174
+ <div id="footer">
175
+ Generated on Mon Jul 22 17:42:41 2024 by
176
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
177
+ 0.9.36 (ruby-3.2.2).
178
+ </div>
179
+
180
+ </div>
181
+ </body>
182
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+ <li id="object_CHANGELOG" class="even">
53
+ <div class="item"><span class="object_link"><a href="file.CHANGELOG.html" title="CHANGELOG">CHANGELOG</a></span></div>
54
+ </li>
55
+
56
+
57
+ <li id="object_LICENSE" class="odd">
58
+ <div class="item"><span class="object_link"><a href="file.LICENSE.html" title="LICENSE">LICENSE</a></span></div>
59
+ </li>
60
+
61
+
62
+
63
+ </ul>
64
+ </div>
65
+ </body>
66
+ </html>
data/docs/frames.html ADDED
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.36</title>
6
+ </head>
7
+ <script type="text/javascript">
8
+ var mainUrl = 'index.html';
9
+ try {
10
+ var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
11
+ var name = match ? match[1] : mainUrl;
12
+ var url = new URL(name, location.href);
13
+ window.top.location.replace(url.origin === location.origin ? name : mainUrl);
14
+ } catch (e) {
15
+ window.top.location.replace(mainUrl);
16
+ }
17
+ </script>
18
+ <noscript>
19
+ <h1>Oops!</h1>
20
+ <h2>YARD requires JavaScript!</h2>
21
+ </noscript>
22
+ </html>
data/docs/index.html ADDED
@@ -0,0 +1,182 @@
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
+ File: README
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 = "README";
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> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1 id="umami-ruby">Umami Ruby</h1>
61
+
62
+ <p><a href="https://badge.fury.io/rb/umami-ruby"><img src="https://badge.fury.io/rb/umami-ruby.svg" alt="Gem Version"></a></p>
63
+
64
+ <p>A Ruby wrapper for the Umami analytics API.</p>
65
+
66
+ <h2 id="installation">Installation</h2>
67
+
68
+ <p>Add this line to your application&#39;s Gemfile:</p>
69
+
70
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>umami-ruby</span><span class='tstring_end'>&#39;</span></span>
71
+ </code></pre>
72
+
73
+ <p>And then execute:</p>
74
+
75
+ <pre class="code ruby"><code class="ruby">$ bundle install
76
+ </code></pre>
77
+
78
+ <p>Or install it yourself as:</p>
79
+
80
+ <pre class="code ruby"><code class="ruby">$ gem install umami-ruby
81
+ </code></pre>
82
+
83
+ <h2 id="documentation">Documentation</h2>
84
+
85
+ <p>Full API documentation is available <a href="https://rameerez.github.io/umami-ruby/">online</a> or can be generated using YARD:</p>
86
+
87
+ <pre class="code bash"><code class="bash">yard doc
88
+ yard server
89
+ </code></pre>
90
+
91
+ <h2 id="usage">Usage</h2>
92
+
93
+ <h3 id="configuration">Configuration</h3>
94
+
95
+ <p>You can put this config in a handy location within your Rails project, like <code>config/initializers/umami.rb</code></p>
96
+
97
+ <h4 id="for-self-hosted-umami-instances">For self-hosted Umami instances:</h4>
98
+
99
+ <pre class="code ruby"><code class="ruby"><span class='comment'># With username and password
100
+ </span><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="Umami.html#configure-class_method" title="Umami.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
101
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_uri_base'>uri_base</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://your-umami-instance.com</span><span class='tstring_end'>&quot;</span></span>
102
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_credentials'>credentials</span> <span class='op'>=</span> <span class='lbrace'>{</span>
103
+ <span class='label'>username:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_username</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
104
+ <span class='label'>password:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_password</span><span class='tstring_end'>&quot;</span></span>
105
+ <span class='rbrace'>}</span>
106
+ <span class='kw'>end</span>
107
+
108
+ <span class='comment'># Or with an access token
109
+ </span><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="Umami.html#configure-class_method" title="Umami.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
110
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_uri_base'>uri_base</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://your-umami-instance.com</span><span class='tstring_end'>&quot;</span></span>
111
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_access_token</span><span class='tstring_end'>&quot;</span></span>
112
+ <span class='kw'>end</span>
113
+ </code></pre>
114
+
115
+ <h4 id="for-umami-cloud">For Umami Cloud:</h4>
116
+
117
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="Umami.html#configure-class_method" title="Umami.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
118
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_access_token'>access_token</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>your_api_key</span><span class='tstring_end'>&quot;</span></span>
119
+ <span class='comment'># No need to specify uri_base for Umami Cloud
120
+ </span><span class='kw'>end</span>
121
+ </code></pre>
122
+
123
+ <h3 id="using-the-client">Using the Client</h3>
124
+
125
+ <p>After configuration, you can use the client to interact with the Umami API:</p>
126
+
127
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Umami/Client.html" title="Umami::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Umami/Client.html#initialize-instance_method" title="Umami::Client#initialize (method)">new</a></span></span>
128
+
129
+ <span class='comment'># Get all websites
130
+ </span><span class='id identifier rubyid_websites'>websites</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_websites'>websites</span>
131
+
132
+ <span class='comment'># Get a specific website
133
+ </span><span class='id identifier rubyid_website'>website</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_website'>website</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website_id</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
134
+
135
+ <span class='comment'># Get website stats
136
+ </span><span class='id identifier rubyid_stats'>stats</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_website_stats'>website_stats</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>website_id</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>startAt:</span> <span class='int'>1656679719687</span><span class='comma'>,</span> <span class='label'>endAt:</span> <span class='int'>1656766119687</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
137
+
138
+ <span class='comment'># Verify token
139
+ </span><span class='id identifier rubyid_token_info'>token_info</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_verify_token'>verify_token</span>
140
+ </code></pre>
141
+
142
+ <h2 id="error-handling">Error Handling</h2>
143
+
144
+ <p>The gem defines several custom error classes:</p>
145
+
146
+ <ul>
147
+ <li><code>Umami::ConfigurationError</code>: Raised for configuration-related issues.</li>
148
+ <li><code>Umami::AuthenticationError</code>: Raised for authentication-related issues.</li>
149
+ <li><code>Umami::APIError</code>: Raised for API request failures.</li>
150
+ </ul>
151
+
152
+ <h2 id="logging">Logging</h2>
153
+
154
+ <p>The gem uses a logger that can be configured:</p>
155
+
156
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Umami.html" title="Umami (module)">Umami</a></span></span><span class='period'>.</span><span class='id identifier rubyid_logger'><span class='object_link'><a href="Umami.html#logger-class_method" title="Umami.logger (method)">logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_level'>level</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>DEBUG</span>
157
+ </code></pre>
158
+
159
+ <h2 id="development">Development</h2>
160
+
161
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake spec</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
162
+
163
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>.</p>
164
+
165
+ <h2 id="contributing">Contributing</h2>
166
+
167
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/rameerez/umami-ruby">https://github.com/rameerez/umami-ruby</a>. Our code of conduct is: just be nice and make your mom proud of what you do and post online.</p>
168
+
169
+ <h2 id="license">License</h2>
170
+
171
+ <p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
172
+ </div></div>
173
+
174
+ <div id="footer">
175
+ Generated on Mon Jul 22 17:42:41 2024 by
176
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
177
+ 0.9.36 (ruby-3.2.2).
178
+ </div>
179
+
180
+ </div>
181
+ </body>
182
+ </html>