lemur 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -0
  3. data/lib/lemur.rb +34 -29
  4. data/lib/lemur/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzYxMjg2NDZlM2NjOGQ2NzQwNTAyMTBhNjY5ZDQ3YjE0NzNjODFjOQ==
4
+ YzFiMmVjZTU2OGMzNmVlYmQ5ZGExZjBmMmZiZjVmYTdiMTJjODI0Mw==
5
5
  data.tar.gz: !binary |-
6
- ZmNjNjZmMjVhOTNiMDYyNzlhODA0ODg2ZDhkNDdjY2Y5ZWIxNWMyNw==
6
+ NzczMjFkNmJjMmU1YmM1YTlmYzQ4ZjlhZTg1YzBjZjgxOGExZmVmNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjNlODEzMjUwOTZjMDYxOGFmOGNkNTJmNmI0YTVhYjU3OGU5YzgwZTA3ZjJl
10
- ZWJjODI1NmQxMDU0MWJmZDEyNWRhYzg4MmZhYjZlZDllZDVkNjhjMDdkMjI1
11
- ODU3ZDdhMWMzOTc1NzI1ZWQ1MDQ0NTQyNDMwMDM4MTJlYjZhYWE=
9
+ ZWRiYmUyNTEwZWFmNmU1YzE4YzA1NzUxMzhlMzU3MmRhYTU5MThhMTA4NDEy
10
+ YjA2YWE4YjBkNDZiMmRiMTI1ZmUwMWVjNTE4YjY0ZmVhZjliNWQ2Y2MzYzAx
11
+ ZGQzZmViYjM4YzQwODhhMDA5NzM2OGUzODIxZGFiODhmMTBmNzc=
12
12
  data.tar.gz: !binary |-
13
- ZTA1Y2RlZTY4MDAyYTA1MTE2NzRiZGExOWFjNmRjZjE1YTBkMmRkYmM3MDc4
14
- ZTg5N2VjYjRlOTRmNWE5ZDM0MjdhNDUyMmI2OWMwNGM0NjMyZThmMWRiYjQx
15
- MmU2NDQ3MDhhYjlmNWU1OWRhZjliNDA3YTlmZDI5OWU3OWVjZDU=
13
+ NWEwN2JlN2ViNzFlN2FlMTgxMjVlMTcyMmJiM2NiMmNkNmYzMDliMTg5OWQz
14
+ YzEzMDdkMzUwZDY3NWMwYWZjMzUyNzc5M2I1YzlkYmUwOTBhMzg3Yzg0NWU0
15
+ ZjY2MjM5MTFkMjUwYTFmN2Q0MzI1OWQ2ZTE0OGVkYWQ0NWVjMDA=
data/README.md CHANGED
@@ -9,6 +9,8 @@ Lemur is a lightweight, flexible Ruby SDK for Odnoklassniki. It allows read/writ
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  gem 'lemur'
12
+ or instal gem with latest changes
13
+ gem 'lemur', :git => "git@github.com:edikgat/lemur.git"
12
14
 
13
15
  And then execute:
14
16
 
@@ -4,6 +4,9 @@ require 'json'
4
4
  require 'digest/md5'
5
5
 
6
6
  module Lemur
7
+ ODNOKLASSNIKI_API_URL = 'http://api.odnoklassniki.ru/fb.do'
8
+ ODNOKLASSNIKI_NEW_TOKEN_URL = 'http://api.odnoklassniki.ru/oauth/token.do'
9
+
7
10
  class API
8
11
 
9
12
  def initialize(application_secret_key, application_key, access_token, application_id = nil, refresh_token = nil)
@@ -17,31 +20,13 @@ module Lemur
17
20
 
18
21
  attr_reader :security_options, :request_options, :response, :connection
19
22
 
20
- def start_faraday
21
- faraday_options = {
22
- :headers['Content-Type'] => 'application/json',
23
- :url => 'http://api.odnoklassniki.ru/fb.do'
24
- }
25
- @connection = init_faraday(faraday_options)
26
- end
27
-
28
-
29
- def init_faraday(faraday_options)
30
- Faraday.new(faraday_options) do |faraday|
31
- faraday.request :url_encoded
32
- faraday.response :logger
33
- faraday.adapter Faraday.default_adapter
34
- end
35
- end
36
-
37
-
38
23
  def get_new_token
39
24
  if @security_options[:application_id].blank? || @security_options[:refresh_token].blank?
40
25
  raise ArgumentError, 'wrong number of arguments'
41
26
  end
42
27
  faraday_options = {
43
28
  :headers['Content-Type'] => 'application/json',
44
- :url => 'http://api.odnoklassniki.ru/oauth/token.do'
29
+ :url => Lemur::ODNOKLASSNIKI_NEW_TOKEN_URL
45
30
  }
46
31
  conn = init_faraday(faraday_options)
47
32
  new_token_response = conn.post do |req|
@@ -56,6 +41,21 @@ module Lemur
56
41
  new_token_response['access_token']
57
42
  end
58
43
 
44
+ def get_request(request_params)
45
+ @request_options = request_params
46
+ @response = @connection.get do |request|
47
+ request.params = final_request_params(@request_options.merge(application_key: security_options[:application_key]),
48
+ security_options[:access_token])
49
+ end
50
+ end
51
+
52
+ def get(request_params)
53
+ @response = get_request(request_params)
54
+ JSON.parse(response.body)
55
+ end
56
+
57
+ private
58
+
59
59
  def final_request_params(request_params, access_token)
60
60
  request_params.merge(sig: odnoklassniki_signature(request_params, access_token, security_options[:application_secret_key]),
61
61
  access_token: security_options[:access_token],
@@ -70,19 +70,24 @@ module Lemur
70
70
  Digest::MD5.hexdigest("#{sorted_params_string}#{secret_part}")
71
71
  end
72
72
 
73
- def get_request(request_params)
74
- @request_options = request_params
75
- @response = @connection.get do |request|
76
- request.params = final_request_params(@request_options.merge(application_key: security_options[:application_key]),
77
- security_options[:access_token])
78
- end
79
- end
73
+ def start_faraday
74
+ faraday_options = {
75
+ :headers['Content-Type'] => 'application/json',
76
+ :url => Lemur::ODNOKLASSNIKI_API_URL
77
+ }
78
+ @connection = init_faraday(faraday_options)
79
+ end
80
80
 
81
- def get(request_params)
82
- @response = get_request(request_params)
83
- JSON.parse(response.body)
81
+
82
+ def init_faraday(faraday_options)
83
+ Faraday.new(faraday_options) do |faraday|
84
+ faraday.request :url_encoded
85
+ faraday.response :logger
86
+ faraday.adapter Faraday.default_adapter
87
+ end
84
88
  end
85
89
 
90
+
86
91
  end
87
92
 
88
93
  end
@@ -1,3 +1,3 @@
1
1
  module Lemur
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lemur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduard Gataullin