truemail-client 0.1.1 → 0.2.0
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 +4 -4
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +16 -2
- data/lib/truemail/client.rb +9 -4
- data/lib/truemail/client/http.rb +16 -5
- data/lib/truemail/client/version.rb +1 -1
- data/truemail-client.gemspec +8 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1b42e36e9d9d70a91dd951c594d3b3afc3ee8815ed3a50fbaa4b179b0488b59
|
4
|
+
data.tar.gz: 4af09437d71822e86365eb59cef631b52f3ddf2d49db65d528949296f904d780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 162f18138f8764672e8e416c5f30f46a63092aadde2d7592bf828be002991632dba30b184c0873764c9802032b605b8c43ab9609993a95de407425bd9c051c58
|
7
|
+
data.tar.gz: 4296b7edb2acc4a22be663bc2c14ba5b0af3375e3ddcf5d5419ce80c3c7fb6849e19792430e4e6c34369c500f6e7b76bdca6a8d38ba27921e22ab2d1572cac5b
|
data/.github/ISSUE_TEMPLATE.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
- [ ] I have updated truemail-ruby-client to the latest version
|
6
6
|
- [ ] I have read the [Contribution Guidelines](https://github.com/truemail-rb/truemail-ruby-client/blob/master/CONTRIBUTING.md)
|
7
|
-
- [ ] I have read the [documentation](https://
|
7
|
+
- [ ] I have read the [documentation](https://truemail-rb.org/truemail-ruby-client)
|
8
8
|
- [ ] I have searched for [existing GitHub issues](https://github.com/truemail-rb/truemail-ruby-client/issues)
|
9
9
|
|
10
10
|
### Issue Description
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
4
4
|
|
5
|
+
## [0.2.0] - 2020-10-04
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
Ability to use Truemail healthcheck endpoint
|
10
|
+
|
11
|
+
- Added `Truemail::Client.server_healthy?`
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Updated `Truemail::Client::Http#uri`
|
16
|
+
- Updated gem dependencies
|
17
|
+
- Updated gem documentation
|
18
|
+
- Updated gem version
|
19
|
+
|
5
20
|
## [0.1.1] - 2020-07-21
|
6
21
|
|
7
22
|
### Changed
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# 
|
2
2
|
|
3
3
|
[](https://codeclimate.com/github/truemail-rb/truemail-ruby-client/maintainability) [](https://codeclimate.com/github/truemail-rb/truemail-ruby-client/test_coverage) [](https://circleci.com/gh/truemail-rb/truemail-ruby-client/tree/develop) [](https://badge.fury.io/rb/truemail-client) [](https://rubygems.org/gems/truemail-client) [](CODE_OF_CONDUCT.md)
|
4
4
|
|
5
5
|
`truemail-client` gem - [Truemail web API](https://github.com/truemail-rb/truemail-rack) client library for Ruby.
|
6
6
|
|
7
|
+
|
8
|
+
> Actual and maintainable documentation :books: for developers is living [here](https://truemail-rb.org/truemail-ruby-client).
|
9
|
+
|
7
10
|
## Table of Contents
|
8
11
|
|
9
12
|
- [Installation](#installation)
|
10
13
|
- [Usage](#usage)
|
11
14
|
- [Setting global configuration](#setting-global-configuration)
|
12
15
|
- [Establishing connection with Truemail API](#establishing-connection-with-truemail-api)
|
16
|
+
- [Checking server health status](#checking-server-health-status)
|
13
17
|
- [Additional features](#additional-features)
|
14
18
|
- [Truemail family](#truemail-family)
|
15
19
|
- [Contributing](#contributing)
|
@@ -92,6 +96,16 @@ Truemail::Client.validate('admin@bestweb.com.ua')
|
|
92
96
|
}
|
93
97
|
```
|
94
98
|
|
99
|
+
### Checking server health status
|
100
|
+
|
101
|
+
After successful configuration, you can check health-status of Truemail server.
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
Truemail::Client.server_healthy?
|
105
|
+
|
106
|
+
=> true
|
107
|
+
```
|
108
|
+
|
95
109
|
### Additional features
|
96
110
|
|
97
111
|
#### Read global configuration
|
@@ -136,7 +150,7 @@ Truemail::Client.configuration
|
|
136
150
|
|
137
151
|
## Truemail family
|
138
152
|
|
139
|
-
All Truemail extensions: https://
|
153
|
+
All Truemail extensions: https://truemail-rb.org
|
140
154
|
|
141
155
|
| Name | Type | Description |
|
142
156
|
| --- | --- | --- |
|
data/lib/truemail/client.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative '../truemail/client/version'
|
4
|
+
require_relative '../truemail/client/configuration'
|
5
|
+
require_relative '../truemail/client/http'
|
6
6
|
|
7
7
|
module Truemail
|
8
8
|
module Client
|
@@ -29,7 +29,12 @@ module Truemail
|
|
29
29
|
|
30
30
|
def validate(email)
|
31
31
|
raise_unless(Truemail::Client.configuration, Truemail::Client::NOT_CONFIGURED)
|
32
|
-
Truemail::Client::Http.new(email).run
|
32
|
+
Truemail::Client::Http.new(email: email).run
|
33
|
+
end
|
34
|
+
|
35
|
+
def server_healthy?
|
36
|
+
raise_unless(Truemail::Client.configuration, Truemail::Client::NOT_CONFIGURED)
|
37
|
+
Truemail::Client::Http.new(Truemail::Client::Http::HEALTHCHECK_ENDPOINT).run.empty?
|
33
38
|
end
|
34
39
|
|
35
40
|
private
|
data/lib/truemail/client/http.rb
CHANGED
@@ -5,16 +5,20 @@ module Truemail
|
|
5
5
|
class Http
|
6
6
|
require 'uri'
|
7
7
|
require 'net/http'
|
8
|
+
require 'json'
|
8
9
|
|
9
|
-
URI_ATTRS = %i[secure_connection host port
|
10
|
+
URI_ATTRS = %i[secure_connection host port endpoint uri_params].freeze
|
10
11
|
USER_AGENT = 'Truemail Ruby client'
|
11
12
|
MIME_TYPE = 'application/json'
|
13
|
+
VALIDATION_ENDPOINT = '/'
|
14
|
+
HEALTHCHECK_ENDPOINT = '/healthcheck'
|
12
15
|
|
13
|
-
def initialize(
|
14
|
-
Truemail::Client::Http::URI_ATTRS[0
|
16
|
+
def initialize(endpoint = Truemail::Client::Http::VALIDATION_ENDPOINT, **uri_params)
|
17
|
+
Truemail::Client::Http::URI_ATTRS[0..2].each do |attribute|
|
15
18
|
instance_variable_set(:"@#{attribute}", Truemail::Client.configuration.public_send(attribute))
|
16
19
|
end
|
17
|
-
@
|
20
|
+
@endpoint = endpoint
|
21
|
+
@uri_params = uri_params
|
18
22
|
end
|
19
23
|
|
20
24
|
def run
|
@@ -34,8 +38,15 @@ module Truemail
|
|
34
38
|
|
35
39
|
attr_reader(*Truemail::Client::Http::URI_ATTRS)
|
36
40
|
|
41
|
+
def request_uri
|
42
|
+
URI::HTTP.build(
|
43
|
+
path: endpoint,
|
44
|
+
query: uri_params.empty? ? nil : URI.encode_www_form(uri_params)
|
45
|
+
).request_uri.gsub(/%40/, '@') # TODO: should be removed after new Truemail server release with encoding uri param values
|
46
|
+
end
|
47
|
+
|
37
48
|
def uri
|
38
|
-
@uri ||= URI("#{secure_connection ? 'https' : 'http'}://#{host}:#{port}
|
49
|
+
@uri ||= URI("#{secure_connection ? 'https' : 'http'}://#{host}:#{port}#{request_uri}")
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
data/truemail-client.gemspec
CHANGED
@@ -16,6 +16,14 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = 'https://github.com/truemail-rb/truemail-ruby-client'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
|
+
spec.metadata = {
|
20
|
+
'homepage_uri' => 'https://truemail-rb.org',
|
21
|
+
'changelog_uri' => 'https://github.com/truemail-rb/truemail-ruby-client/blob/master/CHANGELOG.md',
|
22
|
+
'source_code_uri' => 'https://github.com/truemail-rb/truemail-ruby-client',
|
23
|
+
'documentation_uri' => 'https://truemail-rb.org/truemail-ruby-client',
|
24
|
+
'bug_tracker_uri' => 'https://github.com/truemail-rb/truemail-ruby-client/issues'
|
25
|
+
}
|
26
|
+
|
19
27
|
spec.required_ruby_version = '>= 2.5.0'
|
20
28
|
|
21
29
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truemail-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -280,7 +280,12 @@ files:
|
|
280
280
|
homepage: https://github.com/truemail-rb/truemail-ruby-client
|
281
281
|
licenses:
|
282
282
|
- MIT
|
283
|
-
metadata:
|
283
|
+
metadata:
|
284
|
+
homepage_uri: https://truemail-rb.org
|
285
|
+
changelog_uri: https://github.com/truemail-rb/truemail-ruby-client/blob/master/CHANGELOG.md
|
286
|
+
source_code_uri: https://github.com/truemail-rb/truemail-ruby-client
|
287
|
+
documentation_uri: https://truemail-rb.org/truemail-ruby-client
|
288
|
+
bug_tracker_uri: https://github.com/truemail-rb/truemail-ruby-client/issues
|
284
289
|
post_install_message:
|
285
290
|
rdoc_options: []
|
286
291
|
require_paths:
|