fortytwo 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa27d5a2d701420805a12d81277cc1a70397c835
4
- data.tar.gz: dce801ccabb6cb708c70b0989f7455f553c8d5be
3
+ metadata.gz: cedb851e9d7327673f703c46e8a0b8f4fe72cbf9
4
+ data.tar.gz: a33ee8098ee34a42a3c447d5620751cdfd478ba4
5
5
  SHA512:
6
- metadata.gz: f8b9db68df3b7619c262a26040e6ebfdbd9006cb791173d902e0f35515aae1c7d19a09eccf8527fbcc55783d9b76c44310158a2453fb3215fb2d457e2671599d
7
- data.tar.gz: 81d4562b13878de058aacec7046350a059fe5b1ac56f2168d80d2b4fe88419427e55d2cb7c2e757bc0940d0caad1fbeac7726487fea4d177faa72d8a1bd76ed6
6
+ metadata.gz: 6530acae6a01b66bf09b37da422332e2bc029a5be36bfa219170bbd318fbd369a4e5f8dba080edcfcb261556eb1390928a3e75bf6272c042e8ae79f39f3db91b
7
+ data.tar.gz: e8e652ffaf708f894790b75f4ba61bc669e202310b87211e3798157ae1a23abdd133231a7f7f8343e9ee3d4cb83551afa1f3760d1fe3caa1367081113ab92dd3
data/README.md CHANGED
@@ -34,7 +34,7 @@ This gem uses a client model to query against the API. You need to create and co
34
34
 
35
35
  ### Initialize
36
36
 
37
- Once you have you're key's you can initialize it like this:
37
+ Once you have your key's you can initialize it like this:
38
38
 
39
39
  ```ruby
40
40
  require 'fortytwo'
@@ -3,20 +3,19 @@ require 'fortytwo/responses/user'
3
3
  module FortyTwo
4
4
  module Endpoint
5
5
  class User
6
- PATH = '/v2/users'
7
6
 
8
7
  def initialize(client)
9
8
  @client = client
10
9
  end
11
10
 
12
- def user(username, params = {})
11
+ def user(username, params = { per_page: 100 })
13
12
  Response::User.new(user_request(username, params))
14
13
  end
15
14
 
16
15
  private
17
16
 
18
- def user_request(username, params = {})
19
- @client.token.get("#{PATH}/#{username}", params: params).parsed
17
+ def user_request(username, params)
18
+ @client.token.get("/v2/users/#{username}", params: params).parsed
20
19
  end
21
20
  end
22
21
  end
@@ -0,0 +1,30 @@
1
+ require 'fortytwo/responses/user_sessions'
2
+
3
+ module FortyTwo
4
+ module Endpoint
5
+ class User
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def user_sessions(username, start_time = last_monday, end_time = right_now, params = { per_page: 100 })
12
+ Response::UserSessions.new(user_request(username, start_time, end_time, params))
13
+ end
14
+
15
+ private
16
+
17
+ def user_sessions_request(username, start_time, end_time, params)
18
+ @client.token.get("/v2/users/#{username}/locations?range[begin_at]=#{start_time},#{end_time}", params: params).parsed
19
+ end
20
+
21
+ def last_monday
22
+ Time.current.beginning_of_week.to_s.split(" ")[0...-1].join("T")
23
+ end
24
+
25
+ def right_now
26
+ Time.current.to_s.split(" ")[0...-1].join("T")
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ require 'fortytwo/responses/base'
2
+
3
+ module FortyTwo
4
+ module Response
5
+ module Model
6
+ class UserSession < Response::Base
7
+ attr_reader :id, :begin_at, :end_at, :primary, :floor, :row, :post,
8
+ :host, :campus_id
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'fortytwo/responses/base'
2
+ require 'fortytwo/responses/models/user_sessions'
3
+
4
+ module FortyTwo
5
+ module Response
6
+ class UserSessions < Base
7
+ attr_reader :user_sessions
8
+
9
+ def initialize(json)
10
+ super(json)
11
+
12
+ @user_sessions = parse(@user_sessions, Model::UserSession)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module FortyTwo
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
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.5
4
+ version: 0.0.6
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-13 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -123,6 +123,7 @@ files:
123
123
  - lib/fortytwo/client.rb
124
124
  - lib/fortytwo/configuration.rb
125
125
  - lib/fortytwo/endpoints/user.rb
126
+ - lib/fortytwo/endpoints/user_sessions.rb
126
127
  - lib/fortytwo/responses/base.rb
127
128
  - lib/fortytwo/responses/models/campus.rb
128
129
  - lib/fortytwo/responses/models/cursus.rb
@@ -133,7 +134,9 @@ files:
133
134
  - lib/fortytwo/responses/models/project_user.rb
134
135
  - lib/fortytwo/responses/models/skill.rb
135
136
  - lib/fortytwo/responses/models/user.rb
137
+ - lib/fortytwo/responses/models/user_session.rb
136
138
  - lib/fortytwo/responses/user.rb
139
+ - lib/fortytwo/responses/user_sessions.rb
137
140
  - lib/fortytwo/version.rb
138
141
  - tasks/console.rake
139
142
  homepage: https://github.com/MatiasFMolinari/fortytwo