Class: Renalware::Patients::SyncPracticesViaApi
- Inherits:
-
Object
- Object
- Renalware::Patients::SyncPracticesViaApi
- Defined in:
- app/models/renalware/patients/sync_practices_via_api.rb
Overview
Fetches pratice changes and additions from the NHS ODS API. Called from a rake task. See doc/ods.md
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(api_log:, client: nil, dry_run: false) ⇒ SyncPracticesViaApi
constructor
A new instance of SyncPracticesViaApi.
Constructor Details
#initialize(api_log:, client: nil, dry_run: false) ⇒ SyncPracticesViaApi
Returns a new instance of SyncPracticesViaApi.
15 16 17 18 19 |
# File 'app/models/renalware/patients/sync_practices_via_api.rb', line 15 def initialize(api_log:, client: nil, dry_run: false) @client = client || NHSApiClient::Organisations::Client.new @dry_run = dry_run @api_log = api_log end |
Class Method Details
.call(**args) ⇒ Object
11 12 13 |
# File 'app/models/renalware/patients/sync_practices_via_api.rb', line 11 def self.call(**args) new(**args).call end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/renalware/patients/sync_practices_via_api.rb', line 21 def call if dry_run ActiveRecord::Base.transaction do sync log("Rolling back changes because dry_run=true", flush: true) raise ActiveRecord::Rollback end else sync end end |