mailrelay 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.
- data/lib/mailrelay.rb +4 -0
- data/lib/mailrelay/api.rb +34 -0
- metadata +69 -0
data/lib/mailrelay.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'active_support'
|
|
3
|
+
|
|
4
|
+
module Mailrelay
|
|
5
|
+
class API
|
|
6
|
+
include HTTParty
|
|
7
|
+
|
|
8
|
+
def initialize hostname, api_key
|
|
9
|
+
@hostname = hostname
|
|
10
|
+
@api_key = api_key
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def api_url
|
|
14
|
+
"http://#{@hostname}/ccm/admin/api/version/2/&type=json"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def method_missing(method, *args)
|
|
18
|
+
call(method.to_s, *args)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
def call function, data
|
|
23
|
+
data[:function] = function
|
|
24
|
+
data[:apiKey] = @api_key
|
|
25
|
+
|
|
26
|
+
result = self.class.post api_url, :body => {:data => ActiveSupport::JSON.encode(data)}
|
|
27
|
+
result = ActiveSupport::JSON.decode(result.body)
|
|
28
|
+
|
|
29
|
+
raise 'Call for ' + function + ' failed with the following message: ' + result['error'] if result['status'] == 0
|
|
30
|
+
|
|
31
|
+
return result['data']
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mailrelay
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Fernando Morgenstern
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: active_support
|
|
16
|
+
requirement: &70321651084660 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70321651084660
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: httparty
|
|
27
|
+
requirement: &70321651084200 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *70321651084200
|
|
36
|
+
description: A simple wrapper for Mailrelay's API
|
|
37
|
+
email:
|
|
38
|
+
- fernando@mailrelay.com
|
|
39
|
+
executables: []
|
|
40
|
+
extensions: []
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
files:
|
|
43
|
+
- lib/mailrelay.rb
|
|
44
|
+
- lib/mailrelay/api.rb
|
|
45
|
+
homepage: http://mailrelay.com/
|
|
46
|
+
licenses: []
|
|
47
|
+
post_install_message:
|
|
48
|
+
rdoc_options: []
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ! '>='
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
|
+
none: false
|
|
59
|
+
requirements:
|
|
60
|
+
- - ! '>='
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0'
|
|
63
|
+
requirements: []
|
|
64
|
+
rubyforge_project:
|
|
65
|
+
rubygems_version: 1.8.15
|
|
66
|
+
signing_key:
|
|
67
|
+
specification_version: 3
|
|
68
|
+
summary: Mailrelay API in Ruby
|
|
69
|
+
test_files: []
|