yoolinkpro-ruby-sdk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.rvmrc +48 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +70 -0
- data/Guardfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/lib/hash_ext.rb +5 -0
- data/lib/yoolinkpro-ruby-sdk.rb +28 -0
- data/lib/yoolinkpro/api.rb +165 -0
- data/lib/yoolinkpro/client.rb +27 -0
- data/lib/yoolinkpro/exceptions.rb +3 -0
- data/spec/hash_ext_spec.rb +15 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/yoolinkpro-ruby-sdk_spec.rb +25 -0
- data/yoolinkpro-ruby-sdk.gemspec +85 -0
- metadata +244 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use ree" > .rvmrc
|
9
|
+
environment_id="ree-1.8.7-2012.02@yoolinkpro-ruby-sdk"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.11.6" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'rest-client', '~> 1.6.7'
|
4
|
+
gem 'oj', '~> 2.0.1'
|
5
|
+
gem 'activesupport', '~> 3.2.11'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'rspec', '~> 2.8.0'
|
9
|
+
gem 'yard', '~> 0.7'
|
10
|
+
gem 'jeweler', '~> 1.8.4'
|
11
|
+
gem 'guard', '~> 1.6.1'
|
12
|
+
gem 'guard-bundler', '~> 1.0.0'
|
13
|
+
gem 'guard-rspec', '~> 1.2.1'
|
14
|
+
gem 'rb-inotify', '~> 0.8.8'
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.11)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
coderay (1.0.8)
|
8
|
+
diff-lcs (1.1.3)
|
9
|
+
ffi (1.3.1)
|
10
|
+
git (1.2.5)
|
11
|
+
guard (1.6.1)
|
12
|
+
listen (>= 0.6.0)
|
13
|
+
lumberjack (>= 1.0.2)
|
14
|
+
pry (>= 0.9.10)
|
15
|
+
thor (>= 0.14.6)
|
16
|
+
guard-bundler (1.0.0)
|
17
|
+
bundler (~> 1.0)
|
18
|
+
guard (~> 1.1)
|
19
|
+
guard-rspec (1.2.1)
|
20
|
+
guard (>= 1.1)
|
21
|
+
i18n (0.6.1)
|
22
|
+
jeweler (1.8.4)
|
23
|
+
bundler (~> 1.0)
|
24
|
+
git (>= 1.2.5)
|
25
|
+
rake
|
26
|
+
rdoc
|
27
|
+
json (1.7.6)
|
28
|
+
listen (0.7.2)
|
29
|
+
lumberjack (1.0.2)
|
30
|
+
method_source (0.8.1)
|
31
|
+
mime-types (1.19)
|
32
|
+
multi_json (1.5.0)
|
33
|
+
oj (2.0.1)
|
34
|
+
pry (0.9.11.4)
|
35
|
+
coderay (~> 1.0.5)
|
36
|
+
method_source (~> 0.8)
|
37
|
+
slop (~> 3.4)
|
38
|
+
rake (10.0.3)
|
39
|
+
rb-inotify (0.8.8)
|
40
|
+
ffi (>= 0.5.0)
|
41
|
+
rdoc (3.12)
|
42
|
+
json (~> 1.4)
|
43
|
+
rest-client (1.6.7)
|
44
|
+
mime-types (>= 1.16)
|
45
|
+
rspec (2.8.0)
|
46
|
+
rspec-core (~> 2.8.0)
|
47
|
+
rspec-expectations (~> 2.8.0)
|
48
|
+
rspec-mocks (~> 2.8.0)
|
49
|
+
rspec-core (2.8.0)
|
50
|
+
rspec-expectations (2.8.0)
|
51
|
+
diff-lcs (~> 1.1.2)
|
52
|
+
rspec-mocks (2.8.0)
|
53
|
+
slop (3.4.3)
|
54
|
+
thor (0.16.0)
|
55
|
+
yard (0.8.3)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
activesupport (~> 3.2.11)
|
62
|
+
guard (~> 1.6.1)
|
63
|
+
guard-bundler (~> 1.0.0)
|
64
|
+
guard-rspec (~> 1.2.1)
|
65
|
+
jeweler (~> 1.8.4)
|
66
|
+
oj (~> 2.0.1)
|
67
|
+
rb-inotify (~> 0.8.8)
|
68
|
+
rest-client (~> 1.6.7)
|
69
|
+
rspec (~> 2.8.0)
|
70
|
+
yard (~> 0.7)
|
data/Guardfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :bundler do
|
5
|
+
watch('Gemfile')
|
6
|
+
end
|
7
|
+
|
8
|
+
guard 'rspec' do
|
9
|
+
watch(%r{^spec/.+_spec\.rb$})
|
10
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
11
|
+
watch('spec/spec_helper.rb') { "spec" }
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Vincent Durand
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= yoolinkpro-ruby-sdk
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to yoolinkpro-ruby-sdk
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2013 Vincent Durand. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "yoolinkpro-ruby-sdk"
|
18
|
+
gem.homepage = "http://github.com/madwork/yoolinkpro-ruby-sdk"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{YoolinkPro API Ruby SDK}
|
21
|
+
gem.description = %Q{YoolinkPro API Ruby SDK, manage your feed, users, groups, teams...}
|
22
|
+
gem.email = "vincent@yoolink.fr"
|
23
|
+
gem.authors = ["Vincent Durand"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'yard'
|
42
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/hash_ext.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'oj'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
require 'hash_ext'
|
5
|
+
require 'yoolinkpro/exceptions'
|
6
|
+
|
7
|
+
module Yoolinkpro
|
8
|
+
extend self
|
9
|
+
|
10
|
+
API_SERVER = "api.yoolinkpro.com"
|
11
|
+
API_VERSION = 1
|
12
|
+
|
13
|
+
attr_accessor :public_key, :private_key, :admin_key
|
14
|
+
|
15
|
+
# config/initializers/load_yoolinkpro.rb (for rails)
|
16
|
+
#
|
17
|
+
# Yoolinkpro.configure do |config|
|
18
|
+
# config.public_key = 'public_key'
|
19
|
+
# config.private_key = 'private_key'
|
20
|
+
# config.admin_key = 'admin_key'
|
21
|
+
# end
|
22
|
+
def configure
|
23
|
+
yield self
|
24
|
+
end
|
25
|
+
|
26
|
+
autoload :Client, 'yoolinkpro/client'
|
27
|
+
autoload :Api, 'yoolinkpro/api'
|
28
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'digest/sha1'
|
2
|
+
require 'base64'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Yoolinkpro
|
6
|
+
class Api < SimpleDelegator
|
7
|
+
|
8
|
+
# Yoolinkpro::Api
|
9
|
+
#
|
10
|
+
# client = Yoolinkpro::Client.new
|
11
|
+
# api = Yoolinkpro::Api.new client
|
12
|
+
#
|
13
|
+
# @param [Yoolinkpro::Client] client
|
14
|
+
# @return [Yoolinkpro::Api]
|
15
|
+
def initialize(client)
|
16
|
+
super
|
17
|
+
@millitime = Time.now.to_i*1000
|
18
|
+
@int = rand(100000)
|
19
|
+
@key_scopes = { :private => private_key, :admin => admin_key }
|
20
|
+
end
|
21
|
+
|
22
|
+
# User authentication
|
23
|
+
#
|
24
|
+
# api.authenticate "vincent@yoolink.fr", "password"
|
25
|
+
#
|
26
|
+
# @param [String] email
|
27
|
+
# @param [String] password
|
28
|
+
# @return [RestClient::Response]
|
29
|
+
def authenticate(email, password)
|
30
|
+
params = { :email => email, :password => Base64.encode64(crypted_password(password)) }
|
31
|
+
build_uri("/user/authenticate.json", :query => params.to_query)
|
32
|
+
build_key(:post, private_key, params)
|
33
|
+
RestClient.post @uri.to_s, params.to_query, http_headers
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create an url to open a new session
|
37
|
+
#
|
38
|
+
# api.open_session "vincent@yoolink.fr"
|
39
|
+
#
|
40
|
+
# @param [String] email of an existing YoolinkPro user
|
41
|
+
# @return [RestClient::Response]
|
42
|
+
def open_session(email)
|
43
|
+
@key = "get/open_sessionemail=#{email}#{admin_key}#{@millitime}#{@int}"
|
44
|
+
RestClient::Response.create "https://#{Yoolinkpro::API_SERVER}/open_session?email=#{CGI.escape(email)}&X-YP-AppKey=#{public_key}&X-YP-Signature=#{CGI.escape(signature)}&X-YP-MilliTime=#{@millitime}&X-YP-Int=#{@int}".to_json, nil, nil
|
45
|
+
end
|
46
|
+
|
47
|
+
# Find object such as user, team, link
|
48
|
+
#
|
49
|
+
# api.find :user, 1
|
50
|
+
# api.find :team, 1234
|
51
|
+
#
|
52
|
+
# @param [Symbol] obj
|
53
|
+
# @param [Fixnum] id
|
54
|
+
# @param [Symbol] scope for this request
|
55
|
+
# @return [RestClient::Response]
|
56
|
+
def find(obj, id, scope = :private)
|
57
|
+
build_uri("/#{obj}/#{id}.json")
|
58
|
+
build_key(:get, scope)
|
59
|
+
RestClient.get @uri.to_s, http_headers
|
60
|
+
end
|
61
|
+
|
62
|
+
# Find all object such as users, teams, groups
|
63
|
+
#
|
64
|
+
# api.find_all :users
|
65
|
+
# api.find_all :groups
|
66
|
+
#
|
67
|
+
# @param [Symbol] obj pluralize
|
68
|
+
# @param [Symbol] scope for this request
|
69
|
+
# @return [RestClient::Response]
|
70
|
+
def find_all(obj, scope = :admin)
|
71
|
+
build_uri("/#{obj}.json")
|
72
|
+
build_key(:get, scope)
|
73
|
+
RestClient.get @uri.to_s, http_headers
|
74
|
+
end
|
75
|
+
|
76
|
+
# Search object such as :user
|
77
|
+
#
|
78
|
+
# api.search :user, :email => "vincent@yoolink.fr"
|
79
|
+
#
|
80
|
+
# @param [Symbol] obj
|
81
|
+
# @param [Fixnum] params
|
82
|
+
# @param [Symbol] scope for this request
|
83
|
+
# @return [RestClient::Response]
|
84
|
+
def search(obj, params = {}, scope = :private)
|
85
|
+
build_uri("/#{obj}/search.json", :query => params.to_query)
|
86
|
+
build_key(:get, scope, params)
|
87
|
+
RestClient.get @uri.to_s, http_headers
|
88
|
+
end
|
89
|
+
|
90
|
+
# Create object such as :user, :team, :link, :comment
|
91
|
+
#
|
92
|
+
# api.create :group, :name => "Api", :description => "Everything about Api"
|
93
|
+
#
|
94
|
+
# @param [Symbol] obj
|
95
|
+
# @param [Hash] params
|
96
|
+
# @param [Symbol] scope for this request
|
97
|
+
# @return [RestClient::Response]
|
98
|
+
def create(obj, params = {}, scope = :admin)
|
99
|
+
build_uri("/#{obj}.json", :query => params.to_query)
|
100
|
+
build_key(:post, scope, params)
|
101
|
+
RestClient.post @uri.to_s, params.to_query, http_headers
|
102
|
+
end
|
103
|
+
|
104
|
+
# Update object such as :user, :link
|
105
|
+
#
|
106
|
+
# api.update :user, 1, :firstname => "Vincent"
|
107
|
+
#
|
108
|
+
# @param [Symbol] obj
|
109
|
+
# @param [Fixnum] id
|
110
|
+
# @param [Hash] params
|
111
|
+
# @param [Symbol] scope for this request
|
112
|
+
# @return [RestClient::Response]
|
113
|
+
def update(obj, id, params = {}, scope = :admin)
|
114
|
+
build_uri("/#{obj}/#{id}.json", :query => params.to_query)
|
115
|
+
build_key(:put, scope, params)
|
116
|
+
RestClient.put @uri.to_s, params.to_query, http_headers
|
117
|
+
end
|
118
|
+
|
119
|
+
# Delete object
|
120
|
+
#
|
121
|
+
# api.delete :comment, 1, { :identity_token => auth[:identity_token] } :private
|
122
|
+
#
|
123
|
+
# @param [Symbol] obj
|
124
|
+
# @param [Fixnum] id
|
125
|
+
# @param [Hash] params
|
126
|
+
# @param [Symbol] scope for this request
|
127
|
+
# @return [RestClient::Response]
|
128
|
+
def delete(obj, id, params = {}, scope = :admin)
|
129
|
+
build_uri("/#{obj}/#{id}.json", :query => params.to_query)
|
130
|
+
build_key(:delete, scope, params)
|
131
|
+
RestClient.delete @uri.to_s, http_headers
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def http_headers
|
137
|
+
{
|
138
|
+
'User-Agent' => "YoolinkPro Ruby SDK",
|
139
|
+
'X-YP-AppKey' => public_key,
|
140
|
+
'X-YP-Signature' => signature,
|
141
|
+
'X-YP-MilliTime' => @millitime,
|
142
|
+
'X-YP-Int' => @int
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
def signature
|
147
|
+
Base64.encode64(Digest::SHA1.digest(@key)).gsub(/=$/, '')
|
148
|
+
end
|
149
|
+
|
150
|
+
def build_uri(path, options = {})
|
151
|
+
@uri = URI::HTTPS.build({ :host => Yoolinkpro::API_SERVER, :path => path }.merge(options))
|
152
|
+
end
|
153
|
+
|
154
|
+
def build_key(http_method, scope, params = {})
|
155
|
+
@key = "#{http_method}#{@uri.path}#{params.to_key}#{@key_scopes[scope] || private_key}#{@millitime}#{@int}"
|
156
|
+
end
|
157
|
+
|
158
|
+
def crypted_password(password)
|
159
|
+
cipher = OpenSSL::Cipher::Cipher.new('bf-ecb').encrypt
|
160
|
+
cipher.key = Digest::SHA256.digest(private_key)
|
161
|
+
cipher.update(password) << cipher.final
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Yoolinkpro
|
2
|
+
class Client
|
3
|
+
|
4
|
+
attr_reader :public_key, :private_key, :admin_key
|
5
|
+
|
6
|
+
# Yoolinkpro::Client
|
7
|
+
#
|
8
|
+
# client = Yoolinkpro::Client.new 'public_key', 'private_key', 'admin_key'
|
9
|
+
#
|
10
|
+
# @param [String] public_key
|
11
|
+
# @param [String] private_key
|
12
|
+
# @param [String] admin_key
|
13
|
+
# @return [Yoolinkpro::Client]
|
14
|
+
def initialize(public_key = Yoolinkpro.public_key, private_key = Yoolinkpro.private_key, admin_key = Yoolinkpro.admin_key)
|
15
|
+
@public_key, @private_key, @admin_key = public_key, private_key, admin_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_missing(method, *args)
|
19
|
+
api = Api.new(self)
|
20
|
+
response = api.send(method, *args)
|
21
|
+
Oj.load(response.body, :symbol_keys => true)
|
22
|
+
rescue RestClient::Exception => ex
|
23
|
+
raise ApiException, ex.message
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
|
5
|
+
describe ".to_key" do
|
6
|
+
it "generate valid api key" do
|
7
|
+
{ :a => 1, :b => 2 }.to_key.should == "a=1b=2"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "sort keys alphabeticaly" do
|
11
|
+
{ :c => 0, :a => 1, :b => 2 }.to_key.should == "a=1b=2c=0"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'yoolinkpro-ruby-sdk'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Yoolinkpro do
|
4
|
+
|
5
|
+
describe ".configure" do
|
6
|
+
[:public_key, :private_key, :admin_key].each do |key|
|
7
|
+
it "sets the #{key.to_s.gsub('_', ' ')}" do
|
8
|
+
Yoolinkpro.configure do |config|
|
9
|
+
config.send("#{key}=", key)
|
10
|
+
end
|
11
|
+
Yoolinkpro.send(key).should == key
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Yoolinkpro::Client do
|
17
|
+
it "set the keys" do
|
18
|
+
client = Yoolinkpro::Client.new('public_key', 'private_key', 'admin_key')
|
19
|
+
client.public_key.should == 'public_key'
|
20
|
+
client.private_key.should == 'private_key'
|
21
|
+
client.admin_key.should == 'admin_key'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{yoolinkpro-ruby-sdk}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Vincent Durand"]
|
12
|
+
s.date = %q{2013-01-22}
|
13
|
+
s.description = %q{YoolinkPro API Ruby SDK, manage your feed, users, groups, teams...}
|
14
|
+
s.email = %q{vincent@yoolink.fr}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
".rvmrc",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"Guardfile",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/hash_ext.rb",
|
31
|
+
"lib/yoolinkpro-ruby-sdk.rb",
|
32
|
+
"lib/yoolinkpro/api.rb",
|
33
|
+
"lib/yoolinkpro/client.rb",
|
34
|
+
"lib/yoolinkpro/exceptions.rb",
|
35
|
+
"spec/hash_ext_spec.rb",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"spec/yoolinkpro-ruby-sdk_spec.rb",
|
38
|
+
"yoolinkpro-ruby-sdk.gemspec"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/madwork/yoolinkpro-ruby-sdk}
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.6.2}
|
44
|
+
s.summary = %q{YoolinkPro API Ruby SDK}
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
|
51
|
+
s.add_runtime_dependency(%q<oj>, ["~> 2.0.1"])
|
52
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 3.2.11"])
|
53
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
|
+
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
55
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
56
|
+
s.add_development_dependency(%q<guard>, ["~> 1.6.1"])
|
57
|
+
s.add_development_dependency(%q<guard-bundler>, ["~> 1.0.0"])
|
58
|
+
s.add_development_dependency(%q<guard-rspec>, ["~> 1.2.1"])
|
59
|
+
s.add_development_dependency(%q<rb-inotify>, ["~> 0.8.8"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
|
62
|
+
s.add_dependency(%q<oj>, ["~> 2.0.1"])
|
63
|
+
s.add_dependency(%q<activesupport>, ["~> 3.2.11"])
|
64
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
65
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
67
|
+
s.add_dependency(%q<guard>, ["~> 1.6.1"])
|
68
|
+
s.add_dependency(%q<guard-bundler>, ["~> 1.0.0"])
|
69
|
+
s.add_dependency(%q<guard-rspec>, ["~> 1.2.1"])
|
70
|
+
s.add_dependency(%q<rb-inotify>, ["~> 0.8.8"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
|
74
|
+
s.add_dependency(%q<oj>, ["~> 2.0.1"])
|
75
|
+
s.add_dependency(%q<activesupport>, ["~> 3.2.11"])
|
76
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
77
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
78
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
79
|
+
s.add_dependency(%q<guard>, ["~> 1.6.1"])
|
80
|
+
s.add_dependency(%q<guard-bundler>, ["~> 1.0.0"])
|
81
|
+
s.add_dependency(%q<guard-rspec>, ["~> 1.2.1"])
|
82
|
+
s.add_dependency(%q<rb-inotify>, ["~> 0.8.8"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
metadata
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yoolinkpro-ruby-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Vincent Durand
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-01-22 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 1
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 6
|
32
|
+
- 7
|
33
|
+
version: 1.6.7
|
34
|
+
name: rest-client
|
35
|
+
version_requirements: *id001
|
36
|
+
prerelease: false
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
type: :runtime
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 13
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 0
|
48
|
+
- 1
|
49
|
+
version: 2.0.1
|
50
|
+
name: oj
|
51
|
+
version_requirements: *id002
|
52
|
+
prerelease: false
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
type: :runtime
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 25
|
61
|
+
segments:
|
62
|
+
- 3
|
63
|
+
- 2
|
64
|
+
- 11
|
65
|
+
version: 3.2.11
|
66
|
+
name: activesupport
|
67
|
+
version_requirements: *id003
|
68
|
+
prerelease: false
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
type: :development
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 47
|
77
|
+
segments:
|
78
|
+
- 2
|
79
|
+
- 8
|
80
|
+
- 0
|
81
|
+
version: 2.8.0
|
82
|
+
name: rspec
|
83
|
+
version_requirements: *id004
|
84
|
+
prerelease: false
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
type: :development
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 5
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
- 7
|
96
|
+
version: "0.7"
|
97
|
+
name: yard
|
98
|
+
version_requirements: *id005
|
99
|
+
prerelease: false
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
type: :development
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ~>
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 63
|
108
|
+
segments:
|
109
|
+
- 1
|
110
|
+
- 8
|
111
|
+
- 4
|
112
|
+
version: 1.8.4
|
113
|
+
name: jeweler
|
114
|
+
version_requirements: *id006
|
115
|
+
prerelease: false
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
type: :development
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ~>
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 13
|
124
|
+
segments:
|
125
|
+
- 1
|
126
|
+
- 6
|
127
|
+
- 1
|
128
|
+
version: 1.6.1
|
129
|
+
name: guard
|
130
|
+
version_requirements: *id007
|
131
|
+
prerelease: false
|
132
|
+
- !ruby/object:Gem::Dependency
|
133
|
+
type: :development
|
134
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ~>
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 23
|
140
|
+
segments:
|
141
|
+
- 1
|
142
|
+
- 0
|
143
|
+
- 0
|
144
|
+
version: 1.0.0
|
145
|
+
name: guard-bundler
|
146
|
+
version_requirements: *id008
|
147
|
+
prerelease: false
|
148
|
+
- !ruby/object:Gem::Dependency
|
149
|
+
type: :development
|
150
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ~>
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
hash: 29
|
156
|
+
segments:
|
157
|
+
- 1
|
158
|
+
- 2
|
159
|
+
- 1
|
160
|
+
version: 1.2.1
|
161
|
+
name: guard-rspec
|
162
|
+
version_requirements: *id009
|
163
|
+
prerelease: false
|
164
|
+
- !ruby/object:Gem::Dependency
|
165
|
+
type: :development
|
166
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ~>
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
hash: 47
|
172
|
+
segments:
|
173
|
+
- 0
|
174
|
+
- 8
|
175
|
+
- 8
|
176
|
+
version: 0.8.8
|
177
|
+
name: rb-inotify
|
178
|
+
version_requirements: *id010
|
179
|
+
prerelease: false
|
180
|
+
description: YoolinkPro API Ruby SDK, manage your feed, users, groups, teams...
|
181
|
+
email: vincent@yoolink.fr
|
182
|
+
executables: []
|
183
|
+
|
184
|
+
extensions: []
|
185
|
+
|
186
|
+
extra_rdoc_files:
|
187
|
+
- LICENSE.txt
|
188
|
+
- README.rdoc
|
189
|
+
files:
|
190
|
+
- .document
|
191
|
+
- .rspec
|
192
|
+
- .rvmrc
|
193
|
+
- Gemfile
|
194
|
+
- Gemfile.lock
|
195
|
+
- Guardfile
|
196
|
+
- LICENSE.txt
|
197
|
+
- README.rdoc
|
198
|
+
- Rakefile
|
199
|
+
- VERSION
|
200
|
+
- lib/hash_ext.rb
|
201
|
+
- lib/yoolinkpro-ruby-sdk.rb
|
202
|
+
- lib/yoolinkpro/api.rb
|
203
|
+
- lib/yoolinkpro/client.rb
|
204
|
+
- lib/yoolinkpro/exceptions.rb
|
205
|
+
- spec/hash_ext_spec.rb
|
206
|
+
- spec/spec_helper.rb
|
207
|
+
- spec/yoolinkpro-ruby-sdk_spec.rb
|
208
|
+
- yoolinkpro-ruby-sdk.gemspec
|
209
|
+
has_rdoc: true
|
210
|
+
homepage: http://github.com/madwork/yoolinkpro-ruby-sdk
|
211
|
+
licenses:
|
212
|
+
- MIT
|
213
|
+
post_install_message:
|
214
|
+
rdoc_options: []
|
215
|
+
|
216
|
+
require_paths:
|
217
|
+
- lib
|
218
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
+
none: false
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
hash: 3
|
224
|
+
segments:
|
225
|
+
- 0
|
226
|
+
version: "0"
|
227
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
+
none: false
|
229
|
+
requirements:
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
hash: 3
|
233
|
+
segments:
|
234
|
+
- 0
|
235
|
+
version: "0"
|
236
|
+
requirements: []
|
237
|
+
|
238
|
+
rubyforge_project:
|
239
|
+
rubygems_version: 1.6.2
|
240
|
+
signing_key:
|
241
|
+
specification_version: 3
|
242
|
+
summary: YoolinkPro API Ruby SDK
|
243
|
+
test_files: []
|
244
|
+
|