usergrid 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/lib/usergrid.rb +6 -1
- data/lib/usergrid/client.rb +36 -0
- data/lib/usergrid/user.rb +13 -0
- data/lib/usergrid/version.rb +1 -1
- metadata +3 -1
data/Gemfile
CHANGED
data/lib/usergrid.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require './lib/usergrid/user'
|
2
|
+
|
3
|
+
module Usergrid
|
4
|
+
|
5
|
+
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
class Client
|
9
|
+
def initialize(options = {})
|
10
|
+
@app = options[:app]
|
11
|
+
@key = options[:key]
|
12
|
+
@secret = options[:secret]
|
13
|
+
end
|
14
|
+
|
15
|
+
def access_token
|
16
|
+
@access_token ||= HTTParty.get("#{base_uri}/token?grant_type=client_credentials&client_id=#{@key}&client_secret=#{@secret}").parsed_response["access_token"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def base_uri
|
20
|
+
"http://api.usergrid.com/#{@app}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def get url
|
24
|
+
HTTParty.get("#{base_uri}#{url}", :headers => headers_hash)
|
25
|
+
end
|
26
|
+
|
27
|
+
def post url, params
|
28
|
+
options = {:body => params.to_json, :headers => {"Content-Type" => "application/json"}}
|
29
|
+
HTTParty.post("#{base_uri}#{url}", options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def headers_hash
|
33
|
+
{"Authorization" => "Bearer #{access_token}"}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/usergrid/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usergrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -24,6 +24,8 @@ files:
|
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- lib/usergrid.rb
|
27
|
+
- lib/usergrid/client.rb
|
28
|
+
- lib/usergrid/user.rb
|
27
29
|
- lib/usergrid/version.rb
|
28
30
|
- usergrid.gemspec
|
29
31
|
homepage: ''
|