improvmx 0.1.0 → 0.1.1
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 +17 -3
- data/improvmx.gemspec +1 -1
- data/lib/improvmx.rb +1 -1
- data/lib/improvmx/aliases.rb +8 -9
- data/lib/improvmx/client.rb +1 -35
- data/lib/improvmx/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1beb2bc2f4cde29fb6ad32bf378c9ec8df1e9038e182af63d52cf825b9ef040a
|
4
|
+
data.tar.gz: b94c1f17643079e3b8db5392099d3983780e2a9d2efd31d00e52fe92ae8c3de1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c59717e47ade074c19e188e6e8106d125e2245097851a65347980dfcfda30eab9c25f429242bc53b69b5d32e6d180b60ddcc9e30bd466048b75af36bebb4d672
|
7
|
+
data.tar.gz: 32a7c975cef2ad65c894de582b2b33e15dfc01fd8bb84fe580f149018f606abf7758ef2313985a17c8c8b1841abe97656c86378625a0841bcadba563ada5b147
|
data/README.md
CHANGED
@@ -21,14 +21,28 @@ This is how you can use this gem
|
|
21
21
|
require 'improvmx'
|
22
22
|
|
23
23
|
# Instantiate the Client with your API key and domain
|
24
|
-
client = Improvmx::Client.new 'your-api-key'
|
24
|
+
client = Improvmx::Client.new 'your-api-key'
|
25
25
|
|
26
26
|
# List all the aliases
|
27
|
-
aliases = client.list_aliases
|
27
|
+
aliases = client.list_aliases('domain.com')
|
28
28
|
|
29
29
|
puts aliases['aliases']
|
30
30
|
```
|
31
31
|
|
32
|
+
Improvmx has a rate limit system, to handle this you can do
|
33
|
+
```ruby
|
34
|
+
require 'improvmx'
|
35
|
+
client = Improvmx::Client.new 'your-api-key'
|
36
|
+
|
37
|
+
begin
|
38
|
+
client.list_aliases('domain.com')
|
39
|
+
rescue Improvmx::RateLimitError => e
|
40
|
+
sleep e.wait_seconds
|
41
|
+
retry
|
42
|
+
end
|
43
|
+
|
44
|
+
```
|
45
|
+
|
32
46
|
Rails
|
33
47
|
-----
|
34
48
|
|
@@ -64,4 +78,4 @@ This part is for maintaincers only. In order to deploy this gem to rubygem follo
|
|
64
78
|
|
65
79
|
1. Bump the version in `lib/improvmx/version.rb`
|
66
80
|
1. Build the gem using `gem build improvmx.gemspec`
|
67
|
-
1.
|
81
|
+
1. Push it to rubygems `gem push improvmx-x.x.x.gem`
|
data/improvmx.gemspec
CHANGED
data/lib/improvmx.rb
CHANGED
data/lib/improvmx/aliases.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
module Improvmx
|
2
2
|
# All alias related endpoints
|
3
3
|
module Aliases
|
4
|
-
def list_aliases(params = {})
|
4
|
+
def list_aliases(domain, params = {})
|
5
5
|
get("/domains/#{domain}/aliases/", params).to_h
|
6
6
|
end
|
7
7
|
|
8
|
-
def get_alias(alias_name)
|
8
|
+
def get_alias(alias_name, domain)
|
9
9
|
get("/domains/#{domain}/aliases/#{alias_name}")
|
10
10
|
rescue NotFoundError
|
11
11
|
nil
|
12
12
|
end
|
13
13
|
|
14
|
-
def create_alias(alias_name, forward_to)
|
14
|
+
def create_alias(alias_name, forward_to, domain)
|
15
15
|
response = post("/domains/#{domain}/aliases/", { alias: alias_name, forward: forward(forward_to) })
|
16
16
|
|
17
17
|
response.ok?
|
18
18
|
end
|
19
19
|
|
20
|
-
def update_alias(alias_name, forward_to)
|
20
|
+
def update_alias(alias_name, forward_to, domain)
|
21
21
|
response = put("/domains/#{domain}/aliases/#{alias_name}", { forward: forward(forward_to) })
|
22
22
|
|
23
23
|
response.ok?
|
@@ -25,13 +25,12 @@ module Improvmx
|
|
25
25
|
false
|
26
26
|
end
|
27
27
|
|
28
|
-
def create_or_update_alias(alias_name, forward_to)
|
29
|
-
|
30
|
-
|
31
|
-
update_alias(alias_name, forward_to)
|
28
|
+
def create_or_update_alias(alias_name, forward_to, domain)
|
29
|
+
return true if update_alias(alias_name, forward_to, domain)
|
30
|
+
create_alias(alias_name, forward_to, domain)
|
32
31
|
end
|
33
32
|
|
34
|
-
def delete_alias(alias_name)
|
33
|
+
def delete_alias(alias_name, domain)
|
35
34
|
response = delete("/domains/#{domain}/aliases/#{alias_name}")
|
36
35
|
|
37
36
|
response.ok?
|
data/lib/improvmx/client.rb
CHANGED
@@ -8,7 +8,7 @@ module Improvmx
|
|
8
8
|
include Improvmx::Aliases
|
9
9
|
include Improvmx::Utils
|
10
10
|
|
11
|
-
def initialize(api_key = Improvmx.api_key
|
11
|
+
def initialize(api_key = Improvmx.api_key)
|
12
12
|
rest_client_params = {
|
13
13
|
user: 'api',
|
14
14
|
password: api_key,
|
@@ -16,17 +16,8 @@ module Improvmx
|
|
16
16
|
}
|
17
17
|
|
18
18
|
@http_client = RestClient::Resource.new('https://api.improvmx.com/v3', rest_client_params)
|
19
|
-
@domain = domain
|
20
19
|
end
|
21
20
|
|
22
|
-
# Generic Improvmx POST Handler
|
23
|
-
#
|
24
|
-
# @param [String] resource_path This is the API resource you wish to interact
|
25
|
-
# with. Be sure to include your domain, where necessary.
|
26
|
-
# @param [Hash] data This should be a standard Hash
|
27
|
-
# containing required parameters for the requested resource.
|
28
|
-
# @param [Hash] headers Additional headers to pass to the resource.
|
29
|
-
# @return [Improvmx::Response] A Improvmx::Response object.
|
30
21
|
def post(resource_path, data, headers = {})
|
31
22
|
response = @http_client[resource_path].post(data, headers)
|
32
23
|
Response.new(response)
|
@@ -34,14 +25,6 @@ module Improvmx
|
|
34
25
|
raise communication_error e
|
35
26
|
end
|
36
27
|
|
37
|
-
# Generic Improvmx GET Handler
|
38
|
-
#
|
39
|
-
# @param [String] resource_path This is the API resource you wish to interact
|
40
|
-
# with.
|
41
|
-
# @param [Hash] params This should be a standard Hash
|
42
|
-
# containing required parameters for the requested resource.
|
43
|
-
# @param [String] accept Acceptable Content-Type of the response body.
|
44
|
-
# @return [Improvmx::Response] A Improvmx::Response object.
|
45
28
|
def get(resource_path, params = nil, accept = '*/*')
|
46
29
|
response = @http_client[resource_path].get(params: params, accept: accept)
|
47
30
|
Response.new(response)
|
@@ -49,13 +32,6 @@ module Improvmx
|
|
49
32
|
raise communication_error e
|
50
33
|
end
|
51
34
|
|
52
|
-
# Generic Improvmx PUT Handler
|
53
|
-
#
|
54
|
-
# @param [String] resource_path This is the API resource you wish to interact
|
55
|
-
# with.
|
56
|
-
# @param [Hash] data This should be a standard Hash
|
57
|
-
# containing required parameters for the requested resource.
|
58
|
-
# @return [Improvmx::Response] A Improvmx::Response object.
|
59
35
|
def put(resource_path, data)
|
60
36
|
response = @http_client[resource_path].put(data)
|
61
37
|
Response.new(response)
|
@@ -63,11 +39,6 @@ module Improvmx
|
|
63
39
|
raise communication_error e
|
64
40
|
end
|
65
41
|
|
66
|
-
# Generic Improvmx DELETE Handler
|
67
|
-
#
|
68
|
-
# @param [String] resource_path This is the API resource you wish to interact
|
69
|
-
# with.
|
70
|
-
# @return [Improvmx::Response] A Improvmx::Response object.
|
71
42
|
def delete(resource_path)
|
72
43
|
response = @http_client[resource_path].delete
|
73
44
|
Response.new(response)
|
@@ -75,13 +46,8 @@ module Improvmx
|
|
75
46
|
raise communication_error e
|
76
47
|
end
|
77
48
|
|
78
|
-
attr_reader :domain
|
79
|
-
|
80
49
|
private
|
81
50
|
|
82
|
-
# Raises CommunicationError and stores response in it if present
|
83
|
-
#
|
84
|
-
# @param [StandardException] e upstream exception object
|
85
51
|
def communication_error(e) # rubocop:disable Metrics/AbcSize
|
86
52
|
if e.respond_to? :response
|
87
53
|
code = e.response.code
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C.S.V. Alpha
|
@@ -15,16 +15,16 @@ dependencies:
|
|
15
15
|
name: rest-client
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.0
|
20
|
+
version: '2.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 2.0
|
27
|
+
version: '2.0'
|
28
28
|
description: Ruby interface for the ImprovMX API
|
29
29
|
email: ict@csvalpha.nl
|
30
30
|
executables: []
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
63
|
+
rubygems_version: 3.2.14
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Ruby interface for the ImprovMX API
|