improvmx 0.1.3 → 0.1.4
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/README.md +2 -2
- data/lib/improvmx/aliases.rb +2 -1
- data/lib/improvmx/client.rb +8 -3
- data/lib/improvmx/exceptions/exceptions.rb +1 -1
- data/lib/improvmx/smtp.rb +22 -0
- data/lib/improvmx/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad58d967068df9cddb1cc030cda9564e75decd4c458ad8fa8a2108836dfb4e3
|
4
|
+
data.tar.gz: 4b2e7e553835c593da542f9d170d24f9356c0fbd066882a1ce529e81dfe8be06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd69f07344a7dac2b0a472ebd99660829e968a8965654b63bb55733aeb4d80820c4208c2f67d5903485a925e848ed4edc7098149991ff97f4bdb00ea7b53ce30
|
7
|
+
data.tar.gz: 6c79b547a86874f0b801cd9d42b23635fc5cabf95786ca57d2109ddb141267df0db550049ef393eafc907fba8f1c36ae105292d4a75ad230f387877481adeff5
|
data/README.md
CHANGED
@@ -77,5 +77,5 @@ Deployment
|
|
77
77
|
This part is for maintaincers only. In order to deploy this gem to rubygem follow those steps:
|
78
78
|
|
79
79
|
1. Bump the version in `lib/improvmx/version.rb`
|
80
|
-
|
81
|
-
|
80
|
+
2. Build the gem using `gem build improvmx.gemspec`
|
81
|
+
3. Push it to rubygems `gem push improvmx-x.x.x.gem`
|
data/lib/improvmx/aliases.rb
CHANGED
@@ -27,6 +27,7 @@ module Improvmx
|
|
27
27
|
|
28
28
|
def create_or_update_alias(alias_name, forward_to, domain)
|
29
29
|
return true if update_alias(alias_name, forward_to, domain)
|
30
|
+
|
30
31
|
create_alias(alias_name, forward_to, domain)
|
31
32
|
end
|
32
33
|
|
@@ -35,7 +36,7 @@ module Improvmx
|
|
35
36
|
|
36
37
|
response.ok?
|
37
38
|
rescue NotFoundError
|
38
|
-
|
39
|
+
true
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
data/lib/improvmx/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'improvmx/aliases'
|
2
|
+
require 'improvmx/smtp'
|
2
3
|
require 'improvmx/response'
|
3
4
|
require 'improvmx/utils'
|
4
5
|
require 'improvmx/exceptions/exceptions'
|
@@ -6,20 +7,24 @@ require 'improvmx/exceptions/exceptions'
|
|
6
7
|
module Improvmx
|
7
8
|
class Client
|
8
9
|
include Improvmx::Aliases
|
10
|
+
include Improvmx::SMTP
|
9
11
|
include Improvmx::Utils
|
10
12
|
|
11
13
|
def initialize(api_key = Improvmx.api_key)
|
12
14
|
rest_client_params = {
|
13
15
|
user: 'api',
|
14
16
|
password: api_key,
|
15
|
-
user_agent: "improvmx-ruby/#{Improvmx::VERSION}"
|
17
|
+
user_agent: "improvmx-ruby/#{Improvmx::VERSION}",
|
18
|
+
headers: {
|
19
|
+
content_type: "application/json"
|
20
|
+
}
|
16
21
|
}
|
17
22
|
|
18
23
|
@http_client = RestClient::Resource.new('https://api.improvmx.com/v3', rest_client_params)
|
19
24
|
end
|
20
25
|
|
21
26
|
def post(resource_path, data, headers = {})
|
22
|
-
response = @http_client[resource_path].post(data, headers)
|
27
|
+
response = @http_client[resource_path].post(data.to_json, headers)
|
23
28
|
Response.new(response)
|
24
29
|
rescue StandardError => e
|
25
30
|
raise communication_error e
|
@@ -33,7 +38,7 @@ module Improvmx
|
|
33
38
|
end
|
34
39
|
|
35
40
|
def put(resource_path, data)
|
36
|
-
response = @http_client[resource_path].put(data)
|
41
|
+
response = @http_client[resource_path].put(data.to_json)
|
37
42
|
Response.new(response)
|
38
43
|
rescue StandardError => e
|
39
44
|
raise communication_error e
|
@@ -53,7 +53,7 @@ module Improvmx
|
|
53
53
|
super(message, response)
|
54
54
|
|
55
55
|
if response
|
56
|
-
reset_at = response.headers
|
56
|
+
reset_at = response.headers[:x_ratelimit_reset] || Time.now.to_i
|
57
57
|
@wait_seconds = reset_at.to_i - Time.now.to_i
|
58
58
|
else
|
59
59
|
@wait_seconds = 0
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Improvmx
|
2
|
+
# All SMTP related endpoints
|
3
|
+
module SMTP
|
4
|
+
def list_smtp(domain, params = {})
|
5
|
+
get("/domains/#{domain}/credentials/", params).to_h
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_smtp(username, password, domain)
|
9
|
+
response = post("/domains/#{domain}/credentials/", { username: username, password: password })
|
10
|
+
|
11
|
+
response.ok?
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete_smtp(username, domain)
|
15
|
+
response = delete("/domains/#{domain}/credentials/#{username}")
|
16
|
+
|
17
|
+
response.ok?
|
18
|
+
rescue NotFoundError
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/improvmx/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: improvmx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C.S.V. Alpha
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/improvmx/client.rb
|
40
40
|
- lib/improvmx/exceptions/exceptions.rb
|
41
41
|
- lib/improvmx/response.rb
|
42
|
+
- lib/improvmx/smtp.rb
|
42
43
|
- lib/improvmx/utils.rb
|
43
44
|
- lib/improvmx/version.rb
|
44
45
|
homepage: https://improvmx.com
|
@@ -60,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '0'
|
62
63
|
requirements: []
|
63
|
-
rubygems_version: 3.2.
|
64
|
+
rubygems_version: 3.2.33
|
64
65
|
signing_key:
|
65
66
|
specification_version: 4
|
66
67
|
summary: Ruby interface for the ImprovMX API
|