Class: YandexDomains::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/yandex_domains.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdd_token) ⇒ YandexDomains::Client

Initializes a new Client

Parameters:

  • pdd_token (String)

14
15
16
17
# File 'lib/yandex_domains.rb', line 14

def initialize(pdd_token)
  self.pdd_token = pdd_token
  self.class.headers 'PddToken' => pdd_token
end

Instance Attribute Details

#pdd_tokenObject

Returns the value of attribute pdd_token


7
8
9
# File 'lib/yandex_domains.rb', line 7

def pdd_token
  @pdd_token
end

Instance Method Details

#add_mailbox(domain, login, password) ⇒ Hash

Used for adding a mailbox for the domain.

Examples:

Example create [email protected] with strongpassword

client.add_mailbox('google.com', 'hi', 'strongpassword')

Return Hash

{
  "domain": "{domain name}",
  "login":"{email address of the mailbox}",
  "uid": "{mailbox ID}",
  "success": "{status of request execution}"
}

Parameters:

  • domain (String)

    Name of the domain.

  • login (String)

    The email address of the mailbox, in the format “[email protected]” or “username”.

  • password (String)

    User's password. The password must: contain from 6 to 20 characters — Latin letters, numbers, and the symbols “!”, “@”, “#”, “$”, “%”, “^”, “&”, “*”, “(”, “)”, “_”, “-”, “+”, “:”, “;”, “,”, “.” be different from the username.

Returns:

  • (Hash)

    Parsed Response

See Also:


57
58
59
60
# File 'lib/yandex_domains.rb', line 57

def add_mailbox(domain, , password)
  req = self.class.post("/admin/email/add", {query: {domain: domain, login: , password: password}})
  req.parsed_response
end

#connect_domain(domain) ⇒ Hash

Used for signing up a domain.

Parameters:

  • domain (String)

Returns:

  • (Hash)

See Also:


23
24
25
26
# File 'lib/yandex_domains.rb', line 23

def connect_domain(domain)
  req = self.class.post("/admin/domain/register", {query: {domain: domain}})
  req.parsed_response
end

#delete_mailbox(domain, login) ⇒ Hash

Used for deleting a mailbox on a domain

Examples:

Example Usage

client.delete_mailbox('google.com', 'hi')

Example Response

{
    "domain": "{domain name}",
    "login":"{mailbox address}",
    "success": "{status of request execution}"
}

Parameters:

  • domain (String)

    Name of the domain.

  • login (String)

    The email address of the mailbox, in the format “[email protected]” or “username”.

Returns:

  • (Hash)

    Parsed Response

See Also:


143
144
145
146
# File 'lib/yandex_domains.rb', line 143

def delete_mailbox(domain, )
  req = self.class.post("/admin/email/del", {query: {domain: domain, login: }})
  req.parsed_response
end

#get_mailboxes(domain, options = {}) ⇒ Hash

TODO:

Add support for options

Used for getting a list of the domain's mailboxes.

Parameters:

  • domain (String)

    Name of the domain.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :page (Integer)

    Page number in the response. The default value is 1. #TODO

  • :on_page (Integer)

    Number of mailboxes on each response page. The default value is 30. #TODO

Returns:

  • (Hash)

See Also:


70
71
72
73
# File 'lib/yandex_domains.rb', line 70

def get_mailboxes(domain, options = {})
  req = self.class.get("/admin/email/list", {query: {domain: domain}})
  req.parsed_response['accounts']
end

#registration_status(domain) ⇒ Hash

The request is used for getting the results of the last check, the date and time the check was performed, and the date and time of the next check.

Parameters:

  • domain (String)

Returns:

  • (Hash)

    Parsed Response

See Also:


33
34
35
36
# File 'lib/yandex_domains.rb', line 33

def registration_status(domain)
  req = self.class.get("/admin/domain/registration_status", {query: {domain: domain}})
  req.parsed_response
end

#update_mailbox(domain, login, options = {}) ⇒ Hash

Used for editing mailbox parameters: password, user's first and last name, and so on.

Examples:

Example Usage

client.update_mailbox('google.com', 'hi', {sex: 0, birth_date: "1998-09-04"})

Example Response

{
    "domain": "{domain name}",
    "login":"{email address of the mailbox}",
    "uid": "{mailbox ID}",
    "success": "{status of request execution}",
    "account":
    {
        "uid": "{mailbox ID}",
        "iname": "{user's name}",
        "sex": "{user's gender}",
        "ready": "{mailbox readiness}",
        "hintq": "{pet's favorite food ???}",
        "aliases":
        [
            "{alias name}",
        ...
        ],
        "enabled": "{whether mailbox is working}",
        "maillist": "{mailing list flag}",
        "fname": "{user's last name}",
        "birth_date": "{user's date of birth}",
        "login": "{mailbox email address}",
        "fio": "{user's full name}"
    }
}

Parameters:

  • domain (String)

    Name of the domain.

  • login (String)

    The email address of the mailbox, in the format “[email protected]” or “username”.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :password (String)

    User's new password.

  • :iname (String)

    User's first name.

  • :fname (String)

    User's last name.

  • :enabled (String)

    Whether the mailbox is enabled. Possible values: yes — Mailbox is enabled no — Mailbox is blocked (for example, due to spam distribution or suspected hacking).

  • :birth_date (Integer)

    User's date of birth in the format YYYY-MM-DD.

  • :sex (Integer)

    User's gender. Possible values: 0 — Not specified. 1 — Male. 2 — Female.

  • :hintq (Integer)

    Secret question.

  • :hinta (Integer)

    Answer to the secret question.

Returns:

  • (Hash)

See Also:


124
125
126
127
128
129
# File 'lib/yandex_domains.rb', line 124

def update_mailbox(domain, , options = {})
  query = {domain: domain, login: }
  query = query.merge(options)
  req = self.class.post("/admin/email/edit", query: query)
  req.parsed_response
end