truemail-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ # Contributing to Truemail
2
+
3
+ Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
4
+
5
+ Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
6
+
7
+ ## Using the issue tracker
8
+
9
+ The issue tracker is the preferred channel for [bug reports](#bugs), [features requests](#features) and [submitting pull requests](#pull-requests).
10
+
11
+ <a name="bugs"></a>
12
+ ## Bug/issue reports
13
+
14
+ A bug is a _demonstrable problem_ that is caused by the code in the repository.
15
+ Good bug reports are extremely helpful - thank you!
16
+
17
+ Guidelines for bug reports:
18
+
19
+ 1. **Use the GitHub issue search** &mdash; check if the issue has already been reported
20
+ 2. **Check if the issue has been fixed** &mdash; try to reproduce it using the latest `master` or development branch in the repository
21
+ 3. Truemail [issue template](.github/ISSUE_TEMPLATE.md)
22
+
23
+ A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What would you expect to be the outcome? All these details will help people to fix any potential bugs.
24
+
25
+ <a name="features"></a>
26
+ ## Feature requests
27
+
28
+ Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
29
+
30
+ <a name="pull-requests"></a>
31
+ ## Pull requests
32
+
33
+ Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
34
+
35
+ **Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
36
+
37
+ Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). Not all features proposed will be added but we are open to having a conversation about a feature you are championing.
38
+
39
+ Guidelines for pull requests:
40
+
41
+ 1. Truemail [pull request template](.github/PULL_REQUEST_TEMPLATE.md)
42
+ 2. Fork the repo
43
+ 3. Run the tests. This is to make sure your starting point works. Tests can be run via ```rspec```
44
+ 4. Create a new branch and make your changes. This includes tests for features!
45
+ 5. Push to your fork and submit a pull request
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5
+ gemspec
@@ -0,0 +1,141 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ truemail-client (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.7.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ ast (2.4.0)
12
+ axiom-types (0.1.1)
13
+ descendants_tracker (~> 0.0.4)
14
+ ice_nine (~> 0.11.0)
15
+ thread_safe (~> 0.3, >= 0.3.1)
16
+ bundler-audit (0.6.1)
17
+ bundler (>= 1.2.0, < 3)
18
+ thor (~> 0.18)
19
+ byebug (11.1.1)
20
+ childprocess (3.0.0)
21
+ codeclimate-engine-rb (0.4.1)
22
+ virtus (~> 1.0)
23
+ coderay (1.1.2)
24
+ coercible (1.0.0)
25
+ descendants_tracker (~> 0.0.1)
26
+ colorize (0.8.1)
27
+ crack (0.4.3)
28
+ safe_yaml (~> 1.0.0)
29
+ descendants_tracker (0.0.4)
30
+ thread_safe (~> 0.3, >= 0.3.1)
31
+ diff-lcs (1.3)
32
+ docile (1.3.2)
33
+ equalizer (0.0.11)
34
+ fasterer (0.8.2)
35
+ colorize (~> 0.7)
36
+ ruby_parser (>= 3.14.1)
37
+ ffaker (2.14.0)
38
+ hashdiff (1.0.1)
39
+ ice_nine (0.11.2)
40
+ iniparse (1.5.0)
41
+ jaro_winkler (1.5.4)
42
+ json (2.3.0)
43
+ json_matchers (0.11.1)
44
+ json_schema
45
+ json_schema (0.20.8)
46
+ kwalify (0.7.2)
47
+ method_source (0.9.2)
48
+ overcommit (0.52.1)
49
+ childprocess (>= 0.6.3, < 4)
50
+ iniparse (~> 1.4)
51
+ parallel (1.19.1)
52
+ parser (2.7.0.4)
53
+ ast (~> 2.4.0)
54
+ pry (0.12.2)
55
+ coderay (~> 1.1.0)
56
+ method_source (~> 0.9.0)
57
+ pry-byebug (3.8.0)
58
+ byebug (~> 11.0)
59
+ pry (~> 0.10)
60
+ psych (3.1.0)
61
+ public_suffix (4.0.3)
62
+ rainbow (3.0.0)
63
+ rake (13.0.1)
64
+ reek (5.6.0)
65
+ codeclimate-engine-rb (~> 0.4.0)
66
+ kwalify (~> 0.7.0)
67
+ parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
68
+ psych (~> 3.1.0)
69
+ rainbow (>= 2.0, < 4.0)
70
+ rexml (3.2.4)
71
+ rspec (3.9.0)
72
+ rspec-core (~> 3.9.0)
73
+ rspec-expectations (~> 3.9.0)
74
+ rspec-mocks (~> 3.9.0)
75
+ rspec-core (3.9.1)
76
+ rspec-support (~> 3.9.1)
77
+ rspec-expectations (3.9.0)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.9.0)
80
+ rspec-mocks (3.9.1)
81
+ diff-lcs (>= 1.2.0, < 2.0)
82
+ rspec-support (~> 3.9.0)
83
+ rspec-support (3.9.2)
84
+ rubocop (0.80.1)
85
+ jaro_winkler (~> 1.5.1)
86
+ parallel (~> 1.10)
87
+ parser (>= 2.7.0.1)
88
+ rainbow (>= 2.2.2, < 4.0)
89
+ rexml
90
+ ruby-progressbar (~> 1.7)
91
+ unicode-display_width (>= 1.4.0, < 1.7)
92
+ rubocop-performance (1.5.2)
93
+ rubocop (>= 0.71.0)
94
+ rubocop-rspec (1.38.1)
95
+ rubocop (>= 0.68.1)
96
+ ruby-progressbar (1.10.1)
97
+ ruby_parser (3.14.2)
98
+ sexp_processor (~> 4.9)
99
+ safe_yaml (1.0.5)
100
+ sexp_processor (4.14.1)
101
+ simplecov (0.17.1)
102
+ docile (~> 1.1)
103
+ json (>= 1.8, < 3)
104
+ simplecov-html (~> 0.10.0)
105
+ simplecov-html (0.10.2)
106
+ thor (0.20.3)
107
+ thread_safe (0.3.6)
108
+ unicode-display_width (1.6.1)
109
+ virtus (1.0.5)
110
+ axiom-types (~> 0.1)
111
+ coercible (~> 1.0)
112
+ descendants_tracker (~> 0.0, >= 0.0.3)
113
+ equalizer (~> 0.0, >= 0.0.9)
114
+ webmock (3.8.3)
115
+ addressable (>= 2.3.6)
116
+ crack (>= 0.3.2)
117
+ hashdiff (>= 0.4.0, < 2.0.0)
118
+
119
+ PLATFORMS
120
+ ruby
121
+
122
+ DEPENDENCIES
123
+ bundler (~> 1.16)
124
+ bundler-audit (~> 0.6.1)
125
+ fasterer (~> 0.8.2)
126
+ ffaker (~> 2.14)
127
+ json_matchers (~> 0.11.1)
128
+ overcommit (~> 0.52.1)
129
+ pry-byebug (~> 3.8)
130
+ rake (~> 13.0, >= 13.0.1)
131
+ reek (~> 5.6)
132
+ rspec (~> 3.9)
133
+ rubocop (~> 0.80.1)
134
+ rubocop-performance (~> 1.5, >= 1.5.2)
135
+ rubocop-rspec (~> 1.38, >= 1.38.1)
136
+ simplecov (~> 0.17.1)
137
+ truemail-client!
138
+ webmock (~> 3.8, >= 3.8.3)
139
+
140
+ BUNDLED WITH
141
+ 1.16.6
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Vladislav Trotsenko
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.
@@ -0,0 +1,177 @@
1
+ # <img src='https://repository-images.githubusercontent.com/246571655/128eda80-63af-11ea-8a0e-d1a7b9043c29' height='250' alt='Truemail web API client library for Ruby' />
2
+
3
+
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/ccc7167f4f49d4a10146/maintainability)](https://codeclimate.com/github/truemail-rb/truemail-ruby-client/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/ccc7167f4f49d4a10146/test_coverage)](https://codeclimate.com/github/truemail-rb/truemail-ruby-client/test_coverage) [![CircleCI](https://circleci.com/gh/truemail-rb/truemail-ruby-client/tree/develop.svg?style=svg)](https://circleci.com/gh/truemail-rb/truemail-ruby-client/tree/develop) [![Gem Version](https://badge.fury.io/rb/truemail-client.svg)](https://badge.fury.io/rb/truemail-client) [![Downloads](https://img.shields.io/gem/dt/truemail-client.svg?colorA=004d99&colorB=0073e6)](https://rubygems.org/gems/truemail-client) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
5
+
6
+ `truemail-client` gem - Truemail web API client library for Ruby.
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Setting global configuration](#setting-global-configuration)
13
+ - [Establishing connection with Truemail API](#establishing-connection-with-truemail-api)
14
+ - [Additional features](#additional-features)
15
+ - [Truemail family](#truemail-family)
16
+ - [Contributing](#contributing)
17
+ - [License](#license)
18
+ - [Code of Conduct](#code-of-conduct)
19
+ - [Versioning](#versioning)
20
+ - [Changelog](CHANGELOG.md)
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'truemail-client'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle
33
+
34
+ Or install it yourself as:
35
+
36
+ $ gem install truemail-client
37
+
38
+ ## Usage
39
+
40
+ To have an access for `Truemail::Client` you must configure it first as in the example below:
41
+
42
+
43
+ ### Setting global configuration
44
+
45
+ ```ruby
46
+ require 'truemail/client'
47
+
48
+ Truemail::Client.configure do |config|
49
+ # Optional parameter (Boolean). By default it is equal false
50
+ config.secure_connection = true
51
+
52
+ # Required parameter (String). It should be a hostname or an ip address where Truemail server runs
53
+ config.host = 'example.com'
54
+
55
+ # Optional parameter (Integer). By default it is equal 9292
56
+ config.port = 80
57
+
58
+ # Required parameter (String). It should be valid Truemail server access token
59
+ config.token = 'token'
60
+ end
61
+ ```
62
+
63
+ ### Establishing connection with Truemail API
64
+
65
+ After successful configuration, you can establish connection with Truemail server.
66
+
67
+ ```ruby
68
+ Truemail::Client.validate('admin@bestweb.com.ua')
69
+
70
+ =>
71
+
72
+ {
73
+ "date": "2020-02-26 17:00:56 +0200",
74
+ "email": "admin@bestweb.com.ua",
75
+ "validation_type": "smtp",
76
+ "success": true,
77
+ "errors": null,
78
+ "smtp_debug": null,
79
+ "configuration": {
80
+ "validation_type_by_domain": null,
81
+ "whitelist_validation": false,
82
+ "whitelisted_domains": null,
83
+ "blacklisted_domains": null,
84
+ "smtp_safe_check": false,
85
+ "email_pattern": "default gem value",
86
+ "smtp_error_body_pattern": "default gem value"
87
+ }
88
+ }
89
+ ```
90
+
91
+ `Truemail::Client.validate` always returns JSON data. If something goes wrong you will receive JSON with error details:
92
+
93
+ ```json
94
+ {
95
+ "truemail_client_error": "error details"
96
+ }
97
+ ```
98
+
99
+ ### Additional features
100
+
101
+ #### Read global configuration
102
+
103
+ After successful configuration, you can read current `Truemail::Client` configuration instance anywhere in your application.
104
+
105
+ ```ruby
106
+ Truemail::Client.configuration
107
+
108
+ => #<Truemail::Client::Configuration:0x000055eafc588878
109
+ @host="example.com",
110
+ @port=80,
111
+ @secure_connection=true,
112
+ @token="token">
113
+ ```
114
+
115
+ #### Update global configuration
116
+
117
+ ```ruby
118
+ Truemail::Client.configuration.port = 8080
119
+ => 8080
120
+
121
+ Truemail::Client.configuration
122
+
123
+ => #<Truemail::Client::Configuration:0x000055eafc588878
124
+ @host="example.com",
125
+ @port=8080,
126
+ @secure_connection=true,
127
+ @token="token">
128
+ ```
129
+
130
+ #### Reset global configuration
131
+
132
+ Also you can reset Truemail::Client configuration.
133
+
134
+ ```ruby
135
+ Truemail::Client.reset_configuration!
136
+ => nil
137
+ Truemail::Client.configuration
138
+ => nil
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Truemail family
144
+
145
+ All Truemail extensions: https://github.com/truemail-rb
146
+
147
+ ### truemail
148
+
149
+ gem `truemail` - Configurable plain Ruby email validator, https://github.com/rubygarage/truemail
150
+
151
+ ### truemail server
152
+
153
+ Lightweight rack based web API wrapper for Truemail, https://github.com/truemail-rb/truemail-rack
154
+
155
+ ### truemail-rack-docker-image
156
+
157
+ Lightweight rack based web API [dockerized image](https://hub.docker.com/r/truemail/truemail-rack) :whale: of Truemail server, https://github.com/truemail-rb/truemail-rack-docker-image
158
+
159
+ ### truemail-rspec
160
+
161
+ gem `truemail-rspec` - Truemail configuration and validator RSpec helpers, https://github.com/truemail-rb/truemail-rspec
162
+
163
+ ## Contributing
164
+
165
+ Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tikets](https://github.com/truemail-rb/truemail-ruby-client/issues). Be shure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md).
166
+
167
+ ## License
168
+
169
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
170
+
171
+ ## Code of Conduct
172
+
173
+ Everyone interacting in the `truemail-ruby-client` project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
174
+
175
+ ## Versioning
176
+
177
+ `truemail-ruby-client` uses [Semantic Versioning 2.0.0](https://semver.org)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'truemail/client'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'truemail/client/version'
4
+ require 'truemail/client/configuration'
5
+ require 'truemail/client/http'
6
+
7
+ module Truemail
8
+ module Client
9
+ INCOMPLETE_CONFIG = 'required args not passed'
10
+ NOT_CONFIGURED = 'use Truemail::Client.configure before'
11
+
12
+ class << self
13
+ def configuration(&block)
14
+ @configuration ||= begin
15
+ return unless block_given?
16
+ configuration = Truemail::Client::Configuration.new(&block)
17
+ raise_unless(configuration.complete?, Truemail::Client::INCOMPLETE_CONFIG)
18
+ configuration
19
+ end
20
+ end
21
+
22
+ def configure(&block)
23
+ configuration(&block)
24
+ end
25
+
26
+ def reset_configuration!
27
+ @configuration = nil
28
+ end
29
+
30
+ def validate(email)
31
+ raise_unless(Truemail::Client.configuration, Truemail::Client::NOT_CONFIGURED)
32
+ Truemail::Client::Http.new(email).run
33
+ end
34
+
35
+ private
36
+
37
+ def raise_unless(condition, message)
38
+ raise Truemail::Client::Configuration::Error, message unless condition
39
+ end
40
+ end
41
+ end
42
+ end