oma 0.0.1 → 0.0.2
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/opensrs/oma.rb +22 -61
- metadata +35 -10
data/lib/opensrs/oma.rb
CHANGED
|
@@ -11,12 +11,14 @@ module OpenSRS
|
|
|
11
11
|
@base = url
|
|
12
12
|
@creds = creds
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
def uri ( method = '' )
|
|
16
|
+
URI.parse( @base )
|
|
17
|
+
end
|
|
14
18
|
|
|
15
19
|
def request(method, params = {})
|
|
16
20
|
params["credentials"] = @creds
|
|
17
21
|
|
|
18
|
-
uri = URI.parse( @base + "/" + method.to_s)
|
|
19
|
-
|
|
20
22
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
21
23
|
http.use_ssl = true
|
|
22
24
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
@@ -39,13 +41,14 @@ module OpenSRS
|
|
|
39
41
|
if response["error"] =~ /Invalid credentials supplied in request/
|
|
40
42
|
raise InvalidCredentials, response["error"]
|
|
41
43
|
end
|
|
44
|
+
raise Exception, response["error"]
|
|
42
45
|
end
|
|
43
46
|
response
|
|
44
47
|
end
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
class OMA < JsonRPC::Client
|
|
48
|
-
VERSION = '0.
|
|
51
|
+
VERSION = '0.0.2'
|
|
49
52
|
|
|
50
53
|
include ErrorHandler
|
|
51
54
|
|
|
@@ -55,79 +58,37 @@ module OpenSRS
|
|
|
55
58
|
attr_reader :methods
|
|
56
59
|
|
|
57
60
|
def initialize( opt={} )
|
|
58
|
-
OMA.create_methods
|
|
59
|
-
@methods = METHODS
|
|
61
|
+
#OMA.create_methods
|
|
60
62
|
|
|
61
63
|
@username = opt[:username] || ''
|
|
62
64
|
@password = opt[:password] || ''
|
|
63
65
|
|
|
64
66
|
@url = opt[:url] || 'https://admin.a.hostedemail.com/api'
|
|
65
|
-
@credentials = { :client => "Ruby OpenSRS::OMA 0.
|
|
67
|
+
@credentials = { :client => "Ruby OpenSRS::OMA 0.0.2", :user => @username, :password => @password }
|
|
66
68
|
super( @url, @credentials )
|
|
67
69
|
end
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
change_domain_bulletin
|
|
76
|
-
change_user
|
|
77
|
-
change_brand
|
|
78
|
-
create_workgroup
|
|
79
|
-
delete_company
|
|
80
|
-
delete_domain
|
|
81
|
-
delete_user
|
|
82
|
-
delete_workgroup
|
|
83
|
-
echo
|
|
84
|
-
generate_token
|
|
85
|
-
get_company
|
|
86
|
-
get_company_bulletin
|
|
87
|
-
get_company_changes
|
|
88
|
-
get_deleted_contacts
|
|
89
|
-
get_deleted_messages
|
|
90
|
-
get_domain
|
|
91
|
-
get_domain_bulletin
|
|
92
|
-
get_domain_changes
|
|
93
|
-
get_user
|
|
94
|
-
get_user_attribute_history
|
|
95
|
-
get_user_changes
|
|
96
|
-
get_user_messages
|
|
97
|
-
get_valid_languages
|
|
98
|
-
get_valid_timezones
|
|
99
|
-
migration_add
|
|
100
|
-
migration_jobs
|
|
101
|
-
migration_status
|
|
102
|
-
migration_threads
|
|
103
|
-
migration_trace
|
|
104
|
-
move_user_messages
|
|
105
|
-
post_domain_bulletin
|
|
106
|
-
post_company_bulletin
|
|
107
|
-
remove_role
|
|
108
|
-
rename_user
|
|
109
|
-
restore_deleted_contacts
|
|
110
|
-
restore_deleted_messages
|
|
111
|
-
restore_domain
|
|
112
|
-
restore_user
|
|
113
|
-
search_brand_members
|
|
114
|
-
search_brands
|
|
115
|
-
search_companies
|
|
116
|
-
search_domains
|
|
117
|
-
search_users
|
|
118
|
-
search_workgroups
|
|
119
|
-
set_role
|
|
120
|
-
stats_summary
|
|
121
|
-
stats_list
|
|
122
|
-
stats_snapshot )
|
|
70
|
+
|
|
71
|
+
def uri ( method = @method )
|
|
72
|
+
URI.parse( @base + "/" + method.to_s)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# removed, in favour of metaprogramming
|
|
76
|
+
METHODS = %w( )
|
|
123
77
|
|
|
78
|
+
# This method is deprecated..
|
|
124
79
|
def self.create_methods
|
|
125
80
|
METHODS.each do |method|
|
|
126
81
|
define_method method do |*argv|
|
|
82
|
+
@method = method
|
|
127
83
|
valid?( request method, *argv )
|
|
128
84
|
end
|
|
129
85
|
end
|
|
130
86
|
end
|
|
87
|
+
|
|
88
|
+
def method_missing( m, *args, &block )
|
|
89
|
+
@method = m
|
|
90
|
+
request( m, *args )
|
|
91
|
+
end
|
|
131
92
|
end
|
|
132
93
|
end
|
|
133
94
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oma
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 27
|
|
5
|
+
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.0.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Peter Blair
|
|
@@ -15,10 +15,36 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
date: 2012-09-27 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: addressable
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 3
|
|
29
|
+
segments:
|
|
30
|
+
- 0
|
|
31
|
+
version: "0"
|
|
32
|
+
type: :runtime
|
|
33
|
+
version_requirements: *id001
|
|
34
|
+
- !ruby/object:Gem::Dependency
|
|
35
|
+
name: json
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
hash: 3
|
|
43
|
+
segments:
|
|
44
|
+
- 0
|
|
45
|
+
version: "0"
|
|
46
|
+
type: :runtime
|
|
47
|
+
version_requirements: *id002
|
|
22
48
|
description: Communicate with OpenSRS' Email Platform using the OMA protocol
|
|
23
49
|
email: petermblair@gmail.com
|
|
24
50
|
executables: []
|
|
@@ -29,7 +55,6 @@ extra_rdoc_files: []
|
|
|
29
55
|
|
|
30
56
|
files:
|
|
31
57
|
- lib/opensrs/oma.rb
|
|
32
|
-
has_rdoc: true
|
|
33
58
|
homepage: http://rubygems.org/gems/oma
|
|
34
59
|
licenses: []
|
|
35
60
|
|
|
@@ -59,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
59
84
|
requirements: []
|
|
60
85
|
|
|
61
86
|
rubyforge_project:
|
|
62
|
-
rubygems_version: 1.
|
|
87
|
+
rubygems_version: 1.7.2
|
|
63
88
|
signing_key:
|
|
64
89
|
specification_version: 3
|
|
65
90
|
summary: OpenSRS's OMA Ruby client library
|