strongmind-platform-sdk 3.26.14 → 3.26.16

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: e32339c1ac422b88104e8ee07dd671f8ffbc4d545ba5bdd2e23c386f960f3ad5
4
- data.tar.gz: 0d12d419c9179d38ddca9b89adc1001ceeee411420504b9f7514c3c7f71fb1c0
3
+ metadata.gz: 3a42cb61d0d13bf1f3b791c263535960d65aa6d5261411f9c735c660dc9cf40d
4
+ data.tar.gz: 7a0ff8baf059d62483fbb595aa8c48b926083ab3d33cad8c95eba0d38a25faf4
5
5
  SHA512:
6
- metadata.gz: 9e7f5401179755f238e49216b175a27c55b59a8b5691233c7005c0929e044a6a49ace100c09313cc9b9b64bd6df5840d097ff862e2f3b247d8a088d7e24970aa
7
- data.tar.gz: 35cd1ba453e0f8a546ff699b7fde26e254804fbe9c05a0912cb6d5cc623dfc904fceec9d802c3ea6acd65f4fb65633595bec2a80fae40c286b2174e1c768b89a
6
+ metadata.gz: cbaa923563742d0a63bb0b17fbab371136678dc10d9805203e4e4a1ad208c71dd0c26abcd3dd923e8835a3c581d2211d398a51c093e7f1f5a9811184c640539c
7
+ data.tar.gz: 56aace7fc201821ab1f9431f5f6f6a68049453029e5d3a648365d3cdb8de5e3d951e91f260abe9e3e9f2796eb7983956501cd3462efc1b42feec910e8f5e454a
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.2.6
@@ -13,16 +13,22 @@ module PlatformSdk
13
13
  end
14
14
 
15
15
  def send_pipeline_create
16
+ return if Rails.env.development?
17
+
16
18
  Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('created'),
17
- one_roster_pipeline_payload)
19
+ one_roster_pipeline_payload)
18
20
  end
19
21
 
20
22
  def send_pipeline_update
23
+ return if Rails.env.development?
24
+
21
25
  Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('modified'),
22
26
  one_roster_pipeline_payload)
23
27
  end
24
28
 
25
29
  def send_pipeline_destroy
30
+ return if Rails.env.development?
31
+
26
32
  Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('destroyed'),
27
33
  one_roster_pipeline_payload(deleted: true))
28
34
  end
@@ -6,9 +6,10 @@ module PlatformSdk
6
6
  class Client
7
7
  attr_reader :base_url, :conn
8
8
 
9
- def initialize(base_url, conn: nil)
9
+ def initialize(base_url, client_id: nil, client_secret: nil, identity_base_url: nil)
10
10
  @base_url = base_url
11
- @conn = conn || build_connection
11
+ @auth = setup_auth_client(client_id, client_secret, identity_base_url)
12
+ @conn = build_connection
12
13
  end
13
14
 
14
15
  # Schools operations
@@ -29,6 +30,15 @@ module PlatformSdk
29
30
  get_payload("/api/v1/DetailModels/#{detail_model_id}")
30
31
  end
31
32
 
33
+ def get_course_image_by_external_course(canvas_domain:, canvas_account_id:, external_course_id:)
34
+ params = {
35
+ canvasDomain: canvas_domain,
36
+ canvasAccountId: canvas_account_id,
37
+ externalCourseId: external_course_id
38
+ }
39
+ get_authenticated_payload_with_params('/api/v1/schools/course-image', params)
40
+ end
41
+
32
42
  private
33
43
 
34
44
  def build_connection
@@ -41,10 +51,28 @@ module PlatformSdk
41
51
  end
42
52
  end
43
53
 
54
+ def setup_auth_client(client_id, client_secret, identity_base_url)
55
+ return nil if client_id.nil? || client_secret.nil? || identity_base_url.nil?
56
+
57
+ PlatformSdk::Identity::AuthClient.new(identity_base_url, client_id, client_secret)
58
+ end
59
+
44
60
  def get_payload(path)
45
61
  response = @conn.get(path)
46
62
  response.body
47
63
  end
