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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 257b2839765515b3873c2b23d3a3b0f73377db5bc2617b328ba87aa346a9190d
4
- data.tar.gz: a16e178d363ef443467072e80b0eb67158aeb657e8b8471cfa703d2063e58762
3
+ metadata.gz: 8ad58d967068df9cddb1cc030cda9564e75decd4c458ad8fa8a2108836dfb4e3
4
+ data.tar.gz: 4b2e7e553835c593da542f9d170d24f9356c0fbd066882a1ce529e81dfe8be06
5
5
  SHA512:
6
- metadata.gz: 86c26c324b44c3a7fbe084f14e535250ed83f664a3914715a489baf5fec64ac219bb33c85890af5f48b4ff67f918bb98a5e1b5f9ea2f766260a5d697326bcef5
7
- data.tar.gz: e6d208ab2b81920a372d13c6f1b2efa1977b9767e355babfd9a6643a893f78dc8ce6b17c588d434a641bf3ac2a4762f7ff3814a5b052772baafd1e2d6e118511
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
- 1. Build the gem using `gem build improvmx.gemspec`
81
- 1. Push it to rubygems `gem push improvmx-x.x.x.gem`
80
+ 2. Build the gem using `gem build improvmx.gemspec`
81
+ 3. Push it to rubygems `gem push improvmx-x.x.x.gem`
@@ -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
- return true
39
+ true
39
40
  end
40
41
  end
41
42
  end
@@ -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.dig(:x_ratelimit_reset) || Time.now.to_i
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
@@ -1,3 +1,3 @@
1
1
  module Improvmx
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
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.3
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: 2021-03-15 00:00:00.000000000 Z
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.14
64
+ rubygems_version: 3.2.33
64
65
  signing_key:
65
66
  specification_version: 4
66
67
  summary: Ruby interface for the ImprovMX API