yandex_domains 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/README.md +11 -5
- data/lib/yandex_domains/admin/domain.rb +48 -0
- data/lib/yandex_domains/admin/email.rb +116 -0
- data/lib/yandex_domains/client.rb +24 -0
- data/lib/yandex_domains/version.rb +1 -1
- data/lib/yandex_domains.rb +1 -149
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 127018646750b8e3798cf8c5cb800a0bd759318d
|
4
|
+
data.tar.gz: bffda633ad2060bc4f95911753a120b26f6cbb9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b60972295ed099c6db31f36c8abbcc4fe0c52a7f94ffe6f9b4b38dea97b5811233f2b94f03a571419aa649af60f1e1399b86c46883846264333e1f520997309
|
7
|
+
data.tar.gz: 36d304596df2b16b874889463ad78ec0886d78da141ed5d2ee9c46b75d49e88c2da0ac703345f91036fccfa6c4a0f84cfb14c76b71d224f174563f1580ac97d1
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -17,12 +17,16 @@ And then execute:
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
19
|
$ gem install yandex_domains
|
20
|
+
|
21
|
+
## Documentation
|
22
|
+
|
23
|
+
http://www.rubydoc.info/github/beydogan/yandex_domains/
|
20
24
|
|
21
25
|
## Usage
|
22
26
|
|
23
|
-
This client works
|
27
|
+
This client works with only **Administrator** access. More details about Administrator user is [here](https://tech.yandex.com/domain/doc/concepts/termin-docpage/). In order to use the client and API features, the PDD token is required. You can get a PDD token on the [token management](https://pddimp.yandex.ru/api2/admin/get_token) page by entering a domain name that has already been verified.
|
24
28
|
|
25
|
-
**
|
29
|
+
**Initialize a client**
|
26
30
|
```ruby
|
27
31
|
client = YandexDomains::Client.new(pdd_token)
|
28
32
|
```
|
@@ -32,19 +36,21 @@ After configuring a client, you can do the followings.
|
|
32
36
|
|
33
37
|
**Signing up a domain**
|
34
38
|
```ruby
|
35
|
-
client.
|
39
|
+
client.connect_domain('google.com')
|
36
40
|
```
|
37
41
|
|
38
|
-
**
|
42
|
+
**Adding a mailbox for a domain**
|
39
43
|
```ruby
|
40
44
|
client.add_mailbox('google.com', 'hi', 'strongpassword')
|
41
45
|
```
|
42
46
|
|
43
|
-
**
|
47
|
+
**Deleting a mailbox on a domain**
|
44
48
|
```ruby
|
45
49
|
client.delete_mailbox('google.com', 'hi')
|
46
50
|
```
|
47
51
|
|
52
|
+
[More examples here](http://www.rubydoc.info/github/beydogan/yandex_domains/)
|
53
|
+
|
48
54
|
## Contributing
|
49
55
|
|
50
56
|
1. Fork it ( https://github.com/beydogan/yandex_domains/fork )
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module YandexDomains
|
2
|
+
module Admin
|
3
|
+
module Domain
|
4
|
+
# Used for signing up a domain.
|
5
|
+
# @param domain [String]
|
6
|
+
# @return [Hash]
|
7
|
+
# @see https://api.yandex.com.tr/kurum/doc/reference/domain-register.xml
|
8
|
+
def connect_domain(domain)
|
9
|
+
req = self.class.post("/admin/domain/register", {query: {domain: domain}})
|
10
|
+
req.parsed_response
|
11
|
+
end
|
12
|
+
|
13
|
+
# Used for getting the results of the last check, the date and time the check was performed,
|
14
|
+
# and the date and time of the next check.
|
15
|
+
# @param [String] domain
|
16
|
+
# @return [Hash] Parsed Response
|
17
|
+
# @see https://api.yandex.com.tr/kurum/doc/reference/domain-registrationstatus.xml
|
18
|
+
def registration_status(domain)
|
19
|
+
req = self.class.get("/admin/domain/registration_status", {query: {domain: domain}})
|
20
|
+
req.parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get current domain properties: the status of connecting and delegating the domain to Yandex,
|
24
|
+
# the mailbox interface language and design, and the POP and IMAP modes.
|
25
|
+
# @param [String] domain
|
26
|
+
# @return [Hash] Parsed Response
|
27
|
+
# @example Example Usage
|
28
|
+
# client.details('google.com)
|
29
|
+
# @example Return Hash
|
30
|
+
# {
|
31
|
+
# "domain": "{domain name}",
|
32
|
+
# "status": "{domain status}",
|
33
|
+
# "stage": "{service key}",
|
34
|
+
# "delegated": "{status of delegating domain to Yandex}",
|
35
|
+
# "country": "{interface language}",
|
36
|
+
# "imap_enabled": "{status of IMAP operation}",
|
37
|
+
# "pop_enabled": "{status of POP operation}",
|
38
|
+
# "default_theme": "{design theme ID}",
|
39
|
+
# "success": "{status of request execution}"
|
40
|
+
# }
|
41
|
+
# @see https://tech.yandex.com/domain/doc/reference/domain-details-docpage/
|
42
|
+
def details(domain)
|
43
|
+
req = self.class.get("/admin/domain/details", {query: {domain: domain}})
|
44
|
+
req.parsed_response
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module YandexDomains
|
2
|
+
module Admin
|
3
|
+
module Email
|
4
|
+
# Used for adding a mailbox for the domain.
|
5
|
+
# @param domain [String] Name of the domain.
|
6
|
+
# @param login [String] The email address of the mailbox, in the format “username@domain.ru” or “username”.
|
7
|
+
# @param password [String] User's password.
|
8
|
+
# The password must:
|
9
|
+
# contain from 6 to 20 characters — Latin letters, numbers, and the symbols “!”, “@”, “#”, “$”, “%”, “^”, “&”, “*”, “(”, “)”, “_”, “-”, “+”, “:”, “;”, “,”, “.”
|
10
|
+
# be different from the username.
|
11
|
+
# @return [Hash] Parsed Response
|
12
|
+
# @example Example create hi@google.com with strongpassword
|
13
|
+
# client.add_mailbox('google.com', 'hi', 'strongpassword')
|
14
|
+
# @example Return Hash
|
15
|
+
# {
|
16
|
+
# "domain": "{domain name}",
|
17
|
+
# "login":"{email address of the mailbox}",
|
18
|
+
# "uid": "{mailbox ID}",
|
19
|
+
# "success": "{status of request execution}"
|
20
|
+
# }
|
21
|
+
#
|
22
|
+
# @see https://api.yandex.com.tr/kurum/doc/reference/email-add.xml
|
23
|
+
def add_mailbox(domain, login, password)
|
24
|
+
req = self.class.post("/admin/email/add", {query: {domain: domain, login: login, password: password}})
|
25
|
+
req.parsed_response
|
26
|
+
end
|
27
|
+
|
28
|
+
# Used for getting a list of the domain's mailboxes.
|
29
|
+
# @param domain [String] Name of the domain.
|
30
|
+
# @param options [Hash]
|
31
|
+
# @option options [Integer] :page Page number in the response. The default value is 1. #TODO
|
32
|
+
# @option options [Integer] :on_page Number of mailboxes on each response page. The default value is 30. #TODO
|
33
|
+
# @return [Hash]
|
34
|
+
# @see https://tech.yandex.com/domain/doc/reference/email-list-docpage/
|
35
|
+
# @todo Add support for options
|
36
|
+
def get_mailboxes(domain, options = {})
|
37
|
+
req = self.class.get("/admin/email/list", {query: {domain: domain}})
|
38
|
+
req.parsed_response['accounts']
|
39
|
+
end
|
40
|
+
|
41
|
+
# Used for editing mailbox parameters: password, user's first and last name, and so on.
|
42
|
+
# @param domain [String] Name of the domain.
|
43
|
+
# @param login [String] The email address of the mailbox, in the format “username@domain.com” or “username”.
|
44
|
+
# @param options [Hash]
|
45
|
+
# @option options [String] :password User's new password.
|
46
|
+
# @option options [String] :iname User's first name.
|
47
|
+
# @option options [String] :fname User's last name.
|
48
|
+
# @option options [String] :enabled Whether the mailbox is enabled.
|
49
|
+
# Possible values:
|
50
|
+
# yes — Mailbox is enabled
|
51
|
+
# no — Mailbox is blocked (for example, due to spam distribution or suspected hacking).
|
52
|
+
# @option options [Integer] :birth_date User's date of birth in the format YYYY-MM-DD.
|
53
|
+
# @option options [Integer] :sex User's gender.
|
54
|
+
# Possible values:
|
55
|
+
# 0 — Not specified.
|
56
|
+
# 1 — Male.
|
57
|
+
# 2 — Female.
|
58
|
+
# @option options [Integer] :hintq Secret question.
|
59
|
+
# @option options [Integer] :hinta Answer to the secret question.
|
60
|
+
# @return [Hash]
|
61
|
+
# @example Example Usage
|
62
|
+
# client.update_mailbox('google.com', 'hi', {sex: 0, birth_date: "1998-09-04"})
|
63
|
+
# @example Example Response
|
64
|
+
# {
|
65
|
+
# "domain": "{domain name}",
|
66
|
+
# "login":"{email address of the mailbox}",
|
67
|
+
# "uid": "{mailbox ID}",
|
68
|
+
# "success": "{status of request execution}",
|
69
|
+
# "account":
|
70
|
+
# {
|
71
|
+
# "uid": "{mailbox ID}",
|
72
|
+
# "iname": "{user's name}",
|
73
|
+
# "sex": "{user's gender}",
|
74
|
+
# "ready": "{mailbox readiness}",
|
75
|
+
# "hintq": "{pet's favorite food ???}",
|
76
|
+
# "aliases":
|
77
|
+
# [
|
78
|
+
# "{alias name}",
|
79
|
+
# ...
|
80
|
+
# ],
|
81
|
+
# "enabled": "{whether mailbox is working}",
|
82
|
+
# "maillist": "{mailing list flag}",
|
83
|
+
# "fname": "{user's last name}",
|
84
|
+
# "birth_date": "{user's date of birth}",
|
85
|
+
# "login": "{mailbox email address}",
|
86
|
+
# "fio": "{user's full name}"
|
87
|
+
# }
|
88
|
+
# }
|
89
|
+
# @see https://tech.yandex.com/domain/doc/reference/email-edit-docpage/
|
90
|
+
def update_mailbox(domain, login, options = {})
|
91
|
+
query = {domain: domain, login: login}
|
92
|
+
query = query.merge(options)
|
93
|
+
req = self.class.post("/admin/email/edit", query: query)
|
94
|
+
req.parsed_response
|
95
|
+
end
|
96
|
+
|
97
|
+
# Used for deleting a mailbox on a domain
|
98
|
+
# @param domain [String] Name of the domain.
|
99
|
+
# @param login [String] The email address of the mailbox, in the format “username@domain.com” or “username”.
|
100
|
+
# @return [Hash] Parsed Response
|
101
|
+
# @example Example Usage
|
102
|
+
# client.delete_mailbox('google.com', 'hi')
|
103
|
+
# @example Example Response
|
104
|
+
# {
|
105
|
+
# "domain": "{domain name}",
|
106
|
+
# "login":"{mailbox address}",
|
107
|
+
# "success": "{status of request execution}"
|
108
|
+
# }
|
109
|
+
# @see https://api.yandex.com.tr/kurum/doc/reference/email-del.xml
|
110
|
+
def delete_mailbox(domain, login)
|
111
|
+
req = self.class.post("/admin/email/del", {query: {domain: domain, login: login}})
|
112
|
+
req.parsed_response
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "yandex_domains/version"
|
2
|
+
require "yandex_domains/admin/domain"
|
3
|
+
require "yandex_domains/admin/email"
|
4
|
+
require "httparty"
|
5
|
+
|
6
|
+
module YandexDomains
|
7
|
+
class Client
|
8
|
+
include HTTParty
|
9
|
+
attr_accessor :pdd_token
|
10
|
+
base_uri 'https://pddimp.yandex.ru/api2'
|
11
|
+
|
12
|
+
# Initializes a new Client
|
13
|
+
#
|
14
|
+
# @param pdd_token [String]
|
15
|
+
# @return [YandexDomains::Client]
|
16
|
+
def initialize(pdd_token)
|
17
|
+
self.pdd_token = pdd_token
|
18
|
+
self.class.headers 'PddToken' => pdd_token
|
19
|
+
end
|
20
|
+
|
21
|
+
include YandexDomains::Admin::Domain
|
22
|
+
include YandexDomains::Admin::Email
|
23
|
+
end
|
24
|
+
end
|
data/lib/yandex_domains.rb
CHANGED
@@ -1,149 +1 @@
|
|
1
|
-
require "yandex_domains/
|
2
|
-
require "httparty"
|
3
|
-
|
4
|
-
module YandexDomains
|
5
|
-
class Client
|
6
|
-
include HTTParty
|
7
|
-
attr_accessor :pdd_token
|
8
|
-
base_uri 'https://pddimp.yandex.ru/api2'
|
9
|
-
|
10
|
-
# Initializes a new Client
|
11
|
-
#
|
12
|
-
# @param pdd_token [String]
|
13
|
-
# @return [YandexDomains::Client]
|
14
|
-
def initialize(pdd_token)
|
15
|
-
self.pdd_token = pdd_token
|
16
|
-
self.class.headers 'PddToken' => pdd_token
|
17
|
-
end
|
18
|
-
|
19
|
-
# Used for signing up a domain.
|
20
|
-
# @param domain [String]
|
21
|
-
# @return [Hash]
|
22
|
-
# @see https://api.yandex.com.tr/kurum/doc/reference/domain-register.xml
|
23
|
-
def connect_domain(domain)
|
24
|
-
req = self.class.post("/admin/domain/register", {query: {domain: domain}})
|
25
|
-
req.parsed_response
|
26
|
-
end
|
27
|
-
|
28
|
-
# The request is used for getting the results of the last check, the date and time the check was performed,
|
29
|
-
# and the date and time of the next check.
|
30
|
-
# @param [String] domain
|
31
|
-
# @return [Hash] Parsed Response
|
32
|
-
# @see https://api.yandex.com.tr/kurum/doc/reference/domain-registrationstatus.xml
|
33
|
-
def registration_status(domain)
|
34
|
-
req = self.class.get("/admin/domain/registration_status", {query: {domain: domain}})
|
35
|
-
req.parsed_response
|
36
|
-
end
|
37
|
-
|
38
|
-
# Used for adding a mailbox for the domain.
|
39
|
-
# @param domain [String] Name of the domain.
|
40
|
-
# @param login [String] The email address of the mailbox, in the format “username@domain.ru” or “username”.
|
41
|
-
# @param password [String] User's password.
|
42
|
-
# The password must:
|
43
|
-
# contain from 6 to 20 characters — Latin letters, numbers, and the symbols “!”, “@”, “#”, “$”, “%”, “^”, “&”, “*”, “(”, “)”, “_”, “-”, “+”, “:”, “;”, “,”, “.”
|
44
|
-
# be different from the username.
|
45
|
-
# @return [Hash] Parsed Response
|
46
|
-
# @example Example create hi@google.com with strongpassword
|
47
|
-
# client.add_mailbox('google.com', 'hi', 'strongpassword')
|
48
|
-
# @example Return Hash
|
49
|
-
# {
|
50
|
-
# "domain": "{domain name}",
|
51
|
-
# "login":"{email address of the mailbox}",
|
52
|
-
# "uid": "{mailbox ID}",
|
53
|
-
# "success": "{status of request execution}"
|
54
|
-
# }
|
55
|
-
#
|
56
|
-
# @see https://api.yandex.com.tr/kurum/doc/reference/email-add.xml
|
57
|
-
def add_mailbox(domain, login, password)
|
58
|
-
req = self.class.post("/admin/email/add", {query: {domain: domain, login: login, password: password}})
|
59
|
-
req.parsed_response
|
60
|
-
end
|
61
|
-
|
62
|
-
# Used for getting a list of the domain's mailboxes.
|
63
|
-
# @param domain [String] Name of the domain.
|
64
|
-
# @param options [Hash]
|
65
|
-
# @option options [Integer] :page Page number in the response. The default value is 1. #TODO
|
66
|
-
# @option options [Integer] :on_page Number of mailboxes on each response page. The default value is 30. #TODO
|
67
|
-
# @return [Hash]
|
68
|
-
# @see https://tech.yandex.com/domain/doc/reference/email-list-docpage/
|
69
|
-
# @todo Add support for options
|
70
|
-
def get_mailboxes(domain, options = {})
|
71
|
-
req = self.class.get("/admin/email/list", {query: {domain: domain}})
|
72
|
-
req.parsed_response['accounts']
|
73
|
-
end
|
74
|
-
|
75
|
-
# Used for editing mailbox parameters: password, user's first and last name, and so on.
|
76
|
-
# @param domain [String] Name of the domain.
|
77
|
-
# @param login [String] The email address of the mailbox, in the format “username@domain.com” or “username”.
|
78
|
-
# @param options [Hash]
|
79
|
-
# @option options [String] :password User's new password.
|
80
|
-
# @option options [String] :iname User's first name.
|
81
|
-
# @option options [String] :fname User's last name.
|
82
|
-
# @option options [String] :enabled Whether the mailbox is enabled.
|
83
|
-
# Possible values:
|
84
|
-
# yes — Mailbox is enabled
|
85
|
-
# no — Mailbox is blocked (for example, due to spam distribution or suspected hacking).
|
86
|
-
# @option options [Integer] :birth_date User's date of birth in the format YYYY-MM-DD.
|
87
|
-
# @option options [Integer] :sex User's gender.
|
88
|
-
# Possible values:
|
89
|
-
# 0 — Not specified.
|
90
|
-
# 1 — Male.
|
91
|
-
# 2 — Female.
|
92
|
-
# @option options [Integer] :hintq Secret question.
|
93
|
-
# @option options [Integer] :hinta Answer to the secret question.
|
94
|
-
# @return [Hash]
|
95
|
-
# @example Example Usage
|
96
|
-
# client.update_mailbox('google.com', 'hi', {sex: 0, birth_date: "1998-09-04"})
|
97
|
-
# @example Example Response
|
98
|
-
# {
|
99
|
-
# "domain": "{domain name}",
|
100
|
-
# "login":"{email address of the mailbox}",
|
101
|
-
# "uid": "{mailbox ID}",
|
102
|
-
# "success": "{status of request execution}",
|
103
|
-
# "account":
|
104
|
-
# {
|
105
|
-
# "uid": "{mailbox ID}",
|
106
|
-
# "iname": "{user's name}",
|
107
|
-
# "sex": "{user's gender}",
|
108
|
-
# "ready": "{mailbox readiness}",
|
109
|
-
# "hintq": "{pet's favorite food ???}",
|
110
|
-
# "aliases":
|
111
|
-
# [
|
112
|
-
# "{alias name}",
|
113
|
-
# ...
|
114
|
-
# ],
|
115
|
-
# "enabled": "{whether mailbox is working}",
|
116
|
-
# "maillist": "{mailing list flag}",
|
117
|
-
# "fname": "{user's last name}",
|
118
|
-
# "birth_date": "{user's date of birth}",
|
119
|
-
# "login": "{mailbox email address}",
|
120
|
-
# "fio": "{user's full name}"
|
121
|
-
# }
|
122
|
-
# }
|
123
|
-
# @see https://tech.yandex.com/domain/doc/reference/email-edit-docpage/
|
124
|
-
def update_mailbox(domain, login, options = {})
|
125
|
-
query = {domain: domain, login: login}
|
126
|
-
query = query.merge(options)
|
127
|
-
req = self.class.post("/admin/email/edit", query: query)
|
128
|
-
req.parsed_response
|
129
|
-
end
|
130
|
-
# Used for deleting a mailbox on a domain
|
131
|
-
# @param domain [String] Name of the domain.
|
132
|
-
# @param login [String] The email address of the mailbox, in the format “username@domain.com” or “username”.
|
133
|
-
# @return [Hash] Parsed Response
|
134
|
-
# @example Example Usage
|
135
|
-
# client.delete_mailbox('google.com', 'hi')
|
136
|
-
# @example Example Response
|
137
|
-
# {
|
138
|
-
# "domain": "{domain name}",
|
139
|
-
# "login":"{mailbox address}",
|
140
|
-
# "success": "{status of request execution}"
|
141
|
-
# }
|
142
|
-
# @see https://api.yandex.com.tr/kurum/doc/reference/email-del.xml
|
143
|
-
def delete_mailbox(domain, login)
|
144
|
-
req = self.class.post("/admin/email/del", {query: {domain: domain, login: login}})
|
145
|
-
req.parsed_response
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
end
|
1
|
+
require "yandex_domains/client"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yandex_domains
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Beydogan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,6 +68,9 @@ files:
|
|
68
68
|
- bin/console
|
69
69
|
- bin/setup
|
70
70
|
- lib/yandex_domains.rb
|
71
|
+
- lib/yandex_domains/admin/domain.rb
|
72
|
+
- lib/yandex_domains/admin/email.rb
|
73
|
+
- lib/yandex_domains/client.rb
|
71
74
|
- lib/yandex_domains/version.rb
|
72
75
|
- yandex_domains.gemspec
|
73
76
|
homepage: http://github.com/beydogan/yandex-domains
|
@@ -95,3 +98,4 @@ signing_key:
|
|
95
98
|
specification_version: 4
|
96
99
|
summary: Ruby client for Yandex.Mail for Domains API
|
97
100
|
test_files: []
|
101
|
+
has_rdoc:
|