yandex_domains 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b585be5a4b837cadbb735a27f9e015e382ae3daf
4
+ data.tar.gz: 9794d4a261ac075cce892c712b01ae64cef7134f
5
+ SHA512:
6
+ metadata.gz: 2b89af835baa920e2e3929423467cc9b726fa113c09ecf1b82034443399afa67d3696c5ed6c6ad5c3138985a9f9cd88c63b9bc0ed4a58ce55606f7650004c839
7
+ data.tar.gz: 0c434f3406289682f91fd481101ea62449d97b6a8974750bbc157936f82cf47455fe339414b3bbb6a8a3893c71ce0055c90a2fd0271e6237eae20d0947d54ea4
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
11
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yandex_domains.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # YandexDomains
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yandex_domains`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'yandex_domains'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install yandex_domains
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/yandex_domains/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yandex_domains"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,149 @@
1
+ require "yandex_domains/version"
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 editing mailbox parameters: password, user's first and last name, and so on.
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
@@ -0,0 +1,3 @@
1
+ module YandexDomains
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yandex_domains/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yandex_domains"
8
+ spec.version = YandexDomains::VERSION
9
+ spec.authors = ["Mehmet Beydogan"]
10
+ spec.email = ["m@mehmet.pw"]
11
+
12
+ spec.summary = %q{Ruby client for Yandex.Mail for Domains API}
13
+ spec.homepage = "http://github.com/beydogan/yandex-domains"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "httparty", "~> 0.13.3"
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yandex_domains
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mehmet Beydogan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.3
55
+ description:
56
+ email:
57
+ - m@mehmet.pw
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/yandex_domains.rb
71
+ - lib/yandex_domains/version.rb
72
+ - yandex_domains.gemspec
73
+ homepage: http://github.com/beydogan/yandex-domains
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.6
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Ruby client for Yandex.Mail for Domains API
97
+ test_files: []