fortytwo 0.0.17 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea66e83dcd6402f67dd91c9a8c34bbd1cd87f689
4
- data.tar.gz: 646bb4989b21d67f11124e85af06885bff07f432
3
+ metadata.gz: abd620c14ed354ce605b6343943e871f7869dd74
4
+ data.tar.gz: 8ecd25b3b5c19d098543cb6100e1a9e73dc8b50b
5
5
  SHA512:
6
- metadata.gz: 2aacba2ac1ce3a80eb51d9d9625053ef0781ec2459fa5c06f3f2f801994ed716013d07195955145956890a0c40007b6c05db3b9e3673e717ed27177cb4962974
7
- data.tar.gz: 8efe61a35b9bcc4d3143e7cd5d427197b1adb4bfb9fbc31712ba659ec83b0e7ea611341af420125be746aff94f70a634d0a043f547ffb7ca81070ad7349b3ce2
6
+ metadata.gz: 47273245d672620abe80beb1640a37d12553d7d489589f2bb43c6615984bc8ad70986063fc54732b88f7340e3e9e5e07eaa86773c6b9f42f175a80dcc0be087b
7
+ data.tar.gz: 9328df0ccd0066c74d66d6cb09267adc35a395e8a5f6a5ea2e76a01b7b5170fb4de6abfa5e5e48462a00bd041abea3781d8618d1616f3ec639e8a17d8b7fbe58
data/README.md CHANGED
@@ -68,38 +68,71 @@ user.location #=> nil
68
68
  user.wallet #=> 0
69
69
  user.groups #=> []
70
70
 
71
- user.cursus_users.first.id #=> 14121
72
- user.cursus_users.first.begin_at #=> "2016-09-19T22:00:00.000Z"
73
- user.cursus_users.first.end_at #=> nil
74
- user.cursus_users.first.grade #=> "Midshipman"
75
- user.cursus_users.first.level #=> 3.91
76
- user.cursus_users.first.skills #=> nil
77
-
78
- user.cursus_users.first.cursus_id #=> 1
79
- user.cursus_users.first.cursus.id #=> 1
80
- user.cursus_users.first.cursus.created_at #=> "2014-11-02T16:43:38.480Z"
81
- user.cursus_users.first.cursus.name #=> "42"
82
- user.cursus_users.first.cursus.slug #=> "42"
83
-
84
- user.projects_users.first.id #=> 405588
85
- user.projects_users.first.occurence #=> nil
86
- user.projects_users.first.final_mark #=> 115
87
- user.projects_users.first.status #=> "finished"
88
- user.projects_users.first.validated #=> true
89
- user.projects_users.first.current_team_id #=> 1434665
90
- user.projects_users.first.cursus_ids #=> [1]
91
-
92
- user.projects_users.first.project.id #=> 1
93
- user.projects_users.first.project.name #=> "Libft"
94
- user.projects_users.first.project.slug #=> "libft"
95
-
96
- user.expertises_users.first.id #=> 7696
97
- user.expertises_users.first.expertise_id #=> 29
98
- user.expertises_users.first.interested #=> true
99
- user.expertises_users.first.value #=> 2
100
- user.expertises_users.first.contact_me #=> false
101
- user.expertises_users.first.created_at #=> "2016-10-15T02:05:37.861Z"
102
- user.expertises_users.first.user_id #=> 19619
71
+ user.cursus_users.each do |user_cursus|
72
+ user_cursus.id #=> 14121
73
+ user_cursus.begin_at #=> "2016-09-19T22:00:00.000Z"
74
+ user_cursus.end_at #=> nil
75
+ user_cursus.grade #=> "Midshipman"
76
+ user_cursus.level #=> 3.91
77
+ user_cursus.skills #=> nil
78
+ user_cursus.cursus_id #=> 1
79
+
80
+ user_cursus.cursus.id #=> 1
81
+ user_cursus.cursus.created_at #=> "2014-11-02T16:43:38.480Z"
82
+ user_cursus.cursus.name #=> "42"
83
+ user_cursus.cursus.slug #=> "42"
84
+ end
85
+
86
+ user.projects_users.each do |user_project|
87
+ user_project.id #=> 405588
88
+ user_project.occurence #=> nil
89
+ user_project.final_mark #=> 115
90
+ user_project.status #=> "finished"
91
+ user_project.validated #=> true
92
+ user_project.current_team_id #=> 1434665
93
+ user_project.cursus_ids #=> [1]
94
+
95
+ user_project.project.id #=> 1
96
+ user_project.project.name #=> "Libft"
97
+ user_project.project.slug #=> "libft"
98
+ end
99
+
100
+ user.expertises_users.each do |expertise|
101
+ expertise.id #=> 7696
102
+ expertise.expertise_id #=> 29
103
+ expertise.interested #=> true
104
+ expertise.value #=> 2
105
+ expertise.contact_me #=> false
106
+ expertise.created_at #=> "2016-10-15T02:05:37.861Z"
107
+ expertise.user_id #=> 19619
108
+ end
109
+
110
+ user.achievements.each do |achievement|
111
+ achievement.id #=> 41
112
+ achievement.name #=> "In the name of Nicolas"
113
+ achievement.description #=> "Etre logué 90h sur une semaine. (à bosser, comme Nicolas vous l'a conseillé !)"
114
+ achievement.tier #=> "easy"
115
+ achievement.kind #=> "scolarity"
116
+ achievement.visible #=> true
117
+ achievement.image #=> "/uploads/achievement/image/41/SCO001.svg"
118
+ achievement.nbr_of_success #=> nil
119
+ achievement.users_url #=> "https://api.intra.42.fr/v2/achievements/41/users"
120
+ end
121
+
122
+ response = client.user_sessions("mfernand")
123
+ user_sessions = response.user_sessions
124
+
125
+ user_sessions.each do |session|
126
+ session.id #=> 5017063
127
+ session.begin_at #=> "2016-11-14T09:57:19"
128
+ session.end_at #=> "2016-11-14T10:07:19"
129
+ session.primary #-> true
130
+ session.floor #=> nil
131
+ session.row #=> nil
132
+ session.post #=> nil
133
+ session.host #=> "e1z2r7p18"
134
+ session.campus_id #=> 7
135
+ end
103
136
 
