Class: MailRU::API

Inherits:
Object
  • Object
show all
Defined in:
lib/mailru-api/api.rb,
lib/mailru-api/dsl.rb,
lib/mailru-api/error.rb,
lib/mailru-api/request.rb

Defined Under Namespace

Modules: Format Classes: AccessToObjectDeniedError, ApplicationIsNotInstalledError, ApplicationLookupFailedError, AuthorizationFailedError, ConfigurationBuilder, DSL, Error, GetRequest, IncorrectImageError, IncorrectSignatureError, InvalidParameterError, MethodIsDeprecatedError, PermissionDeniedError, PostRequest, Request, UnknownError, UnknownMethodCalledError

Constant Summary collapse

PATH =
'http://www.appsmail.ru/platform/api'
PARAMS =
[:app_id, :secret_key, :private_key, :session_key, :uid, :format]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ API

Returns a new instance of API.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mailru-api/api.rb', line 30

def initialize options = {}, &block
  @configuration = options

  if block_given?
    if block.arity == 1
      yield self
    else
      @configuration.merge! ConfigurationBuilder.new(&block).configuration
    end
  end
end

Instance Method Details

#audioObject



62
63
64
65
66
67
68
# File 'lib/mailru-api/api.rb', line 62

def audio
  DSL.new(self, 'audio') do
    api 'get'
    api 'link'
    api 'search'
  end
end

#eventsObject



70
71
72
73
74
# File 'lib/mailru-api/api.rb', line 70

def events
  DSL.new(self, 'events') do
    api 'getNewCount'
  end
end

#friendsObject



76
77
78
79
80
81
82
83
# File 'lib/mailru-api/api.rb', line 76

def friends
  DSL.new(self, 'friends') do
    api 'get'
    api 'getAppUsers'
    api 'getInvitationsCount'
    api 'getOnline'
  end
end

#get(name, params = {}, secure = Request::Secure::Any) ⇒ Object



54
55
56
# File 'lib/mailru-api/api.rb', line 54

def get name, params = {}, secure = Request::Secure::Any
  GetRequest.new(self, name, params, secure).get
end

#guestbookObject



85
86
87
88
89
90
# File 'lib/mailru-api/api.rb', line 85

def guestbook
  DSL.new(self, 'guestbook') do
    api 'get'
    api 'post', :post
  end
end

#mailObject



92
93
94
95
96
# File 'lib/mailru-api/api.rb', line 92

def mail
  DSL.new(self, 'mail') do
    api 'getUnreadCount'
  end
end

#messagesObject



98
99
100
101
102
103
104
105
# File 'lib/mailru-api/api.rb', line 98

def messages
  DSL.new(self, 'messages') do
    api 'getThread'
    api 'getThreadsList'
    api 'getUnreadCount'
    api 'post', :post
  end
end

#mobileObject



107
108
109
110
111
# File 'lib/mailru-api/api.rb', line 107

def mobile
  DSL.new(self, 'mobile') do
    api 'getCanvas', :get, Request::Secure::No
  end
end

#notificationsObject



113
114
115
116
117
# File 'lib/mailru-api/api.rb', line 113

def notifications
  DSL.new(self, 'notifications') do
    api 'send', :get, Request::Secure::Yes
  end
end

#photosObject



119
120
121
122
123
124
125
126
# File 'lib/mailru-api/api.rb', line 119

def photos
  DSL.new(self, 'photos')  do
    api 'createAlbum'
    api 'get'
    api 'getAlbums'
    api 'upload', :post
  end
end

#post(name, params = {}, secure = Request::Secure::Any) ⇒ Object



58
59
60
# File 'lib/mailru-api/api.rb', line 58

def post name, params = {}, secure = Request::Secure::Any
  PostRequest.new(self, name, params, secure).post
end

#streamObject



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/mailru-api/api.rb', line 128

def stream
  DSL.new(self, 'stream') do
    api 'comment'
    api 'get'
    api 'getByAuthor'
    api 'like'
    api 'post', :post
    api 'share', :post
    api 'unlike'
  end
end

#usersObject



140
141
142
143
144
145
146
147
# File 'lib/mailru-api/api.rb', line 140

def users
  DSL.new(self, 'users') do
    api 'getBalance'
    api 'getInfo'
    api 'hasAppPermission'
    api 'isAppUser'
  end
end