epp-eis 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -24,10 +24,6 @@ In Gemfile add it as a gem:
24
24
 
25
25
  ## TODO
26
26
 
27
- Need to implement the following commands
28
-
29
- * credit_info
30
-
31
27
  Commands that are nice to have, but not needed.
32
28
 
33
29
  * check_keyset
data/epp-eis.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency 'rspec'
24
24
  s.add_development_dependency 'guard'
25
+ s.add_development_dependency 'guard-rspec'
25
26
  end
@@ -192,7 +192,7 @@ module Epp
192
192
  ContactCreateResponse.new(send_request(builder.to_xml))
193
193
  end
194
194
 
195
- #Delete contact handle. Contact object can not be deleted if it has relations to other objects like domains or
195
+ # Delete contact handle. Contact object can not be deleted if it has relations to other objects like domains or
196
196
  # nssets.
197
197
  def delete_contact(contact)
198
198
  builder = build_epp_request do |xml|
@@ -257,7 +257,7 @@ module Epp
257
257
  xml.ident ident, 'type' => ident_type
258
258
  }
259
259
  }
260
- add_legal_document(xml, legal_document, legal_doc_type)
260
+ append_legal_document(xml, legal_document, legal_doc_type)
261
261
  xml.clTRID UUIDTools::UUID.timestamp_create.to_s
262
262
  }
263
263
  end
@@ -0,0 +1,40 @@
1
+ module Epp
2
+ module Eis
3
+
4
+ XML_NS_FRED = 'http://www.nic.cz/xml/epp/fred-1.4'
5
+
6
+ class CreditInfoResponse
7
+ def initialize(response)
8
+ @response = Nokogiri::XML(response)
9
+ end
10
+
11
+ def code
12
+ @response.css('epp response result').first['code'].to_i
13
+ end
14
+
15
+ def message
16
+ @response.css('epp response result msg').text
17
+ end
18
+
19
+ def zone_credits
20
+ @response.css('fred|resCreditInfo fred|zoneCredit', 'fred' => XML_NS_FRED).inject({}) do |memo, item|
21
+ memo[item.css('fred|zone', 'fred' => XML_NS_FRED).text] = item.css('fred|credit', 'fred' => XML_NS_FRED).text
22
+ memo
23
+ end
24
+ end
25
+ end
26
+
27
+ module CreditCommands
28
+
29
+ def credit_info
30
+ builder = build_epp_request do |xml|
31
+ xml.credit_info
32
+ end
33
+
34
+ CreditInfoResponse.new(send_request(builder.to_xml))
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ Epp::Server.send(:include, Epp::Eis::CreditCommands)
@@ -220,7 +220,7 @@ module Epp
220
220
  [admins].flatten.each { |admin| xml.admin admin }
221
221
  }
222
222
  }
223
- add_legal_document(xml, legal_document, legal_doc_type)
223
+ append_legal_document(xml, legal_document, legal_doc_type)
224
224
  xml.clTRID UUIDTools::UUID.timestamp_create.to_s
225
225
  }
226
226
  end
@@ -244,7 +244,7 @@ module Epp
244
244
  xml.name domain
245
245
  }
246
246
  }
247
- add_legal_document(xml, legal_document, legal_doc_type)
247
+ append_legal_document(xml, legal_document, legal_doc_type)
248
248
  xml.clTRID UUIDTools::UUID.timestamp_create.to_s
249
249
  }
250
250
  end
@@ -315,7 +315,7 @@ module Epp
315
315
  xml.authInfo auth_info
316
316
  }
317
317
  }
318
- add_legal_document(xml, legal_document, legal_doc_type)
318
+ append_legal_document(xml, legal_document, legal_doc_type)
319
319
  xml.clTRID UUIDTools::UUID.timestamp_create.to_s
320
320
  }
321
321
  end
@@ -361,7 +361,7 @@ module Epp
361
361
  end
362
362
  }
363
363
  }
364
- add_legal_document(xml, legal_document, legal_doc_type)
364
+ append_legal_document(xml, legal_document, legal_doc_type)
365
365
  xml.clTRID UUIDTools::UUID.timestamp_create.to_s
366
366
  }
367
367
  end
@@ -1,5 +1,5 @@
1
1
  module Eis
2
2
  module Epp
3
- VERSION = '0.1.1'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
data/lib/epp-eis.rb CHANGED
@@ -2,6 +2,7 @@ require 'epp'
2
2
 
3
3
  require 'epp-eis/version'
4
4
  require 'epp-eis/session'
5
+ require 'epp-eis/credit'
5
6
  require 'epp-eis/extensions'
6
7
  require 'epp-eis/domain'
7
8
  require 'epp-eis/contact'
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Epp::Eis::CreditCommands do
4
+
5
+ before(:each) do
6
+ @server = Epp::Server.new(:server => '127.0.0.1', :tag => 'username', :password => 'password')
7
+ end
8
+
9
+ describe 'credit_info' do
10
+ context 'when response is successful' do
11
+ before(:each) do
12
+ @server.stub(:send_request).and_return(xml_mock('responses/credit/credit_info.xml'))
13
+ @response = @server.credit_info
14
+ end
15
+
16
+ it 'returns response code' do
17
+ @response.code.should == 1000
18
+ end
19
+
20
+ it 'returns hash of credits by TLD' do
21
+ @response.zone_credits['ee'].should == '1234.56'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <extension>
4
+ <fred:extcommand xmlns:fred="http://www.nic.cz/xml/epp/fred-1.4" xsi:schemaLocation="http://www.nic.cz/xml/epp/fred-1.4 fred-1.4.xsd">
5
+ <fred:creditInfo/>
6
+ <fred:clTRID>pjps002#12-12-05at07:00:57</fred:clTRID>
7
+ </fred:extcommand>
8
+ </extension>
9
+ </epp>