fortytwo 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +6 -1
- data/lib/fortytwo/client.rb +4 -1
- data/lib/fortytwo/endpoints/users.rb +34 -0
- data/lib/fortytwo/responses/users.rb +16 -0
- data/lib/fortytwo/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0333f20c80cbf473c5375c9e8d889dcccfad8882
|
4
|
+
data.tar.gz: 321bf68b6ec5dabfccdb0f530e9fca7138cced18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b66ff8593d57061e98349af1d417deb31bc56676d699d26130d19ad7ce5a886edbd361c6e0d8135b1eb574ac8ed0d8c88fd7af74acc73a176e6320886d22c4
|
7
|
+
data.tar.gz: b7c6bd81280de3bfcbe283f58a74a64e3d85333486c46b054e92ac63b5acae5a48c27c90e6be8feb2f9dc8ea92b5ede19eb3e076c409f9a73c35e68db6a7abc7
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2
|
data/README.md
CHANGED
@@ -74,9 +74,14 @@ user.cursus_users.each do |user_cursus|
|
|
74
74
|
user_cursus.end_at #=> nil
|
75
75
|
user_cursus.grade #=> "Midshipman"
|
76
76
|
user_cursus.level #=> 3.91
|
77
|
-
user_cursus.skills #=> nil
|
78
77
|
user_cursus.cursus_id #=> 1
|
79
78
|
|
79
|
+
user_cursus.skills.each do |skill|
|
80
|
+
skill.id #=> 3
|
81
|
+
skill.name #=> "Rigor"
|
82
|
+
skill.level #=> 2.88
|
83
|
+
end
|
84
|
+
|
80
85
|
user_cursus.cursus.id #=> 1
|
81
86
|
user_cursus.cursus.created_at #=> "2014-11-02T16:43:38.480Z"
|
82
87
|
user_cursus.cursus.name #=> "42"
|
data/lib/fortytwo/client.rb
CHANGED
@@ -2,12 +2,15 @@ require 'oauth2'
|
|
2
2
|
|
3
3
|
require 'fortytwo/configuration'
|
4
4
|
require 'fortytwo/endpoints/user'
|
5
|
+
require 'fortytwo/endpoints/users'
|
5
6
|
require 'fortytwo/endpoints/user_sessions'
|
6
7
|
|
7
8
|
module FortyTwo
|
8
9
|
class Client
|
9
10
|
API_HOST = 'https://api.intra.42.fr'
|
10
|
-
REQUEST_CLASSES = [FortyTwo::Endpoint::User,
|
11
|
+
REQUEST_CLASSES = [FortyTwo::Endpoint::User,
|
12
|
+
FortyTwo::Endpoint::Users,
|
13
|
+
FortyTwo::Endpoint::UserSessions]
|
11
14
|
|
12
15
|
attr_reader :configuration
|
13
16
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'fortytwo/responses/users'
|
2
|
+
|
3
|
+
module FortyTwo
|
4
|
+
module Endpoint
|
5
|
+
class Users
|
6
|
+
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
def users(campus = nil, pool_year = nil, pool_month = nil, params = { page: 1, per_page: 100 })
|
12
|
+
Response::Users.new(users_request(campus, pool_year, pool_month, params))
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def users_request(campus, pool_year, pool_month, params)
|
18
|
+
@client.token.get("/v2#{campus_path(campus)}/users#{pool_year_filter(pool_year)}#{pool_month_filter(pool_month)}", params: params).parsed
|
19
|
+
end
|
20
|
+
|
21
|
+
def campus_path(campus)
|
22
|
+
"/campus/#{campus}" if campus
|
23
|
+
end
|
24
|
+
|
25
|
+
def pool_year_filter(pool_year)
|
26
|
+
"?filter[pool_year]=#{pool_year}" if pool_year
|
27
|
+
end
|
28
|
+
|
29
|
+
def pool_month_filter(pool_month)
|
30
|
+
"&filter[pool_month]=#{pool_month}" if pool_month
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fortytwo/responses/base'
|
2
|
+
require 'fortytwo/responses/models/user'
|
3
|
+
|
4
|
+
module FortyTwo
|
5
|
+
module Response
|
6
|
+
class Users < Base
|
7
|
+
attr_reader :users
|
8
|
+
|
9
|
+
def initialize(json)
|
10
|
+
super(json)
|
11
|
+
|
12
|
+
@users = parse(@users, Model::User)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/fortytwo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortytwo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Fernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/fortytwo/configuration.rb
|
139
139
|
- lib/fortytwo/endpoints/user.rb
|
140
140
|
- lib/fortytwo/endpoints/user_sessions.rb
|
141
|
+
- lib/fortytwo/endpoints/users.rb
|
141
142
|
- lib/fortytwo/responses/base.rb
|
142
143
|
- lib/fortytwo/responses/models/achievement.rb
|
143
144
|
- lib/fortytwo/responses/models/campus.rb
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- lib/fortytwo/responses/models/user_session.rb
|
153
154
|
- lib/fortytwo/responses/user.rb
|
154
155
|
- lib/fortytwo/responses/user_sessions.rb
|
156
|
+
- lib/fortytwo/responses/users.rb
|
155
157
|
- lib/fortytwo/version.rb
|
156
158
|
- tasks/console.rake
|
157
159
|
homepage: https://github.com/MatiasFMolinari/fortytwo
|
@@ -174,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
176
|
version: '0'
|
175
177
|
requirements: []
|
176
178
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.4.5
|
178
180
|
signing_key:
|
179
181
|
specification_version: 4
|
180
182
|
summary: Ruby client library for the 42 API
|