<commit_before># EPP Client

[![Build Status](https://travis-ci.org/m247/epp-client.svg?branch=master)](https://travis-ci.org/m247/epp-client)

Client for communicating with EPP services

## Installation

Add this line to your application's Gemfile:

    gem 'epp-client'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install epp-client

## Usage

    client = EPP::Client.new('username', 'password', 'epp.server.com')
    client.hello
    puts client._last_request.inspect
    puts client._last_response.inspect

Any other methods called on `client` will be passed through to an
authenticated EPP server connection. As a quick example, either a
string of XML, an XML::Node or XML::Document can be passed or a
block may be used

### domain:check using string payload

    client.check <<-EOXML
      <domain:check
       xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
        <domain:name>example.com</domain:name>
        <domain:name>example.net</domain:name>
        <domain:name>example.org</domain:name>
      </domain:check>
    EOXML

### domain:check using XML::Node payload

    xml = XML::Node.new('check')
    ns = XML::Namespace.new(xml, 'domain', 'urn:ietf:params:xml:ns:domain-1.0')
    xml.namespaces.namespace = ns

    %w(example.com example.net example.org).each do |name|
      xml << XML::Node.new('name', name, ns)
    end

    client.check xml

### domain:check using block

    client.check do |xml|
      xml << (check = XML::Node.new('check'))
      ns = XML::Namespace.new(check, 'domain', 'urn:ietf:params:xml:ns:domain-1.0')
      check.namespaces.namespace = ns

      %w(example.com example.net example.org).each do |name|
        check << XML::Node.new('name', name, ns)
      end
    end

If you leave off the block parameter then the return value of the block will be
inserted into the `xml`.
<commit_msg>Update README.md to remove pre 1.0.0 API examples.<commit_after># EPP Client

[![Build Status](https://travis-ci.org/m247/epp-client.svg?branch=master)](https://travis-ci.org/m247/epp-client)

Client for communicating with EPP services

## Installation

Add this line to your application's Gemfile:

    gem 'epp-client'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install epp-client

## Usage

    client = EPP::Client.new('username', 'password', 'epp.server.com')
    client.hello
    puts client.last_request.to_s(:indent => 2)
    puts client.last_response.to_s(:indent => 2)

The old `method_missing` behaviour has been removed and replaced with defined
methods for handling each of the distinct EPP commands.

* `check`
* `create`
* `delete`
* `info`
* `renew`
* `transfer`
* `update`
* `poll`
* `ack`

each of these methods, with the exception of `poll` and `ack`, accept two arguments.
Those arguments are a `payload` and an optional `extension`. The majority of the
common `domain`, `contact` and `host` payloads have been defined already.

### Domain Check Example

    resp = client.check EPP::Domain::Check.new('example.com', 'example.net', 'example.org')
    resp.available?('example.com') #=> true
    resp.available?('example.net') #=> false
    resp.available?('example.org') #=> false

### Domain Information Example

    resp = client.info EPP::Domain::Info.new('example.com')
    resp.name #=> "example.com"
    resp.nameservers #=> [{"name"=>"ns1.example.net"},{"name"=>"ns2.example.net"}]

### Payload an Extension API

The objects which are passed to the `client` methods need to adhere to the following
API in order to be successfully marshalled by the `client` into the required XML
document.

* `name` to specify the EPP command name. Required.
* `to_xml` returns an `XML::Document`. Required.
* `set_namespaces` to receive `XML::Namespace` objects from the parent. Optional.

{'fraction_non_alphanumeric': 0.1346153846153846, 'fraction_numerical': 0.006585879873551107, 'mean_word_length': 3.830788804071247, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 13}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6008589', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1189, 'n_words': 362}