mailru-api 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mailru-api.rb CHANGED
@@ -20,7 +20,7 @@ module MailRU
20
20
 
21
21
  class APIConfigurationBuilder
22
22
  attr_reader :configuration
23
-
23
+
24
24
  def initialize(&block)
25
25
  if block_given?
26
26
  @configuration = APIConfiguration.new
@@ -43,11 +43,11 @@ module MailRU
43
43
  def session_key value
44
44
  @configuration.session_key = value
45
45
  end
46
-
46
+
47
47
  def uid value
48
48
  @configuration.uid = value
49
49
  end
50
-
50
+
51
51
  def format value
52
52
  @configuration.format = value
53
53
  end
@@ -60,9 +60,9 @@ module MailRU
60
60
  end
61
61
 
62
62
  PATH = 'http://www.appsmail.ru/platform/api'
63
-
63
+
64
64
  attr_accessor :app_id, :secret_key, :private_key, :session_key, :uid, :format
65
-
65
+
66
66
  def initialize options = {}, &block
67
67
  @app_id = options[:app_id]
68
68
  @secret_key = options[:secret_key]
@@ -88,35 +88,35 @@ module MailRU
88
88
  end
89
89
  end
90
90
  end
91
-
91
+
92
92
  def audio
93
93
  return Audio.new(self)
94
94
  end
95
-
95
+
96
96
  def events
97
97
  return Events.new(self)
98
98
  end
99
-
99
+
100
100
  def friends
101
101
  return Friends.new(self)
102
102
  end
103
-
103
+
104
104
  def guestbook
105
105
  return Guestbook.new(self)
106
106
  end
107
-
107
+
108
108
  def mail
109
109
  return Mail.new(self)
110
110
  end
111
-
111
+
112
112
  def messages
113
113
  return Messages.new(self)
114
114
  end
115
-
115
+
116
116
  def mobile
117
117
  return Mobile.new(self)
118
118
  end
119
-
119
+
120
120
  def notifications
121
121
  return Notifications.new(self)
122
122
  end
@@ -124,11 +124,11 @@ module MailRU
124
124
  def photos
125
125
  return Photos.new(self)
126
126
  end
127
-
127
+
128
128
  def stream
129
129
  return Stream.new(self)
130
130
  end
131
-
131
+
132
132
  def users
133
133
  return Users.new(self)
134
134
  end
@@ -3,21 +3,21 @@
3
3
  module MailRU
4
4
  class API
5
5
  class Audio
6
- def initialize api
7
- @api = api
8
- end
6
+ def initialize api
7
+ @api = api
8
+ end
9
9
 
10
10
  def get params = {}
11
11
  GetRequest.new(@api, 'audio.get', params).get
12
12
  end
13
-
13
+
14
14
  def link params = {}
15
15
  GetRequest.new(@api, 'audio.link', params).get
16
16
  end
17
-
17
+
18
18
  def search params = {}
19
19
  GetRequest.new(@api, 'audio.search', params).get
20
20
  end
21
21
  end
22
- end
22
+ end
23
23
  end
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Events
6
6
  def initialize api
7
7
  @api = api
@@ -11,5 +11,5 @@ module MailRU
11
11
  GetRequest.new(@api, 'events.getNewCount', {}).get
12
12
  end
13
13
  end
14
- end
14
+ end
15
15
  end
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Friends
6
6
  RETURN_OBJECTS = 1
7
7
  RETURN_UIDS = 0
@@ -13,19 +13,19 @@ module MailRU
13
13
  def get params = {}
14
14
  GetRequest.new(@api, 'friends.get', params).get
15
15
  end
16
-
16
+
17
17
  def get_app_users params = {}
18
18
  GetRequest.new(@api, 'friends.getAppUsers', params).get
19
19
  end
20
-
20
+
21
21
  def get_invitations_count params = {}
22
22
  GetRequest.new(@api, 'friends.getInvitationsCount', params).get
23
23
  end
24
-
24
+
25
25
  def get_online params = {}
26
26
  GetRequest.new(@api, 'friends.getOnline', params).get
27
27
  end
28
28
  end
29
- end
29
+ end
30
30
  end
31
31
 
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Guestbook
6
6
  def initialize api
7
7
  @api = api
@@ -15,5 +15,5 @@ module MailRU
15
15
  PostRequest.new(@api, 'guestbook.post', params).post
16
16
  end
17
17
  end
18
- end
18
+ end
19
19
  end
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Mail
6
6
  def initialize api
7
7
  @api = api
@@ -11,5 +11,5 @@ module MailRU
11
11
  GetRequest.new(@api, 'mail.getUnreadCount', params).get
12
12
  end
13
13
  end
14
- end
14
+ end
15
15
  end
@@ -1,16 +1,16 @@
1
1
  #:encoding: utf-8
2
-
2
+
3
3
  module MyMailRU
4
- class API
4
+ class API
5
5
  class Messages
6
6
  def get_thread params = {}
7
7
  GetRequest.new(@api, 'messages.getThread', params).get
8
8
  end
9
-
9
+
10
10
  def get_threads_list params = {}
11
11
  GetRequest.new(@api, 'messages.getThreadsList', params).get
12
12
  end
13
-
13
+
14
14
  def get_unread_count params = {}
15
15
  GetRequest.new(@api, 'messages.getUnreadCount', params).get