104
137
  ```
105
138
 
@@ -1,9 +1,11 @@
1
+ require "active_support/all"
2
+
1
3
  module FortyTwo
2
4
  module Response
3
5
  class Base
4
6
  def initialize(json)
5
7
  return if json.nil?
6
- return instance_variable_set("@user_sessions", json) if json.is_a?(Array)
8
+ return instance_variable_set(instance_variable_name, json) if json.is_a?(Array)
7
9
 
8
10
  json.each do |key, value|
9
11
  key = key.chomp('?') if key.end_with?('?')
@@ -18,6 +20,10 @@ module FortyTwo
18
20
  return klass.new(json) if json
19
21
  nil
20
22
  end
23
+
24
+ def instance_variable_name
25
+ "@#{self.class.name.demodulize.underscore}"
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -0,0 +1,12 @@
1
+ require 'fortytwo/responses/base'
2
+
3
+ module FortyTwo
4
+ module Response
5
+ module Model
6
+ class Achievement < Response::Base
7
+ attr_reader :id, :name, :description, :tier, :kind, :visible,
8
+ :image, :nbr_of_success, :users_url
9
+ end
10
+ end
11
+ end
12
+ end
@@ -3,6 +3,7 @@ require 'fortytwo/responses/models/cursus_user'
3
3
  require 'fortytwo/responses/models/project_user'
4
4
  require 'fortytwo/responses/models/expertise_user'
5
5
  require 'fortytwo/responses/models/campus'
6
+ require 'fortytwo/responses/models/achievement'
6
7
 
7
8
  module FortyTwo
8
9
  module Response
@@ -22,6 +23,7 @@ module FortyTwo
22
23
  @projects_users = parse(@projects_users, ProjectUser)
23
24
  @expertises_users = parse(@expertises_users, ExpertiseUser)
24
25
  @campus = parse(@campus, Campus)
26
+ @achievements = parse(@achievements, Achievement)
25
27
  end
26
28
  end
27
29
  end
@@ -1,3 +1,3 @@
1
1
  module FortyTwo
2
- VERSION = '0.0.17'
2
+ VERSION = '0.1.0'
3
3
  end
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.0.17
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Fernandez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-14 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -139,6 +139,7 @@ files:
139
139
  - lib/fortytwo/endpoints/user.rb
140
140
  - lib/fortytwo/endpoints/user_sessions.rb
141
141
  - lib/fortytwo/responses/base.rb
142
+ - lib/fortytwo/responses/models/achievement.rb
142
143
  - lib/fortytwo/responses/models/campus.rb
143
144
  - lib/fortytwo/responses/models/cursus.rb
144
145
  - lib/fortytwo/responses/models/cursus_user.rb