Skip to content

xolphin/xolphin-api-.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xolphin API wrapper for C#

XolphinApiDotNet is a client library targeting .NET 4.5 and above that provides an easy way to interact with the Xolphin REST API.

About Xolphin

Xolphin is the largest supplier of SSL Certificates and Digital Signatures in the Netherlands. Xolphin has a professional team providing reliable support and rapid issuance of SSL Certificates at an affordable price from industry leading brands such as Comodo, GeoTrust, GlobalSign, Thawte and Symantec.

Library installation

There are 2 ways to use XolphinApiDotNet:

  • Install-package XolphinApiDotNet (via Nuget)
  • Download source and compile

Usage

Client initialization

var client = new Client("<username>", "<password>");

Test mode

var client = new Client("fake_login@xolphin.api", "Sup3rSecre7P@s$w0rdForThe@p1");
client.TestMode(true);

Calling conventions

Most of the Requests classes have ability to assign the additional parameters of the request with 2 ways:

var reissue = new XolphinApiDotNet.Requests.Reissue(<csr_string>, DCVType.Email);
// 1. Fluent style
reissue.SetApproverEmail("email@domain.com");
// 2. Property assignment
reissue.ApproverEmail = "email@domain.com";

Request operations

Getting list of requests

// GET /requests
var requests = client.Request.All();
foreach (var request in requests)
{
    Console.WriteLine(request.Id);
}

Order certificate

// POST /requests
var products = client.Support.Products();
if (products.Any())
{
    var productId = products.First().Id;
    // request certificate for 1 year
    var requestsRequest = new XolphinApiDotNet.Requests.Request(productId, 1, <csr_string>, DCVType.Email)
        .SetApproverRepresentativeFirstName("<first_name>")
        .SetApproverRepresentativeLastName("<last_name>")
        .SetApproverRepresentativePhone("+12345678901")
        .SetApproverRepresentativePosition("IT")
        .SetApproverRepresentativeEmail("<email>")
        .SetZipcode("123456")
        .SetСity("<city>")
        .SetCompany("<company>")
        .SetApproverEmail("<email>")
        //currently available languages: en, de, fr, nl
        .SetLanguage("en")
        .AddSubjectAlternativeName("test1.domain.com")
        .AddSubjectAlternativeName("test2.domain.com")
        .AddSubjectAlternativeName("test3.domain.com")
        .AddDcv(new RequestDCV("test1.domain.com", DCVType.Email, "email1@domain.com"))
        .AddDcv(new RequestDCV("test2.domain.com", DCVType.Email, "email2@domain.com"));

    var responsesRequest = client.Request.Send(requestsRequest);
    Console.WriteLine(responsesRequest.Id);
}

Getting single request

// GET /requests/{id}
var responseRequest = client.Request.Get(1234);
Console.WriteLine(responseRequest.Id);

Getting all requests

// GET /requests/
var requests = client.Request.All();
foreach (var request in requests)
{
    Console.WriteLine(request.Id);
}

Upload new request document

// POST /requests/{id}/upload-document
var uploadResponse = client.Request.Upload(1234, new UploadDocument("<file_name>", File.ReadAllBytes("document.pdf")).SetDescription("<description>"));
Console.WriteLine(uploadResponse.Message);

Retry DCV

// POST /requests/{id}/retry-dcv
var retryDcvResponse = client.Request.RetryDCV(1234, new DCV("test.domain.com", DCVType.Email, "email@domain.com"));
Console.WriteLine(retryDcvResponse.Message);

Send Subscriber Agreement

// POST /requests/{id}/sa

var comodoSA = new XolphinApiDotNet.Requests.ComodoSA("mail@example.com");
//currently available languages: en, de, fr, nl
comodoSA.SetLanguage("en");
var subscribe = client.Request.SubscribeComodoSA(1234, comodoSA);
Console.WriteLine(subscribe.Message);

Schedule validation call

// POST /requests/{id}/schedule-validation-call
var requestsValidationCallDetails = new XolphinApiDotNet.Requests.ValidationCall()
    .SetPhoneNumber("123465798")
    .SetTimezone("Europe/Amsterdam")
    .SetAction("Callback");

var dateString = "11/24/2023 10:33:52 AM";

DateTime date = DateTime.Parse(dateString,
                          System.Globalization.CultureInfo.InvariantCulture);

var scheduleValidationCallResponse = client.Request.ScheduleValidationCall(1234, date, requestsValidationCallDetails);
Console.WriteLine(scheduleValidationCallResponse.Message);

Send note

// POST /requests/{id}/notes
var result = client.Request.SendNote(1234, new NoteSend("my message"));
Console.WriteLine(result.SendNote);

Get notes

// GET /requests/{id}/notes
var result = client.Request.GetNotes(1234);
foreach (Responses.Note note in result.Notes)
{
    Console.WriteLine(note.Message);
}

Certificate operations

Getting list of certificates

// GET /certificates
var certificates = client.Certificate.All();
foreach (var certificate in certificates)
{
    Console.WriteLine(certificate.Id);
}

Getting single certificate

// GET /certificates/{id}
var certificate = client.Certificate.Get(1234);
Console.WriteLine(certificate.Id);

Download certificate

// GET /certificates/{id}/download
var downloadResult = client.Certificate.Download(1234);

Reissue certificate

// POST /certificates/{id}/reissue
var reissue = new XolphinApiDotNet.Requests.Reissue(<csr_string>, DCVType.Email);
var responsesRequest = client.Certificate.Reissue(1234, reissue);
Console.WriteLine(responsesReissue.Id);

Renew certificate

// POST /certificates/{id}/renew
var products = client.Support.Products();
var productId = products.First().Id;
// renew certificate for 1 year
var renew = new XolphinApiDotNet.Requests.Renew(productId, 1, <csr_string>, DCVType.Email);
var responsesRequest = client.Certificate.Renew(1234, renew);
Console.WriteLine(responsesRequest.Id);

Cancel certificate

// POST /certificates/{id}/cancel
var cancelSettings = new XolphinApiDotNet.Requests.CancelSettings("cancellation reason");
var responsesBase = client.Certificate.Cancel(1234, cancelSettings);

Supporting operations

Getting list of approver e-mail addresses

// GET /approver-email-addresses
var emailAddresses = client.Support.ApproverEmailAddresses("domain.com");
foreach (var emailAddress in emailAddresses)
{
    Console.WriteLine(emailAddress);
}

Decode CSR

// POST /decode-csr
var csr = client.Support.DecodeCSR(<csr_string>);
Console.WriteLine(csr.Type);

Getting list of products

// GET /products
var products = client.Support.Products();
foreach (var product in products)
{
    Console.WriteLine(product.Id);
}

Getting single product

// GET /products/{id}
var product = client.Support.Product(1234);
Console.WriteLine(product.Name);