draugiem 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/draugiem.rb +41 -0
- metadata +45 -0
data/lib/draugiem.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Draugiem
|
6
|
+
|
7
|
+
API_URL = 'http://api.draugiem.lv/json/'
|
8
|
+
attr_accessor :app_key, :user_key
|
9
|
+
|
10
|
+
def initialize app_key, user_key = nil
|
11
|
+
@app_key, @user_key = app_key, user_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def send(params = {})
|
15
|
+
params[:app] = app_key
|
16
|
+
params[:apikey] = user_key
|
17
|
+
|
18
|
+
JSON.parse(Net::HTTP.post_form(URI.parse(API_URL), params).body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def authorize auth_code
|
22
|
+
send action: 'authorize', code: auth_code
|
23
|
+
end
|
24
|
+
|
25
|
+
def user_data
|
26
|
+
send action: 'userdata'
|
27
|
+
end
|
28
|
+
|
29
|
+
def app_friends page = 1, limit = 20, return_ids = false
|
30
|
+
resp = send action: 'app_friends', page: page, limit: limit, show: return_ids ? 'ids' : nil
|
31
|
+
if return_ids && resp['userids'].any?
|
32
|
+
resp = {'total' => resp['total'], 'userids' => resp.map{|k, v| k.to_i}}
|
33
|
+
end
|
34
|
+
resp
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_activity text, prefix = nil, link = nil, params = {}
|
38
|
+
send({action: 'add_activity', text: text, prefix: prefix, link: link}.merge(params))
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: draugiem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maksim Berjoza
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-16 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Draugiem.lv ruby api client
|
15
|
+
email: maksim.berjoza@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/draugiem.rb
|
21
|
+
homepage: https://github.com/torbjon/draugiem
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.25
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Draugiem
|
45
|
+
test_files: []
|