strongmind-platform-sdk 3.21.1 → 3.21.2

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: 57b1e8c4260deda607fb5e9dcf977c3a94f9c1571686ebe1d32dcb253bd22eb5
4
- data.tar.gz: a1149d7e49f28bc4e4d8361dd9f193d78202406faed55c2e4e8bbe843c92f911
3
+ metadata.gz: 3e7d0d42072dcbe33f1f9cd7b6e4a51259c7aeb81e3df2075a8ad2d88b6f8f1e
4
+ data.tar.gz: 9319eb65bc4881be26cdd24b77f54c33616e2b38e1bf05997f65bbf236badcbf
5
5
  SHA512:
6
- metadata.gz: b1191a72e8233bf5dc670e8f67ba3d3ba85c5798af7dbd1f6e7b9145e2e76815c78b7c70a29aa78fce90400dc55ad51bbb76406f779009bc2185f23d5611c988
7
- data.tar.gz: 728aa199f77a5dd224e36f55152880d878e72720d3571e7cae87833a1ee909d85af966749cd74fbc183190c28b7e1b22d14301459dce81edb48a1cb8ea3221ce
6
+ metadata.gz: f86bfa1c3e710781d1423ee2445d1a2df145d7badc96501632ea0729ac3e022eb09f3e695eb9e8bc0f64996bec4f05cdef27433195bf61ccbc38a0c1c98b6824
7
+ data.tar.gz: '05816f03571b880939cb9ab1ea797b1689ae32866c2289b03ace4db1787b734d8bb246d9c68444e1cb6fbdc040b055a4677900a46b39e51927d20c09c0ce92f0'
@@ -13,15 +13,18 @@ module PlatformSdk
13
13
  end
14
14
 
15
15
  def send_pipeline_create
16
- send_to_pipeline('created')
16
+ Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('created'),
17
+ one_roster_pipeline_payload)
17
18
  end
18
19
 
19
20
  def send_pipeline_update
20
- send_to_pipeline('modified')
21
+ Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('modified'),
22
+ one_roster_pipeline_payload)
21
23
  end
22
24
 
23
25
  def send_pipeline_destroy
24
- send_to_pipeline('destroyed')
26
+ Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('destroyed'),
27
+ one_roster_pipeline_payload(deleted: true))
25
28
  end
26
29
 
27
30
  def pipeline_payload(action)
@@ -67,20 +70,6 @@ module PlatformSdk
67
70
  def one_roster_pipeline_payload(deleted: false)
68
71
  {}
69
72
  end
70
-
71
- def send_to_pipeline(action)
72
- credentials = {
73
- pipeline_host: ENV.fetch('DATA_PIPELINE_HOST', 'stage-di-data-pipeline-api.strongmind.com'),
74
- pipeline_username: ENV.fetch('DATA_PIPELINE_USERNAME', 'canvas_prod'),
75
- pipeline_password: ENV.fetch('DATA_PIPELINE_PASSWORD', '')
76
- }
77
- client = PlatformSdk::DataPipeline::Client.new(credentials)
78
-
79
- client.post(pipeline_payload(action)) unless Rails.env.development?
80
- return unless respond_to?(:one_roster_data_type) && !Rails.env.development? && one_roster_pipeline_payload(deleted: action == "destroyed").present?
81
-
82
- client.post(one_roster_pipeline_payload(deleted: action == "destroyed"))
83
- end
84
73
  end
85
74
  end
86
75
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_job'
4
+
5
+ module PlatformSdk
6
+ module Jobs
7
+ class SendNounToPipelineJob < ActiveJob::Base
8
+ queue_as :default
9
+
10
+ def perform(message, one_roster_message)
11
+ send_to_pipeline(message, one_roster_message)
12
+ end
13
+
14
+ private
15
+
16
+ def send_to_pipeline(message, one_roster_message)
17
+ credentials = {
18
+ pipeline_host: ENV.fetch('DATA_PIPELINE_HOST', 'stage-di-data-pipeline-api.strongmind.com'),
19
+ pipeline_username: ENV.fetch('DATA_PIPELINE_USERNAME', 'canvas_prod'),
20
+ pipeline_password: ENV.fetch('DATA_PIPELINE_PASSWORD', '')
21
+ }
22
+ client = PlatformSdk::DataPipeline::Client.new(credentials)
23
+
24
+ client.post(message) unless Rails.env.development?
25
+ return unless one_roster_message && !Rails.env.development?
26
+
27
+ client.post(one_roster_message)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,6 +1,8 @@
1
1
  module PlatformSdk
2
2
  module SpecSupport
3
3
  RSpec.shared_examples 'DataPipelineable' do |params = {}|
4
+ include ActiveJob::TestHelper
5
+
4
6
  let(:shared_params) { params }
5
7
  let(:record) { build(described_class.to_s.underscore.to_sym) }
6
8
  let(:data_pipeline_client) { double(PlatformSdk::DataPipeline::Client) }
@@ -16,7 +18,9 @@ module PlatformSdk
16
18
  context 'create' do
17
19
 
18
20
  it 'posts a copy of our data to the data pipeline' do
