usergrid 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.
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'httparty'
4
+ gem 'json'
3
5
  # Specify your gem's dependencies in usergrid.gemspec
4
6
  gemspec
@@ -1,5 +1,10 @@
1
- require "usergrid/version"
1
+ require 'httparty'
2
+ require "./lib/usergrid/version"
3
+ require "./lib/usergrid/client"
2
4
 
3
5
  module Usergrid
6
+ include HTTParty
4
7
  # Your code goes here...
8
+ class << self
9
+ end
5
10
  end
@@ -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
@@ -0,0 +1,13 @@
1
+ module Usergrid
2
+ class Client
3
+
4
+ def users
5
+ get("/users")
6
+ end
7
+
8
+ def create_user params
9
+ post("/users", params)
10
+ end
11
+
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Usergrid
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: usergrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
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: ''