strongmind-platform-sdk 2.15.1 → 2.16.0

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: f578ddf396a05c731db6eea3325b5506e3211441dbc32635cfbc51144cf53591
4
- data.tar.gz: dfeb24568b2146d0c8af18c223bdeeca0ca01f1835d5095571acb6625176560d
3
+ metadata.gz: d76fe6be1ba7a114ba353e9ad774923ab05a8ea96d95550733b26978dffc80f4
4
+ data.tar.gz: '09def8da7b4694b25180d280cd46c426668c74fa5c6852e91a455579506fe871'
5
5
  SHA512:
6
- metadata.gz: 9b2557b3d3fc81ed7d0de75439a5a42f9b650c3c96b75555bf7284a41169f5b672fe27563bb7f5157f2637f8b998c5de3ae4a21f8d2a92b0cb0d6d0aa54f90dd
7
- data.tar.gz: d6ab6e50d0156a9a62dc9e525cd2114529b12eab4b9e75d85df9d169b72fe010b7feec7baa28340ffb44d0ef65b53be5a09eff534ed836565e556567765daab8
6
+ metadata.gz: a3ef4f3d10523e4e060243fc44200f8d384cf4f771445f8ad48f2e7a624c64b806046db85b02b3dcff8c418033e5641c68842a27d4498793d143d1824405894f
7
+ data.tar.gz: a6ec467ed5ab189c49196af905e8dd75c9c83b9790d273eb2c4e3ebd08b372c5870eaf7823f39555087cea808f0104f8f660603f0e803bf71a0ec68a576b51b5
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.1)
4
+ strongmind-platform-sdk (2.16.0)
5
5
  aws-sdk-secretsmanager (~> 1.66)
6
6
  devise
7
7
  faraday (~> 2.5, >= 2.5.2)
data/README.md CHANGED
@@ -11,7 +11,7 @@ First [configure your GitHub credentials](#configure-github-credentials)
11
11
  Install the gem and add to the application's Gemfile by executing:
12
12
 
13
13
  ```
14
- gem "strongmind-platform-sdk", "~> 2.15.1"
14
+ gem "strongmind-platform-sdk", "~> 2.15.2"
15
15
  ```
16
16
 
17
17
  If bundler is not being used to manage dependencies, install the gem by executing:
@@ -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
@@ -43,7 +43,7 @@ module PlatformSdk
43
43
  public
44
44
 
45
45
  def pairs(guid)
46
- path = "api/v1/pairs/#{guid}/"
46
+ path = "api/v1/pairs/#{guid}"
47
47
  begin
48
48
  get(path)
49
49
  rescue Faraday::ResourceNotFound
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformSdk
4
- VERSION = "2.15.1"
4
+ VERSION = "2.16.0"
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.1
4
+ version: 2.16.0
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-22 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