cps-client 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ doc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cps-client.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cps-client (0.1.0)
5
+ always_verify_ssl_certificates (>= 0.2.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ always_verify_ssl_certificates (0.2.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ always_verify_ssl_certificates (>= 0.2.0)
17
+ cps-client!
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/Readme.textile ADDED
@@ -0,0 +1,76 @@
1
+ h1. CPS-CLIENT
2
+
3
+ Ruby api for the arp-client of cps-datensysteme.de
4
+
5
+ h2. Installation
6
+
7
+ <pre><code>sudo gem install cps-client
8
+ bundle # to install dependencies</code></pre>
9
+
10
+ h2. Howto register a domain
11
+
12
+ Create a cps-client object:
13
+
14
+ <pre><code>server = CPS::Client.new(
15
+ :cid => 'your-cid',
16
+ :uid => 'your-uid',
17
+ :pwd => 'your-pwd',
18
+ :production => false # for development
19
+ )</code></pre>
20
+
21
+ Create a client contact handle:
22
+
23
+ <pre><code>client_contact = CPS::Contact.new(
24
+ :object => 'QD1234',
25
+ :firstname => 'Peter',
26
+ :lastname => 'Pan',
27
+ :street => 'your-street',
28
+ :postal => '60000',
29
+ :city => 'Frankfurt am Main',
30
+ :state => 'Hessen',
31
+ :iso_country => 'DE',
32
+ :phone => '+49 69471117',
33
+ :fax => '+49 69471118',
34
+ :email => 'peter.pan@example.com'
35
+ )
36
+
37
+ server.query(client_contact.create)</code></pre>
38
+
39
+ Create your company contact handle:
40
+
41
+ <pre><code>company_contact = CPS::Contact.new(
42
+ :object => 'QD0001',
43
+ :firstname => 'Paulär',
44
+ :lastname => 'Panter',
45
+ :street => 'my-street',
46
+ :postal => '60000',
47
+ :city => 'Frankfurt am Main',
48
+ :state => 'Hessen',
49
+ :iso_country => 'DE',
50
+ :phone => '+49 69471123',
51
+ :fax => '+49 69471124',
52
+ :email => 'paulaer.panter@example.com'
53
+ )
54
+
55
+ server.query(company_contact.create)</code></pre>
56
+
57
+ Register the domain:
58
+
59
+ <pre><code>domain = CPS::Domain.new(
60
+ :domain => 'example-domain-123456.com',
61
+ :adminc => 'QD1234',
62
+ :ownerc => 'QD1234',
63
+ :techc => 'QD0001',
64
+ :billc => 'QD0001',
65
+ :ns1 => 'my1.dns.com',
66
+ :ns2 => 'my2.dns.com'
67
+ )
68
+
69
+ server.query(domain.create)</code></pre>
70
+
71
+ h2. Todo
72
+
73
+ - Add validation and error handling
74
+ - Add modify and transfer for domains
75
+
76
+ (c) 2011 jfqd [at] blun.org
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cps-client/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "cps-client"
7
+ s.version = CPS::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["jfqd"]
10
+ s.email = ["jfqd@blun.org"]
11
+ s.homepage = "https://github.com/jfqd/cps-client"
12
+ s.summary = %q{ruby api for the arp-client of cps-datensysteme.de}
13
+ s.description = %q{ruby api for the arp-client of cps-datensysteme.de}
14
+
15
+ s.add_dependency('always_verify_ssl_certificates', '>= 0.2.0')
16
+
17
+ s.rubyforge_project = "cps-client"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
data/lib/core_ext.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'iconv'
2
+
3
+ class String
4
+
5
+ CONVERTION_TABLE = {
6
+ 'Ç' => 'C',
7
+ 'ç' => 'c',
8
+ '[ûúù]' => 'u',
9
+ '[éêëè]' => 'e',
10
+ '[âàåá]' => 'a',
11
+ '[ïîìí]' => 'i',
12
+ '[Å]' => 'A',
13
+ 'É' => 'E',
14
+ 'æ' => 'ae',
15
+ 'Æ' => 'Ae',
16
+ '[ôòó]' => 'o',
17
+ 'Ä' => 'Ae',
18
+ 'Ö' => 'Oe',
19
+ 'Ü' => 'Ue',
20
+ 'ä' => 'ae',
21
+ 'ö' => 'oe',
22
+ 'ü' => 'ue',
23
+ 'ß' => 'ss',
24
+ 'ÿ' => 'y',
25
+ 'Ö' => 'O',
26
+ 'ñ' => 'n',
27
+ 'Ñ' => 'N'
28
+ }
29
+
30
+ def i18n_safe
31
+ s = self
32
+ return "" unless s
33
+ CONVERTION_TABLE.each do |key, value|
34
+ s = s.gsub(key, value)
35
+ end
36
+ return s
37
+ end
38
+
39
+ def convert_to_iso_8859_1
40
+ begin
41
+ i = Iconv.new('ISO-8859-1', 'UTF-8') # Iconv.new(to, from)
42
+ f = i.iconv(self.i18n_safe)
43
+ i.close
44
+ return f
45
+ rescue
46
+ i.close
47
+ self
48
+ end
49
+ end
50
+
51
+ def blank?
52
+ self.nil? || self == ""
53
+ end
54
+
55
+ end
data/lib/cps-client.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'cps-client/version'
2
+ require 'cps-client/errors'
3
+ require 'cps-client/config'
4
+ require 'cps-client/erb_helper'
5
+ require 'cps-client/client'
6
+ require 'cps-client/contact'
7
+ require 'cps-client/domain'
8
+ require 'core_ext'
@@ -0,0 +1,102 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+ require 'rexml/document'
4
+ require 'always_verify_ssl_certificates'
5
+
6
+ module CPS
7
+
8
+ class Client
9
+ include REXML
10
+
11
+ # The Integer maximum time to run a cps query, expressed in seconds.
12
+ DEFAULT_TIMEOUT = 10
13
+
14
+ # Initializes a new <tt>Cps::Client</tt> with <tt>options</tt>.
15
+ #
16
+ # new(options = {})
17
+ #
18
+ # ==== Parameters
19
+ #
20
+ # options:: Hash of options:
21
+ # :timeout - The Integer script timeout, expressed in seconds (default: DEFAULT_TIMEOUT).
22
+ # :cid - Customer number
23
+ # :uid - User
24
+ # :pwd - Password
25
+ #
26
+ # If <tt>block</tt> is given, yields <tt>self</tt>.
27
+ #
28
+ # ==== Returns
29
+ #
30
+ # Cps::Client:: The client instance.
31
+ #
32
+ # ==== Examples
33
+ #
34
+ # client = Cps::Client.new do |c|
35
+ # c.timeout = nil
36
+ # end
37
+ # client.query("google.com")
38
+ #
39
+ def initialize(options = {})
40
+ @cid = options[:cid]
41
+ @uid = options[:uid]
42
+ @pwd = options[:pwd]
43
+
44
+ @production = options[:production] == false ? false : true
45
+
46
+ @timeout = options[:timeout] || DEFAULT_TIMEOUT
47
+ @request = ""
48
+ @response = ""
49
+ @data = ""
50
+ end
51
+
52
+ def query( object )
53
+ # AlwaysVerifySSLCertificates.ca_file = CA_FILE
54
+ url = @production == true ? URL : URL_DEV
55
+ uri = URI.parse("#{PROTO}://#{url}:#{PORT}")
56
+ @request = self.template(object)
57
+
58
+ begin
59
+ http = Net::HTTP.new(uri.host, uri.port)
60
+ http.use_ssl = true if PROTO == 'https'
61
+ req = Net::HTTP::Post.new( PATH )
62
+ @response, @data = http.request(req, @request)
63
+ self.result_code == '1000' ? true : false
64
+ rescue
65
+ false
66
+ end
67
+
68
+ end
69
+
70
+ def data
71
+ @data.to_s
72
+ end
73
+
74
+ def request
75
+ @request.to_s
76
+ end
77
+
78
+ def entity(path)
79
+ d = Document.new(@data)
80
+ d.root.elements[path].text rescue ""
81
+ end
82
+
83
+ def result_code
84
+ self.entity('/response/result/code')
85
+ end
86
+
87
+ def result_message
88
+ self.entity('/response/result/message')
89
+ end
90
+
91
+ def template(xml)
92
+ @xml = xml
93
+ ErbHelper.build("base", self)
94
+ end
95
+
96
+ def get_binding
97
+ binding
98
+ end
99
+
100
+ end
101
+
102
+ end
@@ -0,0 +1,10 @@
1
+ module CPS
2
+
3
+ PROTO = 'https'
4
+ URL = 'arpgate.cps-datensysteme.de'
5
+ URL_DEV = 'arpote.cps-datensysteme.de'
6
+ PORT = 700
7
+ PATH = '/'
8
+ CA_FILE = "/path/path/path/cacert.pem" # coming later
9
+
10
+ end
@@ -0,0 +1,48 @@
1
+ require 'erb'
2
+
3
+ module CPS
4
+
5
+ class Contact
6
+ attr_reader :object
7
+
8
+ def initialize(options = {})
9
+ @object = options[:object].upcase
10
+ @firstname = options[:firstname]
11
+ @lastname = options[:lastname]
12
+ @orgname = options[:orgname].nil? || options[:orgname] == "" ? "-" : options[:orgname]
13
+ @street = options[:street]
14
+ @postal = options[:postal]
15
+ @city = options[:city]
16
+ @state = options[:state]
17
+ @iso_country = options[:iso_country]
18
+ @phone = options[:phone]
19
+ @fax = options[:fax]
20
+ @email = options[:email]
21
+ @privacy_rule = options[:privacy_rule] || ""
22
+ @contact_type = @orgname == '-' ? "person" : "organisation"
23
+ end
24
+
25
+ def info
26
+ ErbHelper.build("contact_info", self)
27
+ end
28
+
29
+ def create
30
+ ErbHelper.build("contact_create", self)
31
+ end
32
+
33
+ def delete
34
+ ErbHelper.build("contact_delete", self)
35
+ end
36
+
37
+ def domain
38
+ ErbHelper.build("contact_domain", self)
39
+ end
40
+
41
+ # this is only a helper method to access the objects binding method
42
+ def get_binding
43
+ binding
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,35 @@
1
+ module CPS
2
+
3
+ class Domain
4
+ attr_reader :domain
5
+
6
+ def initialize(options = {})
7
+ @domain = options[:domain]
8
+ @adminc = options[:adminc]
9
+ @techc = options[:techc]
10
+ @billc = options[:billc]
11
+ @ownerc = options[:ownerc]
12
+ @ns1 = options[:ns1]
13
+ @ns2 = options[:ns2]
14
+ end
15
+
16
+ def create
17
+ ErbHelper.build("domain_create", self)
18
+ end
19
+
20
+ def info
21
+ ErbHelper.build("domain_info", self)
22
+ end
23
+
24
+ def delete
25
+ ErbHelper.build("domain_delete", self)
26
+ end
27
+
28
+ # this is only a helper method to access the objects binding method
29
+ def get_binding
30
+ binding
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,11 @@
1
+ require 'erb'
2
+
3
+ module CPS
4
+ class ErbHelper
5
+ def self.build(file, _class)
6
+ path = File.dirname(__FILE__) + "/../erb/#{file}.erb"
7
+ rhtml = ERB.new(File.read(path))
8
+ rhtml.result(_class.get_binding)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,267 @@
1
+ module CPS
2
+
3
+ class Errors
4
+ ERRORS = {
5
+ '1000' => 'Action was successfully completed.',
6
+ '1001' => 'Action was successfully transfered to the sub system. A status update will follow soon.',
7
+ '1002' => 'Change of status received - a further status update will follow soon.',
8
+ '1003' => 'Transaction was started.',
9
+ '5000' => 'The primary DNS answered with an error.',
10
+ '5001' => 'The secondary DNS answered with an error.',
11
+ '5002' => 'Delivery of SMS failed.',
12
+ '5003' => 'The SSL order could not be started.',
13
+ '5004' => 'Registration of domain failed.',
14
+ '5005' => 'Update of domain failed.',
15
+ '5006' => 'Deletion of domain failed.',
16
+ '5007' => 'Status update of Domain failed.',
17
+ '5008' => 'Transfer of domain could not be carried out.',
18
+ '5009' => 'Transfer of domain failed.',
19
+ '5010' => 'Restoration of domain failed.',
20
+ '5011' => 'A handle could not be created by the NIC. The action failed.',
21
+ '5012' => 'A transfer-out-request was refused (NACK) because the domain is in TRANSFER-LOCK.',
22
+ '5013' => 'The migration of the domain/zone failed.',
23
+ '5014' => 'The SSL order was canceled.',
24
+ '5015' => 'Return of payment responsibility (changeover) failed.',
25
+ '5016' => 'A transfer-out-request was denied (NACK) because the assignee has refused it (CLIENT-LOCK).',
26
+ '5017' => 'Registration of hostname failed.',
27
+ '5018' => 'Update of hostname failed.',
28
+ '5019' => 'A transfer-out-request was cancelled (CANCEL).',
29
+ '6000' => 'IP is already in use.',
30
+ '6001' => 'Found an active transaction for the demanded object.',
31
+ '6002' => 'No active transaction found.',
32
+ '6003' => 'No pricing information or active duty found.',
33
+ '6004' => 'No active fees (onhold) found.',
34
+ '6005' => 'Transactions dismatch.',
35
+ '6006' => 'IP is not available.',
36
+ '6007' => 'Demanded User.',
37
+ '6008' => 'Remote command failed.',
38
+ '6009' => 'The execution of the interleaved order CREATE USER caused an error.',
39
+ '6010' => 'Demanded Contact does not exist or the active user does not own the rights to access the handle.',
40
+ '6011' => 'The execution of the interleaved order CREATE CONTACT caused an error.',
41
+ '6012' => 'The contact handle already exists.',
42
+ '6013' => 'The contact handle is in use and cannot be deleted.',
43
+ '6014' => 'The user already exists.',
44
+ '6015' => 'Notification notice-by-recall requires an URL.',
45
+ '6016' => 'Notification notice-by-email requires a target email address.',
46
+ '6017' => 'The user is in use and cannot be deleted.',
47
+ '6018' => 'The application data dismatches the registrary conditions of the responsible registry.',
48
+ '6019' => 'The option chosen for this application is invalid.',
49
+ '6020' => 'The key words are missing in the meta tags of the desired homepage.',
50
+ '6021' => 'The order could not be transfered.',
51
+ '6022' => 'You reached or overstepped your credit limit.',
52
+ '6023' => 'Sending SMS failed.',
53
+ '6024' => 'This zone already exists.',
54
+ '6025' => 'Zone limit reached.',
55
+ '6026' => 'The zone does not exist, the user has no right to access the zone or a wrong product type (attribute) was chosen.',
56
+ '6027' => 'The ACE string seems to be invalid.',
57
+ '6028' => 'The CSR seems to be wrong and could not be parsed.',
58
+ '6029' => 'The common name does not seem to be a correct domain name.',
59
+ '6030' => 'A server for matching data could not be reached (technical or authentication error).',
60
+ '6031' => 'Common name from CSR does not fit the domain in the objectfield.',
61
+ '6032' => 'Wrong certificate type chosen - does not fit to CSR/CN or SAN.',
62
+ '6033' => 'The approver emailaddress does not seem to be usable by CA.',
63
+ '6034' => 'The domain exists and is already managed by the registrar.',
64
+ '6035' => 'The domain already exists.',
65
+ '6036' => 'The domain is not administrated by the demanding user or does not exist.',
66
+ '6037' => 'The domain is not be administrated by the registrar and does not exist.',
67
+ '6038' => 'The domain already exists in the demanding account.',
68
+ '6039' => 'The AUTH-INFO is invalid.',
69
+ '6040' => 'The domain does not exist.',
70
+ '6041' => 'The domain is not administrated by the user or is located in the "Restriction Period".',
71
+ '6042' => 'The host is already subscribed.',
72
+ '6043' => 'The hostname does not base on the root domain.',
73
+ '6044' => 'The host is not be administrated by the demanding user and does not exist.',
74
+ '6045' => 'The check of your nameserver configuration caused an error.',
75
+ '6046' => 'NSENTRY details are missing.',
76
+ '6047' => 'A LATEACK can only be executed together with an UN-LOCK.',
77
+ '6048' => 'The owner-C (values::ownerc) does not match the actual domain holder.',
78
+ '6049' => 'The data of owner-C (values::ownerc) or admin-C (values::adminc) dismatch the registrary conditions of the responsible registry.',
79
+ '6050' => 'No information found for demanded object.',
80
+ '6051' => 'The domain is not administrated by the user or is located in the "Expire Threshold Period" / "Auto Renew Period".',
81
+ '6052' => 'The transaction was denied by the assignee.',
82
+ '6053' => 'Starting authorisation of transaction failed.',
83
+ '6054' => 'Too many active connections to the sub-system.',
84
+ '6055' => 'The query results in too many data records.',
85
+ '6056' => 'The object\'s data could not be synchronized with the order cache.',
86
+ '6057' => 'Domain status prohibits this operation.',
87
+ '6058' => 'Hostname status prohibits this operation.',
88
+ '6059' => 'SSL Certificate status prohibits this operation.',
89
+ '6060' => 'Access to this domain is restricted.',
90
+ '6061' => 'The zone does not exist.',
91
+ '6062' => 'The zone already exists in the demanding account.',
92
+ '6063' => 'The data of the CSR do not meet the requirements of the CA.',
93
+ '7000' => 'The customer number ist invalid.',
94
+ '7001' => 'The username is invalid.',
95
+ '7002' => 'The password is invalid.',
96
+ '7003' => 'The object goup is invalid.',
97
+ '7004' => 'The reference number is invalid.',
98
+ '7005' => 'The chosen action is invalid.',
99
+ '7006' => 'The chosen attribute is invalid.',
100
+ '7007' => 'The insert IP is invalid.',
101
+ '7008' => 'The field request_action is invalid.',
102
+ '7009' => 'The field values::servicepwd is incorrect.',
103
+ '7010' => 'The field values::street is incorrect.',
104
+ '7011' => 'The field values::billc is incorrect.',
105
+ '7012' => 'The field values::techc is incorrect.',
106
+ '7013' => 'The field values::servicepwd is incorrect.',
107
+ '7014' => 'The field values::iso_country is incorrect.',
108
+ '7015' => 'The field values::lang is incorrect.',
109
+ '7016' => 'The field values::adminc is incorrect.',
110
+ '7017' => 'The field values::super_user is incorrect.',
111
+ '7018' => 'The field values::postal is incorrect.',
112
+ '7019' => 'The field values::city is incorrect.',
113
+ '7020' => 'The field first name of admin-c is invalid.',
114
+ '7021' => 'The field last name of admin-c is invalid.',
115
+ '7022' => 'The field first name of bill-c is invalid.',
116
+ '7023' => 'The field first name of tech-c is invalid.',
117
+ '7024' => 'The field last name of bill-c is invalid.',
118
+ '7025' => 'The field last name of tech-c is invalid.',
119
+ '7026' => 'The field values::user is invalid.',
120
+ '7027' => 'The time format of field values::begin is invalid.',
121
+ '7028' => 'The time format of field values::end is invalid.',
122
+ '7029' => 'The field values::firstname is incorrect.',
123
+ '7030' => 'The field values::lastname is incorrect.',
124
+ '7031' => 'The field values::orgname is incorrect.',
125
+ '7032' => 'The field values::street is incorrect.',
126
+ '7033' => 'The field values::postal is incorrect.',
127
+ '7034' => 'The field values::city is incorrect.',
128
+ '7035' => 'The field values::state is incorrect.',
129
+ '7036' => 'The field values::iso_country is incorrect.',
130
+ '7037' => 'The field values::phone is incorrect.',
131
+ '7038' => 'The field values::fax is incorrect.',
132
+ '7039' => 'The field values::email is incorrect.',
133
+ '7040' => 'The chosen user status is invalid.',
134
+ '7041' => 'The chosen password is invalid.',
135
+ '7042' => 'The chosen option for the notification notice-by-poll is invalid.',
136
+ '7043' => 'The chosen option for the notification notice-by-recall is invalid.',
137
+ '7044' => 'The chosen option for the notification notice-by-email is invalid.',
138
+ '7045' => 'The chosen recall URL is invalid.',
139
+ '7046' => 'The sender email address is invalid.',
140
+ '7047' => 'The receiver email address is invalid.',
141
+ '7048' => 'The field values::object is incorrect.',
142
+ '7049' => 'The user rights for the range account are invalid.',
143
+ '7050' => 'The user rights for the range user are invalid.',
144
+ '7051' => 'The user rights for the range contact are invalid.',
145
+ '7052' => 'The user rights for the range domain are invalid.',
146
+ '7053' => 'The user rights for the range DNS are invalid.',
147
+ '7054' => 'The user rights for the range SSL-Cert are invalid.',
148
+ '7055' => 'The user rights for the range SMS are invalid.',
149
+ '7056' => 'The user rights for the range submit are invalid.',
150
+ '7057' => 'The chosen contact is invalid.',
151
+ '7058' => 'Der user name in the object field is invalid.',
152
+ '7059' => 'The chosen domain name is invalid.',
153
+ '7060' => 'The field values::group is invalid.',
154
+ '7061' => 'The field values::account_invoice_num is invalid.',
155
+ '7062' => 'The field values::view is invalid.',
156
+ '7063' => 'The target number in the object field is invalid.',
157
+ '7064' => 'The field enable_flash can only be yes or no.',
158
+ '7065' => 'The field sender_id can only consist of 11 alpha numeric characters or 16 numeric characters.',
159
+ '7066' => 'The field message_text is incorrect.',
160
+ '7067' => 'One of the NS record fiels is invalid.',
161
+ '7068' => 'The domain in the object field is invalid.',
162
+ '7069' => 'One of the MX record fields is invalid.',
163
+ '7070' => 'One of the TXT records is invalid.',
164
+ '7071' => 'One of the CNAME record fields is invalid.',
165
+ '7072' => 'One of the A record fields is incorrect.',
166
+ '7073' => 'The master IP is invalid.',
167
+ '7074' => 'The field values::domain is invalid.',
168
+ '7075' => 'The field vaules::native_domain is invalid.',
169
+ '7076' => 'The CSR is incorrect.',
170
+ '7077' => 'The approver email is invalid.',
171
+ '7078' => 'The certificate type is invalid.',
172
+ '7079' => 'The field values::common_name is invalid.',
173
+ '7080' => 'The field values::status is invalid.',
174
+ '7081' => 'The field values::expire_end is invalid.',
175
+ '7082' => 'The field values::expire_begin is invalid.',
176
+ '7083' => 'The field values::sslcert_type is invalid.',
177
+ '7084' => 'The field values::object_id is invalid.',
178
+ '7085' => 'The desired action / the demanded product are not available.',
179
+ '7086' => 'One of the DNS host names is invalid.',
180
+ '7087' => 'One of the DNS host IPs is invalid.',
181
+ '7088' => 'The field values::ownerc is incorrect.',
182
+ '7089' => 'The field values::ownerc::lastname is incorrect.',
183
+ '7090' => 'The field values::ownerc::firstname is incorrect.',
184
+ '7091' => 'The field values::active is incorrect.',
185
+ '7092' => 'The field values::auth_info is incorrect.',
186
+ '7093' => 'The host name in the Object field is invalid.',
187
+ '7094' => 'The root domain (values::parent_domain) is invalid.',
188
+ '7095' => 'The IP (values::ip) is invalid.',
189
+ '7096' => 'The field values::auto_renew is invalid.',
190
+ '7097' => 'The field values::transfer_lock is invalid.',
191
+ '7098' => 'The field values::hostname is invalid.',
192
+ '7099' => 'One of the NSENTRY fields is invalid.',
193
+ '7100' => 'The option values::denic_lateack is incorrect.',
194
+ '7101' => 'The AUTH-CODE is invalid.',
195
+ '7102' => 'Error in the additional declaration REG-number.',
196
+ '7103' => 'Error the additional declaration REG-type.',
197
+ '7104' => 'Error the additional declaration REG-date.',
198
+ '7105' => 'Error the additional declaration REG-location.',
199
+ '7106' => 'Error the additional declaration REG-AUTH.',
200
+ '7107' => 'The field values::attribute is invalid.',
201
+ '7108' => 'The field values::action is invalid.',
202
+ '7109' => 'The structure of your XML order is incorrect.',
203
+ '7110' => 'The field values::privacy_rule is incorrect.',
204
+ '7111' => 'The field values::publicc is incorrect.',
205
+ '7112' => 'The field last name of public-c is invalid.',
206
+ '7113' => 'The field first name of public-c is invalid.',
207
+ '7114' => 'The field values::contact_type is incorrect.',
208
+ '7115' => 'The chosen report source (object group) is incorrect.',
209
+ '7116' => 'The output format is invalid.',
210
+ '7117' => 'One of the AAAA record fields is incorrect.',
211
+ '7118' => 'The field values::delegation is invalid.',
212
+ '7119' => 'The field values::ttl is invalid.',
213
+ '8000' => 'This IP is not authorised for accessing our system.',
214
+ '8001' => 'The IP could not be auhorised by the used account.',
215
+ '8002' => 'The account could not be found.',
216
+ '8003' => 'The user could not be found.',
217
+ '8004' => 'Authentication failed. Please check the password.',
218
+ '8005' => 'Account is inactive.',
219
+ '8006' => 'User is inactive.',
220
+ '8007' => 'User privileges forbid this action.',
221
+ '8008' => 'Chosen module or duty is under maintenance.',
222
+ '8009' => 'Too many active connections for this resource.',
223
+ '8010' => 'User temporarily blocked.',
224
+ '9000' => 'System temporary not available - System locked.',
225
+ '9001' => 'Critical error by ROLLBACK to DBMS while writing transaction.',
226
+ '9002' => 'Critical error by ROLLBACK after invalid COMMIT to DBMS after a transaction.',
227
+ '9003' => 'RegEx table access violation.',
228
+ '9004' => 'IP table access violation.',
229
+ '9005' => 'Account table access violation.',
230
+ '9006' => 'User table access violation.',
231
+ '9007' => 'Critical Error by ROLLBACK to DBMS while transaction.',
232
+ '9008' => 'Module table access violation.',
233
+ '9009' => 'No active module for machining available or rather error while loading module.',
234
+ '9010' => 'Transaction table access violation.',
235
+ '9011' => 'Pricing table access violation.',
236
+ '9012' => 'Critical Error while reading the auto increment value.',
237
+ '9013' => 'Debug breakpoint. Please try again later.',
238
+ '9014' => 'SQL writing transaction failed.',
239
+ '9015' => 'COMMIT failed. Reverse execution follows.',
240
+ '9016' => 'Error on SQL prepare order.',
241
+ '9017' => 'Active bill table access violation.',
242
+ '9018' => 'Contact table access violation.',
243
+ '9019' => 'Access table access violation.',
244
+ '9020' => 'Bill log table access violation.',
245
+ '9021' => 'Account balance table access violation.',
246
+ '9022' => 'Account billing details table access violation.',
247
+ '9023' => 'Service table access violation',
248
+ '9024' => 'Active transaction table access violation.',
249
+ '9025' => 'DNS zones table access violation.',
250
+ '9026' => 'Service table access violation.',
251
+ '9027' => 'SSL-Certs table access violation.',
252
+ '9028' => 'Domain names table access violation.',
253
+ '9029' => 'Host name table access violation.',
254
+ '9030' => 'Domain additional Value access violation.',
255
+ '9031' => 'Active-Transactions-Approvals table access violation.',
256
+ '9032' => 'Active-Sessions table access violation.',
257
+ '9033' => 'Active-Transactions-Email-Crontab table access violation.',
258
+ '9034' => 'Footnotes access violation.',
259
+ '9035' => 'Object cache access violation.',
260
+ '9036' => 'Contact reference table access violation.',
261
+ '9037' => 'Restricted domains access violation.',
262
+ '9038' => 'Credit data access violation.',
263
+ '9039' => 'Order stack table access violation.',
264
+ '9040' => 'Exchange rates table access violation.'
265
+ }
266
+ end
267
+ end
@@ -0,0 +1,17 @@
1
+ module CPS
2
+
3
+ NAME = "CPS-CLIENT"
4
+ GEM = "cps-client"
5
+ AUTHORS = ["jfqd <jfqd@blun.org>"]
6
+
7
+ module Version
8
+ MAJOR = 0
9
+ MINOR = 0
10
+ PATCH = 2
11
+ BUILD = nil
12
+
13
+ STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
14
+ end
15
+
16
+ VERSION = CPS::Version::STRING
17
+ end
data/lib/erb/base.erb ADDED
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <request>
3
+ <auth>
4
+ <cid><%= @cid.convert_to_iso_8859_1 %></cid>
5
+ <user><%= @uid.convert_to_iso_8859_1 %></user>
6
+ <pwd><%= @pwd.convert_to_iso_8859_1 %></pwd>
7
+ </auth>
8
+ <transaction>
9
+ <%= @xml %>
10
+ </transaction>
11
+ </request>
@@ -0,0 +1,19 @@
1
+ <group>contact</group>
2
+ <action>create</action>
3
+ <attribute>contact</attribute>
4
+ <object><%= @object.convert_to_iso_8859_1 %></object>
5
+ <values>
6
+ <firstname><%= @firstname.convert_to_iso_8859_1 %></firstname>
7
+ <lastname><%= @lastname.convert_to_iso_8859_1 %></lastname>
8
+ <orgname><%= @orgname.convert_to_iso_8859_1 %></orgname>
9
+ <street><%= @street.convert_to_iso_8859_1 %></street>
10
+ <postal><%= @postal.convert_to_iso_8859_1 %></postal>
11
+ <city><%= @city.convert_to_iso_8859_1 %></city>
12
+ <state><%= @state.convert_to_iso_8859_1 %></state>
13
+ <iso_country><%= @iso_country.convert_to_iso_8859_1 %></iso_country>
14
+ <phone><%= @phone.convert_to_iso_8859_1 %></phone>
15
+ <fax><%= @fax.convert_to_iso_8859_1 %></fax>
16
+ <email><%= @email.convert_to_iso_8859_1 %></email>
17
+ <privacy_rule><%= @privacy_rule.convert_to_iso_8859_1 %></privacy_rule>
18
+ <contact_type><%= @contact_type.convert_to_iso_8859_1 %></contact_type>
19
+ </values>
@@ -0,0 +1,4 @@
1
+ <group>contact</group>
2
+ <action>delete</action>
3
+ <attribute>contact</attribute>
4
+ <object><%= @object.convert_to_iso_8859_1 %></object>
@@ -0,0 +1,13 @@
1
+ <firstname><%= @firstname.convert_to_iso_8859_1 %></firstname>
2
+ <lastname><%= @lastname.convert_to_iso_8859_1 %></lastname>
3
+ <orgname><%= @orgname.convert_to_iso_8859_1 %></orgname>
4
+ <street><%= @street.convert_to_iso_8859_1 %></street>
5
+ <postal><%= @postal.convert_to_iso_8859_1 %></postal>
6
+ <city><%= @city.convert_to_iso_8859_1 %></city>
7
+ <state><%= @state.convert_to_iso_8859_1 %></state>
8
+ <iso_country><%= @iso_country.convert_to_iso_8859_1 %></iso_country>
9
+ <phone><%= @phone.convert_to_iso_8859_1 %></phone>
10
+ <fax><%= @fax.convert_to_iso_8859_1 %></fax>
11
+ <email><%= @email.convert_to_iso_8859_1 %></email>
12
+ <privacy_rule><%= @privacy_rule.convert_to_iso_8859_1 %></privacy_rule>
13
+ <contact_type><%= @contact_type.convert_to_iso_8859_1 %></contact_type>
@@ -0,0 +1,4 @@
1
+ <group>contact</group>
2
+ <action>info</action>
3
+ <attribute>contact</attribute>
4
+ <object><%= @object.convert_to_iso_8859_1 %></object>
@@ -0,0 +1,16 @@
1
+ <group>domain</group>
2
+ <action>create</action>
3
+ <attribute>domain</attribute>
4
+ <object><%= @domain.convert_to_iso_8859_1 %></object>
5
+ <values>
6
+ <adminc><%= @adminc.convert_to_iso_8859_1 %></adminc>
7
+ <techc><%= @techc.convert_to_iso_8859_1 %></techc>
8
+ <billc><%= @billc.convert_to_iso_8859_1 %></billc>
9
+ <ownerc><%= @ownerc.convert_to_iso_8859_1 %></ownerc>
10
+ <dns>
11
+ <hostname><%= @ns1.convert_to_iso_8859_1 %></hostname>
12
+ </dns>
13
+ <dns>
14
+ <hostname><%= @ns2.convert_to_iso_8859_1 %></hostname>
15
+ </dns>
16
+ </values>
@@ -0,0 +1,4 @@
1
+ <group>domain</group>
2
+ <action>delete</action>
3
+ <attribute>domain</attribute>
4
+ <object><%= @domain.convert_to_iso_8859_1 %></object>
@@ -0,0 +1,4 @@
1
+ <group>domain</group>
2
+ <action>info</action>
3
+ <attribute>domain</attribute>
4
+ <object><%= @domain.convert_to_iso_8859_1 %></object>
data/test.rb ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/lib/cps-client.rb'
4
+
5
+ server = CPS::Client.new(
6
+ :cid => 'your-cid',
7
+ :uid => 'your-uid',
8
+ :pwd => 'your-pwd',
9
+ :production => false
10
+ )
11
+
12
+ client_contact = CPS::Contact.new(
13
+ :object => 'qd1234',
14
+ :firstname => 'Peter',
15
+ :lastname => 'Pan',
16
+ :street => 'Brunnengasse 34',
17
+ :postal => '60127',
18
+ :city => 'Frankfurt am Main',
19
+ :state => 'Hessen',
20
+ :iso_country => 'DE',
21
+ :phone => '+49 694711',
22
+ :fax => '+49 694711',
23
+ :email => 'peter.pan@example.com'
24
+ )
25
+
26
+ company_contact = CPS::Contact.new(
27
+ :object => 'qd0001',
28
+ :firstname => 'Paulär',
29
+ :lastname => 'Panter',
30
+ :street => 'Brunnengasse 1',
31
+ :postal => '60127',
32
+ :city => 'Frankfurt am Main',
33
+ :state => 'Hessen',
34
+ :iso_country => 'DE',
35
+ :phone => '+49 69471123',
36
+ :fax => '+49 69471124',
37
+ :email => 'paulaer.panter@example.com'
38
+ )
39
+
40
+ domain = CPS::Domain.new(
41
+ :domain => 'example-domain-123456.com',
42
+ :adminc => 'QD1234',
43
+ :techc => 'QD0001',
44
+ :billc => 'QD0001',
45
+ :ownerc => 'QD1234',
46
+ :ns1 => 'my1.dns.com',
47
+ :ns2 => 'my2.dns.com'
48
+ )
49
+
50
+ unless server.query(client_contact.info) # return true if contact handle exists
51
+ # Create client contact handle
52
+ if server.query(client_contact.create)
53
+ puts "Contact created: #{server.result_code}: #{server.result_message}"
54
+ else
55
+ puts "Error: #{server.data}"
56
+ puts "#{server.result_code}: #{server.result_message} #{server.request}"
57
+ exit 1
58
+ end
59
+ else
60
+ puts "Client contact handle exists: #{client_contact.object}"
61
+ end
62
+
63
+ unless server.query(company_contact.info) # return true if contact handle exists
64
+ # Create company contact handle
65
+ if server.query(company_contact.create)
66
+ puts "Contact created: #{server.result_code}: #{server.result_message}"
67
+ else
68
+ puts "Error: #{server.data}"
69
+ puts "#{server.result_code}: #{server.result_message} #{server.request}"
70
+ exit 1
71
+ end
72
+ else
73
+ puts "Company contact handle exists: #{company_contact.object}"
74
+ end
75
+
76
+ # if server.query(client_contact.info)
77
+ # puts "Contact info: #{server.data}"
78
+ # puts "#{server.result_code}: #{server.result_message}"
79
+ # else
80
+ # puts "Error: #{server.data}"
81
+ # puts "#{server.result_code}: #{server.result_message} #{server.request}"
82
+ # exit 1
83
+ # end
84
+
85
+ # create domain
86
+ unless server.query(domain.info) # return true if domain is registered
87
+ if server.query(domain.create)
88
+ puts "Domain created: #{server.result_code}: #{server.result_message}"
89
+ else
90
+ puts "Error: #{server.data}"
91
+ puts "#{server.result_code}: #{server.result_message} #{server.request}"
92
+ exit 1
93
+ end
94
+ else
95
+ puts "Domain exists: #{domain.domain}"
96
+ end
97
+
98
+ # if server.query(domain.info)
99
+ # puts "Domain info: #{server.data}"
100
+ # puts "#{server.result_code}: #{server.result_message}"
101
+ # else
102
+ # puts "Error: #{server.data}"
103
+ # puts "#{server.result_code}: #{server.result_message} #{server.request}"
104
+ # exit 1
105
+ # end
106
+
107
+ if server.query(domain.delete)
108
+ puts "Domain delete: #{server.result_code}: #{server.result_message}"
109
+ else
110
+ puts "Error: #{server.data}"
111
+ puts "#{server.result_code}: #{server.result_message} #{server.request}"
112
+ exit 1
113
+ end
114
+
115
+ if server.query(client_contact.delete)
116
+ puts "Contact deleted: #{server.result_code}: #{server.result_message}"
117
+ else
118
+ puts "Error: #{server.data}"
119
+ puts "#{server.result_code}: #{server.result_message}"
120
+ exit 1
121
+ end
122
+
123
+ if server.query(company_contact.delete)
124
+ puts "Contact deleted: #{server.result_code}: #{server.result_message}"
125
+ else
126
+ puts "Error: #{server.data}"
127
+ puts "#{server.result_code}: #{server.result_message}"
128
+ exit 1
129
+ end
130
+
131
+ exit 0
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cps-client
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - jfqd
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-05 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: always_verify_ssl_certificates
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 0
34
+ version: 0.2.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: ruby api for the arp-client of cps-datensysteme.de
38
+ email:
39
+ - jfqd@blun.org
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - Rakefile
51
+ - Readme.textile
52
+ - cps-client.gemspec
53
+ - lib/core_ext.rb
54
+ - lib/cps-client.rb
55
+ - lib/cps-client/client.rb
56
+ - lib/cps-client/config.rb
57
+ - lib/cps-client/contact.rb
58
+ - lib/cps-client/domain.rb
59
+ - lib/cps-client/erb_helper.rb
60
+ - lib/cps-client/errors.rb
61
+ - lib/cps-client/version.rb
62
+ - lib/erb/base.erb
63
+ - lib/erb/contact_create.erb
64
+ - lib/erb/contact_delete.erb
65
+ - lib/erb/contact_domain.erb
66
+ - lib/erb/contact_info.erb
67
+ - lib/erb/domain_create.erb
68
+ - lib/erb/domain_delete.erb
69
+ - lib/erb/domain_info.erb
70
+ - test.rb
71
+ has_rdoc: true
72
+ homepage: https://github.com/jfqd/cps-client
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project: cps-client
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: ruby api for the arp-client of cps-datensysteme.de
105
+ test_files: []
106
+