rcracy 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ module RCracy
2
+
3
+ class Response
4
+
5
+ attr_reader :errors, :key
6
+
7
+ def initialize(attrs)
8
+
9
+ @errors = attrs['error']
10
+ @key = attrs['key']
11
+
12
+ end
13
+
14
+ def errors?
15
+ return error == 0 ? true : false;
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -1,3 +1,3 @@
1
1
  module RCracy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -5,6 +5,23 @@ module RCracy
5
5
 
6
6
  API_BASE_URL = 'http://karmacracy.com/api/v1' # Remove from here.
7
7
 
8
+ ##
9
+ # Returns a RCracy::Response object
10
+
11
+ def self.get_user_private_key(username, password, regenerate = false)
12
+
13
+ request_url = "#{API_BASE_URL}/key/?u=#{username}&p=#{password}&appkey=#{RCracy.configuration.app_key}"
14
+
15
+ request_url += "&regenerate=1" unless !regenerate
16
+
17
+ http_response = Net::HTTP.get_response(URI.parse(request_url))
18
+
19
+ hashed_response = JSON.parse(http_response.body)
20
+
21
+ return RCracy::Response.new(hashed_response)
22
+
23
+ end
24
+
8
25
  ##
9
26
  # Returns an Array of RCracy::Kcy objects
10
27
 
data/lib/rcracy.rb CHANGED
@@ -1,7 +1,8 @@
1
- require File.dirname(__FILE__) + '/rcracy/api.rb'
1
+ require File.dirname(__FILE__) + '/rcracy/wrapper.rb'
2
2
  require File.dirname(__FILE__) + '/rcracy/version.rb'
3
3
  require File.dirname(__FILE__) + '/rcracy/kcy.rb'
4
4
  require File.dirname(__FILE__) + '/rcracy/nut.rb'
5
5
  require File.dirname(__FILE__) + '/rcracy/user.rb'
6
6
  require File.dirname(__FILE__) + '/rcracy/domain.rb'
7
- require File.dirname(__FILE__) + '/rcracy/configuration.rb'
7
+ require File.dirname(__FILE__) + '/rcracy/configuration.rb'
8
+ require File.dirname(__FILE__) + '/rcracy/response.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcracy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -22,13 +22,14 @@ files:
22
22
  - LICENSE.txt
23
23
  - README.md
24
24
  - lib/rcracy.rb
25
- - lib/rcracy/api.rb
26
25
  - lib/rcracy/configuration.rb
27
26
  - lib/rcracy/domain.rb
28
27
  - lib/rcracy/kcy.rb
29
28
  - lib/rcracy/nut.rb
29
+ - lib/rcracy/response.rb
30
30
  - lib/rcracy/user.rb
31
31
  - lib/rcracy/version.rb
32
+ - lib/rcracy/wrapper.rb
32
33
  - rcracy.gemspec
33
34
  homepage: https://github.com/pabloelices/rcracy
34
35
  licenses: []