19
- record.save!
21
+ perform_enqueued_jobs do
22
+ record.save!
23
+ end
20
24
  expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
21
25
  noun: described_class.pipeline_noun,
22
26
  data: record.pipeline_data('created'),
@@ -31,8 +35,10 @@ module PlatformSdk
31
35
  context 'destroy' do
32
36
 
33
37
  it 'posts a copy of our data to the data pipeline' do
34
- record.save!
35
- record.destroy
38
+ perform_enqueued_jobs do
39
+ record.save!
40
+ record.destroy
41
+ end
36
42
 
37
43
  expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
38
44
  noun: described_class.pipeline_noun,
@@ -54,7 +60,9 @@ module PlatformSdk
54
60
  it 'posts a copy of our data to the data pipeline' do
55
61
  column = column_to_update(record)
56
62
  unless column.nil?
57
- update_record(record, column)
63
+ perform_enqueued_jobs do
64
+ update_record(record, column)
65
+ end
58
66
  expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
59
67
  noun: described_class.pipeline_noun,
60
68
  data: record.pipeline_data('modified'),
@@ -71,10 +79,12 @@ module PlatformSdk
71
79
  let(:action) { 'modified' }
72
80
 
73
81
  it 'does not post to the data pipeline' do
74
- record.save!
75
- column = column_to_update(record)
76
- update_record(record, column)
77
- record.save!
82
+ perform_enqueued_jobs do
83
+ record.save!
84
+ column = column_to_update(record)
85
+ update_record(record, column)
86
+ record.save!
87
+ end
78
88
  expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
79
89
  noun: described_class.pipeline_noun,
80
90
  data: record.pipeline_data('modified'),
@@ -3,6 +3,8 @@
3
3
  module PlatformSdk
4
4
  module SpecSupport
5
5
  RSpec.shared_examples 'OneRosterDataPipelineable' do |record_keys|
6
+ include ActiveJob::TestHelper
7
+
6
8
  let(:data) do
7
9
  record_keys.each_with_object({}) do |key, hash|
8
10
  if key == '_type'
@@ -50,7 +52,9 @@ module PlatformSdk
50
52
  let(:action) { 'created' }
51
53
 
52
54
  it 'posts to the data pipeline' do
53
- record.save!
55
+ perform_enqueued_jobs do
56
+ record.save!
57
+ end
54
58
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
55
59
  end
56
60
  end
@@ -68,8 +72,10 @@ module PlatformSdk
68
72
  end
69
73
 
70
74
  it 'posts to the data pipeline' do
71
- record.save!
72
- record.destroy
75
+ perform_enqueued_jobs do
76
+ record.save!
77
+ record.destroy
78
+ end
73
79
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
74
80
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload_deleted)
75
81
  end
@@ -86,7 +92,9 @@ module PlatformSdk
86
92
 
87
93
  it 'posts a copy of our data to the data pipeline' do
88
94
  column = column_to_update(record)
89
- update_record(record, column)
95
+ perform_enqueued_jobs do
96
+ update_record(record, column)
97
+ end
90
98
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
91
99
  end
92
100
 
@@ -96,10 +104,12 @@ module PlatformSdk
96
104
  let(:action) { 'modified' }
97
105
 
98
106
  it 'does not post to the data pipeline' do
99
- record.save!
100
- column = column_to_update(record)
101
- update_record(record, column)
102
- record.save!
107
+ perform_enqueued_jobs do
108
+ record.save!
109
+ column = column_to_update(record)
110
+ update_record(record, column)
111
+ record.save!
112
+ end
103
113
  expect(data_pipeline_client).to have_received(:post).once.with(pipeline_payload)
104
114
  end
105
115
  end
@@ -3,7 +3,7 @@
3
3
  module PlatformSdk
4
4
  MAJOR = 3
5
5
  MINOR = 21
6
- PATCH = 1
6
+ PATCH = 2
7
7
 
8
8
  VERSION = "#{PlatformSdk::MAJOR}.#{PlatformSdk::MINOR}.#{PlatformSdk::PATCH}"
9
9
  end
data/lib/platform_sdk.rb CHANGED
@@ -23,6 +23,7 @@ require "fog-aws"
23
23
  require "platform_sdk/asset_sync_initializer"
24
24
  require "platform_sdk/sidekiq/ecs_task_protection_middleware"
25
25
  require "platform_sdk/sidekiq"
26
+ require "platform_sdk/jobs/send_noun_to_pipeline_job"
26
27
 
27
28
  module PlatformSdk
28
29
  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: 3.21.1
4
+ version: 3.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-12 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -273,6 +273,7 @@ files:
273
273
  - lib/platform_sdk/id_mapper/models/domain.rb
274
274
  - lib/platform_sdk/identity.rb
275
275
  - lib/platform_sdk/identity/clients.rb
276
+ - lib/platform_sdk/jobs/send_noun_to_pipeline_job.rb
276
277
  - lib/platform_sdk/learnosity_api.rb
277
278
  - lib/platform_sdk/learnosity_api/client.rb
278
279
  - lib/platform_sdk/one_roster.rb