diff --git a/Gemfile.lock b/Gemfile.lock index 645b9a6..b1ad427 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - lockstep_rails (0.3.84) + lockstep_rails (0.3.85) rails GEM diff --git a/app/models/lockstep/workflow_status.rb b/app/models/lockstep/workflow_status.rb index ac640ff..a3c786a 100644 --- a/app/models/lockstep/workflow_status.rb +++ b/app/models/lockstep/workflow_status.rb @@ -5,4 +5,22 @@ class Lockstep::WorkflowStatus < Lockstep::ApiRecord self.id_ref = 'id' load_schema(Schema::WorkflowStatus) + + def self.retrieve_by_id_with_children(id) + resp = resource.get("#{id}", params: { include: :children }) + parsed_response = JSON.parse(resp.body) + + case resp.code.to_s + when '401' + raise Lockstep::Exceptions::UnauthorizedError, parsed_response['title'] + when '400' + raise Lockstep::Exceptions::BadRequestError, parsed_response['title'] + when '404' + raise Lockstep::Exceptions::RecordNotFound, parsed_response['title'] + when '200' + parsed_response.deep_transform_keys(&:underscore) + else + raise Lockstep::Exceptions::BadRequestError, parsed_response + end + end end diff --git a/lib/lockstep_rails/version.rb b/lib/lockstep_rails/version.rb index 0becf44..7b42858 100644 --- a/lib/lockstep_rails/version.rb +++ b/lib/lockstep_rails/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module LockstepRails - VERSION = '0.3.84' + VERSION = '0.3.85' end