pechkinrb 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +6 -2
- data/lib/pechkinrb/list.rb +21 -0
- data/lib/pechkinrb/member.rb +9 -1
- data/lib/pechkinrb/pechkin.rb +14 -1
- data/lib/pechkinrb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b12560dec83e2cc81e6e2767488f07ca6f136742
|
4
|
+
data.tar.gz: 5fd46487c190259b0e508f7343ce42ac5651821c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c231c3a005e5f9ce01f5042ba7c4949080a0969490fe2cd33a25d88f29d499689ea1411b023d99b3c1ce96cfa54f5442c8aec1c6356b091c18954a08136325f2
|
7
|
+
data.tar.gz: 0c9198aac51848c50e261658547482f9a3d085899812bbe77016bb37a87da33d94614a115d5a842e54bd87076be9ef5ffdab6efe7f892d7682758386b17db175
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# PechkinRb
|
2
|
+
|
3
|
+
[](https://codeclimate.com/github/crsde/PechkinRb)
|
2
4
|
|
3
5
|
This gem provides you with easy Ruby interface for pechkin-mail.ru mail service.
|
4
6
|
|
7
|
+
Documentation available at http://www.rubydoc.info/github/crsde/PechkinRb
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -25,7 +29,7 @@ Or install it yourself as:
|
|
25
29
|
|
26
30
|
## Contributing
|
27
31
|
|
28
|
-
1. Fork it ( https://github.com/
|
32
|
+
1. Fork it ( https://github.com/crsde/PechkinRb/fork )
|
29
33
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
34
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
35
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/pechkinrb/list.rb
CHANGED
@@ -41,6 +41,27 @@ module Pechkin
|
|
41
41
|
connection.call_method('lists.get_members', params.merge(id_params)).map {|member| Pechkin::Member.new(connection, member)}
|
42
42
|
end
|
43
43
|
|
44
|
+
# Alias to get_members
|
45
|
+
#
|
46
|
+
alias_method :members, :get_members
|
47
|
+
|
48
|
+
# Invokes 'lists.add_memner' method
|
49
|
+
#
|
50
|
+
# @param params [Hash] Params to be passed
|
51
|
+
# @return [Pechkin::Member] New member instance
|
52
|
+
def add_member
|
53
|
+
added = connection.call_method('lists.add_member', params.merge(id_params))
|
54
|
+
get_members(added).first
|
55
|
+
end
|
56
|
+
|
57
|
+
# Invokes 'lists.unsubscribe_member' API method
|
58
|
+
#
|
59
|
+
# @param params [Hash] Params to be passed
|
60
|
+
# @return [Fixnum] Count of unsubscribed members
|
61
|
+
def unsubscribe_member(params)
|
62
|
+
connection.call_method('lists.unsubscribe_member', params.merge(id_params))['unsubscribed']
|
63
|
+
end
|
64
|
+
|
44
65
|
private
|
45
66
|
|
46
67
|
def id_params
|
data/lib/pechkinrb/member.rb
CHANGED
@@ -47,11 +47,19 @@ module Pechkin
|
|
47
47
|
|
48
48
|
# Invokes 'lists.get_lists' API method to retrieve member list
|
49
49
|
#
|
50
|
-
# @
|
50
|
+
# @param params [Pechkin::List] List instance, accosiated with member
|
51
51
|
def list
|
52
52
|
connection.get_list(list_id)
|
53
53
|
end
|
54
54
|
|
55
|
+
# Invokes 'lists.unsubscribe_member' API method
|
56
|
+
#
|
57
|
+
# @param params [Hash] Params to be passed
|
58
|
+
# @return [Fixnum] Count of unsubscribed members
|
59
|
+
def unsubscribe_member(params)
|
60
|
+
connection.call_method('lists.unsubscribe_member', params.merge(id_params))['unsubscribed']
|
61
|
+
end
|
62
|
+
|
55
63
|
private
|
56
64
|
|
57
65
|
def id_params
|
data/lib/pechkinrb/pechkin.rb
CHANGED
@@ -30,7 +30,7 @@ module Pechkin
|
|
30
30
|
# @param method [String] Method name, corresponding API reference https://pechkin-mail.ru/api/
|
31
31
|
# @param params [Hash] Params to be passed
|
32
32
|
def call_method(method, params = {})
|
33
|
-
response = connection.post '/', {method: method}.merge(credentials).merge(params)
|
33
|
+
response = connection.post '/', {method: method}.merge(credentials).merge(params)
|
34
34
|
err_code = response.body["response"]["msg"]["err_code"]
|
35
35
|
unless err_code == 0
|
36
36
|
raise Pechkin::ApiException.new(response.body["response"]["msg"]["text"])
|
@@ -46,6 +46,7 @@ module Pechkin
|
|
46
46
|
call_method('lists.get', params).map {|list_raw| Pechkin::List.new(self, list_raw)}
|
47
47
|
end
|
48
48
|
|
49
|
+
|
49
50
|
# Invokes 'lists.get' API method to retrieve single List object
|
50
51
|
#
|
51
52
|
# @param id [Fixnum] List id
|
@@ -54,6 +55,10 @@ module Pechkin
|
|
54
55
|
lists(list_id: id)[0]
|
55
56
|
end
|
56
57
|
|
58
|
+
# 'list.get' method alias
|
59
|
+
#
|
60
|
+
alias_method :get, :lists
|
61
|
+
|
57
62
|
# Invokes 'lists.get_member' API method
|
58
63
|
#
|
59
64
|
# @param email [String] Email for search
|
@@ -62,6 +67,14 @@ module Pechkin
|
|
62
67
|
call_method('lists.get_member', {email: email}).map {|member| Pechkin::Member.new(connection, member)}
|
63
68
|
end
|
64
69
|
|
70
|
+
# Invokes 'lists.unsubscribe_member' API method
|
71
|
+
#
|
72
|
+
# @param params [Hash] Params to be passed
|
73
|
+
# @return [Fixnum] Count of unsubscribed members
|
74
|
+
def unsubscribe_member(params)
|
75
|
+
call_method('lists.unsubscribe_member', params)['unsubscribed']
|
76
|
+
end
|
77
|
+
|
65
78
|
private
|
66
79
|
|
67
80
|
def credentials
|
data/lib/pechkinrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pechkinrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandr Prokopenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|