64
+
65
+ def get_payload_with_params(path, params)
66
+ response = @conn.get(path, params)
67
+ response.body
68
+ end
69
+
70
+ def get_authenticated_payload_with_params(path, params)
71
+ response = @conn.get(path, params) do |req|
72
+ req.headers['Authorization'] = "Bearer #{@auth.auth_token}" if @auth
73
+ end
74
+ response.body
75
+ end
48
76
  end
49
77
  end
50
78
  end
@@ -3,6 +3,7 @@
3
3
  require 'faraday'
4
4
  require 'faraday/net_http'
5
5
  require 'faraday/retry'
6
+ require 'platform_sdk/identity/clients'
6
7
  require 'platform_sdk/catalog_manager/client'
7
8
 
8
9
  module PlatformSdk
@@ -21,8 +21,8 @@ module PlatformSdk
21
21
  }
22
22
  client = PlatformSdk::DataPipeline::Client.new(credentials)
23
23
 
24
- client.post(message) unless Rails.env.development?
25
- return unless one_roster_message.present? && !Rails.env.development?
24
+ client.post(message)
25
+ return unless one_roster_message.present?
26
26
 
27
27
  client.post(one_roster_message)
28
28
  end
@@ -49,6 +49,14 @@ module PlatformSdk
49
49
  identifiers: { id: record.id }
50
50
  ))
51
51
  end
52
+
53
+ it 'does not post to the data pipeline if in development environment' do
54
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
55
+ perform_enqueued_jobs do
56
+ record.save!
57
+ end
58
+ expect(data_pipeline_client).not_to have_received(:post)
59
+ end
52
60
  end
53
61
 
54
62
  context 'update' do
@@ -73,6 +81,15 @@ module PlatformSdk
73
81
  ))
74
82
  end
75
83
  end
84
+
85
+ it 'does not post to the data pipeline if in development environment' do
86
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
87
+ column = column_to_update(record)
88
+ perform_enqueued_jobs do
89
+ update_record(record, column)
90
+ end
91
+ expect(data_pipeline_client).not_to have_received(:post)
92
+ end
76
93
  end
77
94
 
78
95
  context 'after an update that does not change data' do
@@ -59,6 +59,14 @@ module PlatformSdk
59
59
  end
60
60
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
61
61
  end
62
+
63
+ it 'does not post to the data pipeline if in development environment' do
64
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
65
+ perform_enqueued_jobs do
66
+ record.save!
67
+ end
68
+ expect(data_pipeline_client).not_to have_received(:post)
69
+ end
62
70
  end
63
71
 
64
72
  context 'destroy' do
@@ -81,6 +89,15 @@ module PlatformSdk
81
89
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
82
90
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload_deleted)
83
91
  end
92
+
93
+ it 'does not post to the data pipeline if in development environment' do
94
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
95
+ perform_enqueued_jobs do
96
+ record.save!
97
+ record.destroy
98
+ end
99
+ expect(data_pipeline_client).not_to have_received(:post)
100
+ end
84
101
  end
85
102
 
86
103
  context 'update' do
@@ -91,7 +108,6 @@ module PlatformSdk
91
108
  end
92
109
 
93
110
  context 'after an update' do
94
-
95
111
  it 'posts a copy of our data to the data pipeline' do
96
112
  column = column_to_update(record)
97
113
  perform_enqueued_jobs do
@@ -100,6 +116,14 @@ module PlatformSdk
100
116
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
101
117
  end
102
118
 
119
+ it 'does not post to the data pipeline if in development environment' do
120
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
121
+ column = column_to_update(record)
122
+ perform_enqueued_jobs do
123
+ update_record(record, column)
124
+ end
125
+ expect(data_pipeline_client).not_to have_received(:post)
126
+ end
103
127
  end
104
128
 
105
129
  context 'after an update that does not change data' do
@@ -3,7 +3,7 @@
3
3
  module PlatformSdk
4
4
  MAJOR = 3
5
5
  MINOR = 26
6
- PATCH = 14
6
+ PATCH = 16
7
7
 
8
8
  VERSION = "#{PlatformSdk::MAJOR}.#{PlatformSdk::MINOR}.#{PlatformSdk::PATCH}"
9
9
  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: 3.26.14
4
+ version: 3.26.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-12 00:00:00.000000000 Z
11
+ date: 2025-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday