-
Notifications
You must be signed in to change notification settings - Fork 35
Home
Richard Pearson edited this page Oct 9, 2013
·
7 revisions
var tcpTransport = new TcpTransport("epp.registry", 700, new X509Certificate("mycert.pfx", "p4ssw0rd"), true);
var service = new Service(tcpTransport);
// SSL connection establishment
service.Connect();
var logingCmd = new Login("username", "password");
logingCmd.Options = new Options {MLang = "en", MVersion = "1.0"};
var services = new Services();
services.ObjURIs.Add("urn:ietf:params:xml:ns:epp-1.0");
services.ObjURIs.Add("urn:ietf:params:xml:ns:domain-1.0");
services.ObjURIs.Add("urn:ietf:params:xml:ns:host-1.0");
services.ObjURIs.Add("urn:ietf:params:xml:ns:contact-1.0");
//CIRA extensions
services.Extensions.Add("urn:ietf:params:xml:ns:cira-1.0");
services.Extensions.Add("urn:ietf:params:xml:ns:poll-1.0");
logingCmd.Services = services;
var response = service.Execute(logingCmd);
if(!response.Code.Equals("1000"))
{
throw new ApplicationException("Authentication failed");
}
var agreementCmd = new GetAgreement();
var getAgreementResponse = service.Execute(agreementCmd);
var agreementVersion = getAgreementResponse.AgreementVersion;
var agreementText = getAgreementResponse.Agreement;
var agreementLanguage = getAgreementResponse.Language;
var registrantContact = new Contact("xxxx",
"Registrant Full Name", "Example Inc.",
"Toronto", "Address", "ON", "M5V3T1", "CA",
"[email protected]",
new Telephone { Value = "+1.6471114444", Extension = "333" },
new Telephone { Value = "+1.6471114445" });
var registrantContactCmd = new ContactCreate(registrantContact);
var ciraExtension = new CiraCreateExtension
{
Language = "en",
OriginatingIpAddress = "127.0.0.1",
CprCategory = CprCategory.CCT,
AgreementVersion = "2.0",
AggreementValue = "Y",
CreatedByResellerId = "resellerId"
};
registrantContactCmd.Extensions.Add(ciraExtension);
response = service.Execute(registrantContactCmd);
var registrantTransferCmd = new DomainUpdate("mydomain.ca");
registrantTransferCmd.DomainChange = new DomainChange { RegistrantContactId = "newcontactid" };
response = service.Execute(registrantTransferCmd);
var contactUpdateCmd = new ContactUpdate(registrantContact.Id);
var contactChange = new ContactChange(registrantContact);
contactChange.Fax = new Telephone("2223334444", "123");
contactUpdateCmd.ContactChange = contactChange;
// CIRA CPR extension
contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension { CprCategory = CiraCprCategories.CCT });
response = service.Execute(contactUpdateCmd);
var domainCheckCmd = new DomainCheck("mydomain.ca");
response = service.Execute(domainCheckCmd) as DomainCheckResponse;
if(response.Results[0].Available){
// add to shopping cart
}
var domainCreateCmd = new DomainCreate("mydomain.ca", "contactid");
domainCreateCmd.DomainContacts.Add(new DomainContact("admincontactid", "admin"));
//NOTE: password is compulsory
domainCreateCmd.Password = "s0mer4ndom";
response = service.Execute(domainCreateCmd);
var hostCheckCmd = new HostCheck(new List { "ns1.example.com", "ns2.example.com" });
response = service.Execute(hostCheckCmd);
var host = new Host("ns1.example.com");
host.Addresses.Add(new HostAddress("127.0.0.1", "v4"));
var hostCreateCmd = new HostCreate(host);
response = service.Execute(hostCreateCmd);
var hostInfoCmd = new HostInfo("ns1.example.com");
response = service.Execute(hostInfoCmd);
var domainUpdateCmd = new DomainUpdate("example.ca");
//NOTE: Nameservers need different IP addresses
domainUpdateCmd.ToAdd.NameServers = new List<string> { "ns1.example.com", "ns2.example.com" };
response = service.Execute(domainUpdateCmd);
var hostUpdateCmd = new HostUpdate("ns1.example.com");
var eppHostUpdateAddRemove = new EppHostUpdateAddRemove();
eppHostUpdateAddRemove.Adresses = new List { new HostAddress("1080:0:0:0:8:800:2004:17A", "v6") };
eppHostUpdateAddRemove.Status = new List { new Status("", "clientUpdateProhibited") };
hostUpdateCmd.ToAdd = eppHostUpdateAddRemove;
response = service.Execute(hostUpdateCmd);
var domainInfoCmd = new DomainInfo("example.ca");
var domainInfo = (DomainInfoResponse)service.Execute(domainInfoCmd);
var renewCmd = new DomainRenew(domainInfo.Domain.Name, domainInfo.Domain.ExDate, new DomainPeriod(2, "y"));
response = service.Execute(renewCmd);
var transferCmd = new DomainTransfer("example.ca", null, null, new List());
transferCmd.Password = "p4ssw0rd";
response = service.Execute(transferCmd);
var deleteDomainCmd = new DomainDelete("example.ca");
response = service.Execute(deleteDomainCmd);
var thereAreMessages = true;
while (thereAreMessages)
{
var poll = new Poll { Type = PollType.Request };
var pollResponse = (PollResponse)service.Execute(poll);
if (!String.IsNullOrEmpty(pollResponse.Id))
{
//acknowledge
poll = new Poll { Type = PollType.Acknowledge, MessageId = pollResponse.Id };
pollResponse = (PollResponse)service.Execute(poll);
PrintResponse(pollResponse);
}
Console.WriteLine("Messages left in the queue:" + pollResponse.Count);
thereAreMessages = pollResponse.Count != 0;
}
(c) 2011 Code Maker Inc. All rights reserved