16
16
  end
@@ -19,5 +19,5 @@ module MyMailRU
19
19
  PostRequest.new(@api, 'messages.post', params).post
20
20
  end
21
21
  end
22
- end
22
+ end
23
23
  end
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Mobile
6
6
  BASIC = 'basic'
7
7
  SMARTPHONE = 'smartphone'
@@ -14,5 +14,5 @@ module MailRU
14
14
  GetRequest.new(@api, 'mobile.getCanvas', params, Request::Secure::No).get
15
15
  end
16
16
  end
17
- end
17
+ end
18
18
  end
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Photos
6
6
  def initialize api
7
7
  @api = api
@@ -10,11 +10,11 @@ module MailRU
10
10
  def create_album params = {}
11
11
  GetRequest.new(@api, 'photos.createAlbum', params).get
12
12
  end
13
-
13
+
14
14
  def get params = {}
15
15
  GetRequest.new(@api, 'photos.get', params).get
16
16
  end
17
-
17
+
18
18
  def get_albums params = {}
19
19
  GetRequest.new(@api, 'photos.getAlbums', params).get
20
20
  end
@@ -23,5 +23,5 @@ module MailRU
23
23
  PostRequest.new(@api, 'photos.upload', params).post
24
24
  end
25
25
  end
26
- end
26
+ end
27
27
  end
@@ -33,20 +33,20 @@ module MailRU
33
33
  @api.private_key and (@secure == Secure::No or @secure == Secure::Any)
34
34
  end
35
35
 
36
- def signature
37
- return s2s_signature if use_s2s?
38
- return c2s_signature if use_c2s?
36
+ def signature
37
+ return s2s_signature if use_s2s?
38
+ return c2s_signature if use_c2s?
39
39
  ''
40
- end
40
+ end
41
41
 
42
- def c2s_signature
42
+ def c2s_signature
43
43
  Digest::MD5.hexdigest(@api.uid + parameters.sort.join + @api.private_key)
44
- end
45
-
44
+ end
45
+
46
46
  def s2s_signature
47
47
  Digest::MD5.hexdigest(parameters.sort.join + @api.secret_key)
48
48
  end
49
-
49
+
50
50
  def parameters
51
51
  params = {app_id: @api.app_id, method: @method}
52
52
  params.merge!({session_key: @api.session_key}) if @api.session_key
@@ -54,9 +54,9 @@ module MailRU
54
54
  params.merge!(@method_params) if @method_params
55
55
  params.merge!({secure: 1}) if use_s2s?
56
56
 
57
- params.to_a.map{|p| p.join('=')}
57
+ params.to_a.map{|p| p.join('=')}
58
58
  end
59
-
59
+
60
60
  def handle_response response
61
61
  response = response.body unless response.is_a?(String)
62
62
 
@@ -83,14 +83,14 @@ module MailRU
83
83
  response
84
84
  end
85
85
  end
86
-
86
+
87
87
  class GetRequest < Request
88
88
  def get
89
89
  request = URI.escape(PATH + '?' + parameters.push("sig=#{signature}").join('&'))
90
90
  handle_response(Net::HTTP.get(URI(request)))
91
91
  end
92
92
  end
93
-
93
+
94
94
  class PostRequest < Request
95
95
  def post
96
96
  uri = URI(PATH)
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Stream
6
6
  def initialize api
7
7
  @api = api
@@ -10,15 +10,15 @@ module MailRU
10
10
  def comment params = {}
11
11
  GetRequest.new(@api, 'stream.comment', params).get
12
12
  end
13
-
13
+
14
14
  def get params = {}
15
15
  GetRequest.new(@api, 'stream.get', params).get
16
16
  end
17
-
17
+
18
18
  def get_by_author params = {}
19
19
  GetRequest.new(@api, 'stream.getByAuthor', params).get
20
20
  end
21
-
21
+
22
22
  def like params = {}
23
23
  GetRequest.new(@api, 'stream.like', params).get
24
24
  end
@@ -30,10 +30,10 @@ module MailRU
30
30
  def share params ={}
31
31
  PostRequest.new(@api, 'stream.share', params).post
32
32
  end
33
-
33
+
34
34
  def unlike params = {}
35
35
  GetRequest.new(@api, 'stream.unlike', params).get
36
36
  end
37
37
  end
38
- end
38
+ end
39
39
  end
@@ -1,7 +1,7 @@
1
1
  #:encoding: utf-8
2
2
 
3
3
  module MailRU
4
- class API
4
+ class API
5
5
  class Users
6
6
  def initialize api
7
7
  @api = api
@@ -10,15 +10,15 @@ module MailRU
10
10
  def get_balance
11
11
  GetRequest.new(@api, 'users.getBalance', params).get
12
12
  end
13
-
13
+
14
14
  def get_info params = {}
15
15
  GetRequest.new(@api, 'users.getInfo', params).get
16
16
  end
17
-
17
+
18
18
  def has_app_permission params = {}
19
19
  GetRequest.new(@api, 'users.hasAppPermission', params).get
20
20
  end
21
-
21
+
22
22
  def is_app_user
23
23
  GetRequest.new(@api, 'users.isAppUser', params).get
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailru-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2010-04-28 00:00:00.000000000 Z
12
+ date: 2013-09-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: MailRU API for Ruby
15
15
  email: demin.alexey@inbox.ru