yandex-pdd-2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ebaf642201e64e061f50f8e3b89eaa1b7b8babee
4
+ data.tar.gz: d683287f0522ff0c794c908fdc1de9e8fa7897c7
5
+ SHA512:
6
+ metadata.gz: 25bbdbdf12982680952d1f4a0ddc71a77a58ac748d6896f1d584186d28bbc11d481ef188f55b1a61aecfd5580058092b4ec08e29889daf35009fd5ec538c27d9
7
+ data.tar.gz: 8ac4a653722207907be4a159a6bd00ca28276367cf19e8ec91178d346ba1640a9e3f3bd31bac3eb79fafef2dae5ffc41ce4817e36868d8e0722d1a5ececa0a99
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.idea/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yandex-pdd.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dmitry Makeev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Yandex-Pdd
2
+
3
+ Unofficial Yandex Mail for Domain service API implementation.
4
+
5
+ - [x] Domains
6
+ - [x] Domain's mailboxes
7
+ - [x] Subscriptions list
8
+ - [x] Managing subscribers
9
+ - [ ] Import
10
+ - [ ] Sharing domain's management privileges
11
+ - [ ] Managing DKIM
12
+ - [ ] Managing DNS
13
+ - [ ] Managing OAuth features
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'yandex-pdd'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install yandex-pdd
30
+
31
+ ## Usage
32
+
33
+ First of all [create access token](https://pddimp.yandex.ru/api2/registrar/get_token)
34
+
35
+ Initialize client via access token:
36
+ ```ruby
37
+ client = Yandex::Pdd::Client.new('PDD_TOKEN')
38
+ ```
39
+
40
+ Call to API:
41
+ ```ruby
42
+ client.mailbox_list('domain_name')
43
+ ```
44
+
45
+ Methods are available:
46
+ ###### Domains
47
+ ```ruby
48
+ domain_list
49
+ domain_register
50
+ domain_registration_status
51
+ domain_details
52
+ domain_set_country
53
+ ```
54
+
55
+ ###### Mailboxes
56
+ ```ruby
57
+ mailbox_add
58
+ mailbox_list
59
+ mailbox_edit
60
+ mailbox_delete
61
+ mailbox_counters
62
+ ```
63
+ ## Development
64
+
65
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
66
+
67
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/dskyyy/yandex-pdd]()
72
+
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
77
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'yandex/pdd'
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/yandex/pdd.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'httparty'
2
+
3
+ require 'yandex/pdd/version'
4
+ require 'yandex/pdd/client'
5
+
6
+ module Yandex
7
+ module Pdd
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ require 'yandex/pdd/client/connection'
2
+
3
+ require 'yandex/pdd/client/domains'
4
+ require 'yandex/pdd/client/mailboxes'
5
+
6
+ module Yandex
7
+ module Pdd
8
+ class Client
9
+ include HTTParty
10
+ include Yandex::Pdd::Client::Connection
11
+ include Yandex::Pdd::Client::Domains
12
+ include Yandex::Pdd::Client::Mailboxes
13
+
14
+ base_uri 'https://pddimp.yandex.ru'
15
+ format :json
16
+
17
+ def initialize(token = nil)
18
+ @token = token || ENV['PDD_TOKEN']
19
+
20
+ self.class.default_options.merge!(headers: { PddToken: @token })
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ module Yandex
2
+ module Pdd
3
+ class Client
4
+ module Connection
5
+ def get(path, options = {})
6
+ request :get, path, options
7
+ end
8
+
9
+ def post(path, options = {})
10
+ request :post, path, options
11
+ end
12
+
13
+ def put(path, options = {})
14
+ request :put, path, options
15
+ end
16
+
17
+ def patch(path, options = {})
18
+ request :patch, path, options
19
+ end
20
+
21
+ def delete(path, options = {})
22
+ request :delete, path, options
23
+ end
24
+
25
+ private
26
+
27
+ def request(http_method, path, options)
28
+ response = self.class.send(http_method, path, body: options)
29
+ response.parsed_response
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,52 @@
1
+ module Yandex
2
+ module Pdd
3
+ class Client
4
+ module Domains
5
+ # page=<Page number>
6
+ # on_page=<Domains per page>
7
+ def domain_list(page = nil, on_page = nil)
8
+ query = {
9
+ page: page,
10
+ on_page: on_page
11
+ }
12
+
13
+ get('/api2/admin/domain/domains', query)
14
+ end
15
+
16
+ # domain=<Domain name>
17
+ def domain_register(options = {})
18
+ post('/api2/admin/domain/register', options)
19
+ end
20
+
21
+ # domain=<Domain name>
22
+ def domain_registration_status(domain)
23
+ query = {
24
+ domain: domain
25
+ }
26
+
27
+ get('/api2/admin/domain/registration_status', query)
28
+ end
29
+
30
+ # domain=<Domain name>
31
+ def domain_details(domain)
32
+ query = {
33
+ domain: domain
34
+ }
35
+
36
+ get('/api2/admin/domain/details', query)
37
+ end
38
+
39
+ # domain=<Domain name>
40
+ def domain_delete(options = {})
41
+ post('/api2/admin/domain/delete', options)
42
+ end
43
+
44
+ # domain=<Domain name>
45
+ # country=<Country code>
46
+ def domain_set_country(options = {})
47
+ post('/api2/admin/domain/settings/set_country', options)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,59 @@
1
+ module Yandex
2
+ module Pdd
3
+ class Client
4
+ module Mailboxes
5
+ # domain=<Domain name>
6
+ # login=<Login>
7
+ # password=<Password>
8
+ def mailbox_add(options = {})
9
+ post('/api2/admin/email/add', options)
10
+ end
11
+
12
+ # domain=<Domain>
13
+ # page=<Page number>
14
+ # on_page=<Mailboxes per page>
15
+ def mailbox_list(domain, page = nil, on_page = nil)
16
+ query = {
17
+ domain: domain,
18
+ page: page,
19
+ on_page: on_page
20
+ }
21
+
22
+ get('/api2/admin/email/list', query)
23
+ end
24
+
25
+ # domain=<Domain name>
26
+ # login=<Email or login>|uid=<Mailbox ID>
27
+ # password=<The new password>
28
+ # iname=<Name>
29
+ # fname=<Last name>
30
+ # enabled=<State>
31
+ # birth_date=<Date of birth>
32
+ # sex=<Sex>
33
+ # hintq=<Secret answer>
34
+ # hinta=<Secret answer key>
35
+ def mailbox_edit(options = {})
36
+ post('/api2/admin/email/edit', options)
37
+ end
38
+
39
+ # domain=<Domain name>
40
+ # login=<Email or login>|uid=<Mailbox ID>
41
+ def mailbox_delete(options = {})
42
+ post('/api2/admin/email/del', options)
43
+ end
44
+
45
+ # domain=<Domain name>
46
+ # login=<Email or login>|uid=<Mailbox ID>
47
+ def mailbox_counters(domain, login = nil, uid = nil)
48
+ query = {
49
+ domain: domain,
50
+ login: login,
51
+ uid: uid
52
+ }
53
+
54
+ get('/api2/admin/email/counters', query)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,28 @@
1
+ module Yandex
2
+ module Pdd
3
+ class Client
4
+ module Maillists
5
+ # domain=<Domain name>
6
+ # maillist=<Email or maillist login>
7
+ def maillist_add(options = {})
8
+ post('/api2/admin/email/ml/add', options)
9
+ end
10
+
11
+ # domain=<Domain name>
12
+ def maillist_list(domain)
13
+ query = {
14
+ doamin: domain
15
+ }
16
+
17
+ get('/api2/admin/email/ml/list', query)
18
+ end
19
+
20
+ # domain=<Domain name>
21
+ # maillist=<Email or maillist login>|maillist_uid=<Maillist ID>
22
+ def maillist_delete(options = {})
23
+ post('/api2/admin/email/ml/del', options)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,54 @@
1
+ module Yandex
2
+ module Pdd
3
+ class Client
4
+ module Subscriptions
5
+ # domain=<Domain name>
6
+ # maillist=<Email or subscription login>|maillist_uid=<Subscription ID>
7
+ # subscriber=<Subscriber's email>|subscriber_uid=<Subscriber's ID>
8
+ # can_send_on_behalf=<Subscriber's status>
9
+ def subscription_add(options = {})
10
+ post('/api2/admin/email/ml/subscribe', options)
11
+ end
12
+
13
+ # domain=<Domain name>
14
+ # maillist=<Email or subscription login>|maillist_uid=<Subscription ID>
15
+ def subscription_sublist(domain, maillist = nil, maillist_uid = nil)
16
+ query = {
17
+ domain: domain,
18
+ maillist: maillist,
19
+ maillist_uid: maillist_uid
20
+ }
21
+
22
+ get('/api2/admin/email/ml/subscribers', query)
23
+ end
24
+
25
+ def subscription_destroy(options = {})
26
+ post('/api2/admin/email/ml/unsubscribe', options)
27
+ end
28
+
29
+ # domain=<Domain name>
30
+ # maillist=<Email or subscription login>|maillist_uid=<Subscription ID>
31
+ # subscriber=<Subscriber's email>|subscriber_uid=<Subscriber's ID>
32
+ def subscription_status(domain, maillist = nil, maillist_uid = nil, subscriber = nil, subscriber_uid = nil)
33
+ query = {
34
+ domain: domain,
35
+ maillist: maillist,
36
+ maillist_uid: maillist_uid,
37
+ subscriber: subscriber,
38
+ subscriber_uid: subscriber_uid
39
+ }
40
+
41
+ get('/api2/admin/email/ml/get_can_send_on_behalf', query)
42
+ end
43
+
44
+ # domain=<Domain name>
45
+ # maillist=<Email or subscription login>|maillist_uid=<Subscription ID>
46
+ # subscriber=<Subscriber's email>|subscriber_uid=<Subscriber's ID>
47
+ # can_send_on_behalf=<Subscriber's status>
48
+ def subscription_set_status(options = {})
49
+ post('/api2/admin/email/ml/set_can_send_on_behalf', options)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Yandex
2
+ module Pdd
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'yandex/pdd/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'yandex-pdd-2'
7
+ spec.version = Yandex::Pdd::VERSION
8
+ spec.authors = ['Dmitry Makeev']
9
+ spec.email = ['dmakeev@gmail.com']
10
+
11
+ spec.summary = 'Yandex PDD API client'
12
+ spec.description = 'Yandex Mail for Domain API client'
13
+ spec.homepage = 'https://github.com/dskyyy/yandex-pdd'
14
+ spec.license = 'MIT'
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.11'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'rubocop'
24
+
25
+ spec.add_dependency 'httparty'
26
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yandex-pdd-2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Makeev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-09 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Yandex Mail for Domain API client
84
+ email:
85
+ - dmakeev@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - lib/yandex/pdd.rb
98
+ - lib/yandex/pdd/client.rb
99
+ - lib/yandex/pdd/client/connection.rb
100
+ - lib/yandex/pdd/client/domains.rb
101
+ - lib/yandex/pdd/client/mailboxes.rb
102
+ - lib/yandex/pdd/client/maillists.rb
103
+ - lib/yandex/pdd/client/subscriptions.rb
104
+ - lib/yandex/pdd/version.rb
105
+ - yandex-pdd.gemspec
106
+ homepage: https://github.com/dskyyy/yandex-pdd
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Yandex PDD API client
130
+ test_files: []
131
+ has_rdoc: