tiptaplab 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- metadata +4 -19
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -37
- data/LICENSE +0 -20
- data/LICENSE.txt +0 -22
- data/README.md +0 -49
- data/Rakefile +0 -1
- data/lib/tiptaplab/api.rb +0 -87
- data/lib/tiptaplab/brand.rb +0 -0
- data/lib/tiptaplab/user.rb +0 -7
- data/lib/tiptaplab/version.rb +0 -3
- data/lib/tiptaplab.rb +0 -9
- data/pkg/tiptaplab-0.0.1.gem +0 -0
- data/spec/tiptaplab_spec.rb +0 -1
- data/tiptaplab.gemspec +0 -26
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGZjOTA1ZjRkZGRiZDg2YzJjMDJlNzM5NzRjYzVlODkwYjdmOTY1NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTg4YjQ2OWVhZTFhMDJhNTc1NmVkNTBlNTA3OWFiOGYxY2YyYTgyZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGNhNDkwN2M0YmU3N2M4Zjk4YWNiY2ZiMDA3Yjk2NzdkMzc1ZTY5ZmRjODUy
|
10
|
+
NTYyMmVkYzc4MDc4OWUxMjgwZjUxZDNmM2IxOTljN2NmNzY4Y2NkNGM0MGY2
|
11
|
+
Nzk1OTg4ZmZmMjRiYTdjNTJjMDE0ODUxMTliYzdmYjI0OWYxODk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDk5M2VkNjliZDU5N2U0OWJhZDliMzllNjA4ZjZkZWE0ODQ5OGFlYzU3M2E5
|
14
|
+
OTVkYjc4ZDMwOThhMTQ5MzY4Yzg5OWYxOGEwYjk3NGM3YmE4ZjllOWQyN2Q0
|
15
|
+
MjJkZWUxNDE2NTlhZjQ1YWJmMjEwMzE0NzM5Njc5YTUwY2E3NWE=
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiptaplab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian McLean
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,21 +86,7 @@ email:
|
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
|
-
files:
|
90
|
-
- Gemfile
|
91
|
-
- Gemfile.lock
|
92
|
-
- LICENSE
|
93
|
-
- LICENSE.txt
|
94
|
-
- README.md
|
95
|
-
- Rakefile
|
96
|
-
- lib/tiptaplab.rb
|
97
|
-
- lib/tiptaplab/api.rb
|
98
|
-
- lib/tiptaplab/brand.rb
|
99
|
-
- lib/tiptaplab/user.rb
|
100
|
-
- lib/tiptaplab/version.rb
|
101
|
-
- pkg/tiptaplab-0.0.1.gem
|
102
|
-
- spec/tiptaplab_spec.rb
|
103
|
-
- tiptaplab.gemspec
|
89
|
+
files: []
|
104
90
|
homepage: http://github.com/tiptapinc/tiptaplab
|
105
91
|
licenses:
|
106
92
|
- MIT
|
@@ -126,6 +112,5 @@ signing_key:
|
|
126
112
|
specification_version: 4
|
127
113
|
summary: Provides the ability to track and compare psychological trait information
|
128
114
|
using the TipTapLab API.
|
129
|
-
test_files:
|
130
|
-
- spec/tiptaplab_spec.rb
|
115
|
+
test_files: []
|
131
116
|
has_rdoc:
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
tiptaplab (0.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (3.2.11)
|
10
|
-
i18n (~> 0.6)
|
11
|
-
multi_json (~> 1.0)
|
12
|
-
diff-lcs (1.2.4)
|
13
|
-
faraday (0.8.8)
|
14
|
-
multipart-post (~> 1.2.0)
|
15
|
-
i18n (0.6.5)
|
16
|
-
multi_json (1.7.9)
|
17
|
-
multipart-post (1.2.0)
|
18
|
-
rake (10.1.0)
|
19
|
-
rspec (2.14.1)
|
20
|
-
rspec-core (~> 2.14.0)
|
21
|
-
rspec-expectations (~> 2.14.0)
|
22
|
-
rspec-mocks (~> 2.14.0)
|
23
|
-
rspec-core (2.14.5)
|
24
|
-
rspec-expectations (2.14.3)
|
25
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
26
|
-
rspec-mocks (2.14.3)
|
27
|
-
|
28
|
-
PLATFORMS
|
29
|
-
ruby
|
30
|
-
|
31
|
-
DEPENDENCIES
|
32
|
-
activesupport (~> 3.2.11)
|
33
|
-
bundler (~> 1.3)
|
34
|
-
faraday (~> 0.8.8)
|
35
|
-
rake
|
36
|
-
rspec (~> 2.6)
|
37
|
-
tiptaplab!
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2013 TipTap
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
7
|
-
the Software without restriction, including without limitation the rights to
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
-
subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 TODO: Write your name
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Tiptaplab
|
2
|
-
|
3
|
-
Warning: This gem is unfinished, and should not be used just yet.
|
4
|
-
|
5
|
-
The tiptaplab gem will provide easy and painless access to the TipTapLab API.
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
gem 'tiptaplab'
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install tiptaplab
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
First, [register your application with the TipTapLab API][register]
|
24
|
-
|
25
|
-
[register]https://api.tiptap.com/oauth/applications
|
26
|
-
|
27
|
-
Then, create a new `Tiptaplab::Api` instance, specifying your `app_id` and `app_secret`:
|
28
|
-
|
29
|
-
api = Tiptaplab::Api.new(:app_id => YOUR_APP_ID, :app_secret => YOUR_APP_SECRET)
|
30
|
-
|
31
|
-
In addition to the required app_id and app_secret, you can specify `:api_environment`. If this is set to 'staging', the gem will use the [TipTapLab staging API][staging]. This is useful while your app is in development, but remember that API data created on staging will not be available once you switch to production mode, and that your App credentials may be different.
|
32
|
-
|
33
|
-
You can also make arbitrary calls to the api using the `make_call` method:
|
34
|
-
|
35
|
-
api.make_call(call_path, data, method)
|
36
|
-
|
37
|
-
The default `data` is an empty hash and the default method is 'GET', so you can make simple requests with just the call path:
|
38
|
-
|
39
|
-
api.make_call('traits')
|
40
|
-
=> [{"title"=>"Susceptability", "key"=>"susceptability"}, {"title"=>"Diet", "key"=>"diet"}...
|
41
|
-
|
42
|
-
|
43
|
-
## Contributing
|
44
|
-
|
45
|
-
1. Fork it
|
46
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/lib/tiptaplab/api.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/numeric'
|
2
|
-
require 'faraday'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module Tiptaplab
|
6
|
-
class Api
|
7
|
-
DEFAULT_OPTIONS = {
|
8
|
-
:api_version => 3,
|
9
|
-
:api_environment => 'production'
|
10
|
-
}
|
11
|
-
|
12
|
-
def initialize *params
|
13
|
-
if params.first.is_a?(Hash)
|
14
|
-
hash_options = params.first
|
15
|
-
@api_version = hash_options[:api_version] || DEFAULT_OPTIONS[:api_version]
|
16
|
-
@api_environment = hash_options[:api_environment] || DEFAULT_OPTIONS[:api_environment]
|
17
|
-
@app_id = hash_options[:app_id]
|
18
|
-
unless @app_id
|
19
|
-
raise "No app_id specified. Please pass a Hash containing your application credentials to Tiptaplab::Api.new"
|
20
|
-
end
|
21
|
-
@app_secret = hash_options[:app_secret]
|
22
|
-
unless @app_secret
|
23
|
-
raise "No app_secret specified. Please pass a Hash containing your application credentials to Tiptaplab::Api.new"
|
24
|
-
end
|
25
|
-
else
|
26
|
-
raise "Pass init parameters as a Hash"
|
27
|
-
end
|
28
|
-
@version_str = "v#{@api_version}"
|
29
|
-
api_url = case @api_environment
|
30
|
-
when 'staging'
|
31
|
-
'http://api.staging.tiptap.com'
|
32
|
-
else
|
33
|
-
'https://api.tiptap.com'
|
34
|
-
end
|
35
|
-
@conn = Faraday.new(:url => api_url) do |faraday|
|
36
|
-
faraday.request :url_encoded
|
37
|
-
faraday.response :logger
|
38
|
-
faraday.adapter Faraday.default_adapter
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def fetch_auth_token(opts = {})
|
43
|
-
if opts[:force] || @auth_at.nil? || (@auth_at < (opts[:cache_for]|| 60.minutes).ago)
|
44
|
-
@auth_at = Time.now
|
45
|
-
token_response = @conn.post('/oauth/token',
|
46
|
-
{
|
47
|
-
:client_id => @app_id,
|
48
|
-
:client_secret => @app_secret,
|
49
|
-
:grant_type => 'client_credentials'
|
50
|
-
}
|
51
|
-
)
|
52
|
-
if token_response.status == 200
|
53
|
-
@auth_token = JSON.parse(token_response.body)['access_token']
|
54
|
-
else
|
55
|
-
raise "Error fetching auth token. Check the log for details."
|
56
|
-
end
|
57
|
-
end
|
58
|
-
@auth_token
|
59
|
-
end
|
60
|
-
|
61
|
-
def make_call(call, data = {}, method = 'GET')
|
62
|
-
fetch_auth_token
|
63
|
-
case method
|
64
|
-
when 'GET'
|
65
|
-
response = @conn.get("/#{@version_str}/#{call}", data, {'Authorization' => "Bearer #{@auth_token}"})
|
66
|
-
if response.status == '401'
|
67
|
-
puts "Response returned unauthorized, attempting to refresh auth token"
|
68
|
-
fetch_auth_token(:force => true)
|
69
|
-
response = @conn.get("/#{@version_str}/#{call}", data, {'Authorization' => "Bearer #{@auth_token}"})
|
70
|
-
end
|
71
|
-
when 'POST'
|
72
|
-
response = @conn.post("/#{@version_str}/#{call}", data, {'Authorization' => "Bearer #{@auth_token}"})
|
73
|
-
if response.status == '401'
|
74
|
-
puts "Response returned unauthorized, attempting to refresh auth token"
|
75
|
-
fetch_auth_token(:force => true)
|
76
|
-
response = @conn.get("/#{@version_str}/#{call}", data, {'Authorization' => "Bearer #{@auth_token}"})
|
77
|
-
end
|
78
|
-
end
|
79
|
-
if (response.status/100 == 2)
|
80
|
-
JSON.parse(response.body)
|
81
|
-
else
|
82
|
-
raise "Error making request. Status: #{response.status}. Check log for details."
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
data/lib/tiptaplab/brand.rb
DELETED
File without changes
|
data/lib/tiptaplab/user.rb
DELETED
data/lib/tiptaplab/version.rb
DELETED
data/lib/tiptaplab.rb
DELETED
data/pkg/tiptaplab-0.0.1.gem
DELETED
Binary file
|
data/spec/tiptaplab_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
describe Tiptaplab
|
data/tiptaplab.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'tiptaplab/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "tiptaplab"
|
8
|
-
spec.version = Tiptaplab::VERSION
|
9
|
-
spec.authors = ["Ian McLean"]
|
10
|
-
spec.email = ["engineering@tiptap.com"]
|
11
|
-
spec.description = %q{TipTapLab API Integration}
|
12
|
-
spec.summary = %q{Provides the ability to track and compare psychological trait information using the TipTapLab API.}
|
13
|
-
spec.homepage = "http://github.com/tiptapinc/tiptaplab"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec", "~> 2.6"
|
24
|
-
spec.add_development_dependency "activesupport", "~> 3.2.11"
|
25
|
-
spec.add_development_dependency "faraday", "~> 0.8.8"
|
26
|
-
end
|