strongmind-platform-sdk 2.15.2 → 2.16.1

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
  SHA256:
3
- metadata.gz: f222ada467676a875fa2c5cc326dabf20b0a00f7b265125558e0417494bf1dc1
4
- data.tar.gz: 3246e4a95dcc9dcf8d841bb70c13a992a416264d82337d1953025872be688205
3
+ metadata.gz: 99a87ca7572da045e78c282913ca05aa7d9819675f323bf66df19ed12c513868
4
+ data.tar.gz: c32d7938835d2efdff80a4b78957dc38e2144d07a3e2889c3a4c3b18f16fc219
5
5
  SHA512:
6
- metadata.gz: 7539d8d74541700b3181bde620c987ae2280378cf56881ba4a2f18a68545f8f169e670e215e009dc80b5a292d700d1d63e4dc2548494fb6163f2995300c85c84
7
- data.tar.gz: e6e00d9e9f84c3232039f53e6cd051b1895f40d01bf1a77a7fead742f24daf8d4b94a9e53bd7ec8bb72cc6b6956ecc1a7afa58b9e066586aead1fe5e8464293e
6
+ metadata.gz: b0dfac7a18e457130180cc3fe770edb084bb36ff2f78564de9268075476af4be287f01fa2eafdded396f79dbe4a07ad9088a8ba2b0712a37b1e06391b0cd92dc
7
+ data.tar.gz: 2b112f03cec59903cee5b8dbc438a5e1675cc851ee4beec442e42168d4e55a5648272d92920c0f4035d76cb77f9e158d41b57ab517494a471c9743ac03d92ed8
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.1.3
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strongmind-platform-sdk (2.15.2)
4
+ strongmind-platform-sdk (2.16.1)
5
5
  aws-sdk-secretsmanager (~> 1.66)
6
6
  devise
7
7
  faraday (~> 2.5, >= 2.5.2)
@@ -21,6 +21,8 @@
21
21
  ```
22
22
  IDENTITY_CLIENT_ID=
23
23
  IDENTITY_CLIENT_SECRET=
24
+ IDENTITY_BASE_URL=
25
+ APP_BASE_URL=
24
26
  ```
25
27
  1. For local development, run this to enable caching:
26
28
  ```
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PlatformSdk
4
+ module Edkey
5
+ class Client
6
+ attr_reader :base_url, :client_id, :client_secret, :token, :token_expires_at, :conn
7
+
8
+ def initialize(base_url, client_id, client_secret)
9
+ @client_id = client_id
10
+ @client_secret = client_secret
11
+ @base_url = base_url
12
+
13
+ # @token = "q8XNbZJRJjB4AkCgVlGAxjvEFYm7xeK9"
14
+
15
+ @conn = Faraday.new(base_url) do |faraday|
16
+ faraday.adapter :net_http
17
+ faraday.request :json
18
+ faraday.response :json
19
+ faraday.response :raise_error
20
+ end
21
+ end
22
+
23
+ def headers
24
+ {
25
+ "Authorization" => "Bearer #{access_token}",
26
+ "Content-Type" => "application/json",
27
+ "Accept" => "application/json"
28
+ }
29
+ end
30
+
31
+ def access_token
32
+ if expired?
33
+ response = @conn.post("api/v2/auth/request-token",
34
+ token_request_body.to_json,
35
+ { "Content-Type" => "application/json", "Accept" => "*/*" })
36
+ @token = response.body["token"]
37
+ @token_expires_at = DateTime.strptime(response.body["expires_at"], "%Y-%m-%d %H:%M:%S")
38
+ end
39
+
40
+ @token
41
+ end
42
+
43
+ def expired?
44
+ return true if @token.nil?
45
+
46
+ @token_expires_at < DateTime.now
47
+ end
48
+
49
+ def attendance(start_date, end_date)
50
+ path = "/api/v2/attendance-exporter/long-term"
51
+ body = {
52
+ startDate: start_date,
53
+ endDate: end_date
54
+ }.to_json
55
+ response = @conn.post(path, body, headers)
56
+ response.body
57
+ end
58
+
59
+ private
60
+
61
+ def token_request_body
62
+ {
63
+ clientId: @client_id,
64
+ clientSecret: @client_secret
65
+ }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'platform_sdk/edkey/client'
4
+
5
+ module PlatformSdk
6
+ module Edkey
7
+ class Error < StandardError; end
8
+ end
9
+ end
@@ -46,7 +46,7 @@ module PlatformSdk
46
46
  end
47
47
 
48
48
  def valid_power_query_names
49
- %w[specialprograms]
49
+ %w[specialprograms edkey.attendance_get_daily_total_minutes]
50
50
  end
51
51
 
52
52
  def scrub_query(query_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformSdk
4
- VERSION = "2.15.2"
4
+ VERSION = "2.16.1"
5
5
  end
data/lib/platform_sdk.rb CHANGED
@@ -6,6 +6,7 @@ require "platform_sdk/identity"
6
6
  require "platform_sdk/power_school"
7
7
  require "platform_sdk/aws"
8
8
  require "platform_sdk/id_mapper"
9
+ require "platform_sdk/edkey"
9
10
 
10
11
  module PlatformSdk
11
12
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongmind-platform-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.2
4
+ version: 2.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -158,6 +158,8 @@ files:
158
158
  - lib/platform_sdk.rb
159
159
  - lib/platform_sdk/aws.rb
160
160
  - lib/platform_sdk/aws/secrets_manager_client.rb
161
+ - lib/platform_sdk/edkey.rb
162
+ - lib/platform_sdk/edkey/client.rb
161
163
  - lib/platform_sdk/id_mapper.rb
162
164
  - lib/platform_sdk/id_mapper/client.rb
163
165
  - lib/platform_sdk/id_mapper/constants.rb