class DMAO::API::Project

Constants

ENDPOINT
INVALID_ENTITY_CLASS
INVALID_ENTITY_ERROR_MESSAGE
INVALID_ID_ERROR
NOT_FOUND_ERROR
VALID_ATTRIBUTES

Public Class Methods

handle_unprocessable_entity(error_response) click to toggle source
# File lib/dmao/api/project.rb, line 87
def self.handle_unprocessable_entity error_response

  errors = parse_error_response error_response

  raise_error_if_key DMAO::API::Errors::InvalidOrganisationUnitID, errors, "owning_unit"

  raise DMAO::API::Errors::InvalidProject.new("Invalid project details, please see errors.", errors)


end
instance_from_api_data(data) click to toggle source
# File lib/dmao/api/project.rb, line 60
def self.instance_from_api_data data

  funder_id = set_id_attribute_if_not_nil data["relationships"]["funder"]["data"]

  attributes = {
      id: data["id"],
      institution_id: data["relationships"]["institution"]["data"]["id"],
      title: data["attributes"]["title"],
      acronym: data["attributes"]["acronym"],
      description: data["attributes"]["description"],
      status: data["attributes"]["status"],
      project_type: data["attributes"]["project-type"],
      classification: data["attributes"]["classification"],
      internal_project_code: data["attributes"]["internal-project-code"],
      url: data["attributes"]["url"],
      start_date: data["attributes"]["start-date"],
      end_date: data["attributes"]["end-date"],
      system_uuid: data["attributes"]["system-uuid"],
      system_modified_at: data["attributes"]["system-modified-at"],
      owning_unit_id: data["relationships"]["owning-unit"]["data"]["id"],
      funder_id: funder_id
  }

  new(attributes)

end
new(attributes) click to toggle source
# File lib/dmao/api/project.rb, line 39
def initialize(attributes)

  @id = attributes[:id]
  @institution_id = attributes[:institution_id]
  @title = attributes[:title]
  @acronym = attributes[:acronym]
  @description = attributes[:description]
  @status = attributes[:status]
  @project_type = attributes[:project_type]
  @classification = attributes[:classification]
  @internal_project_code = attributes[:internal_project_code]
  @url = attributes[:url]
  @start_date = attributes[:start_date]
  @end_date = attributes[:end_date]
  @system_uuid = attributes[:system_uuid]
  @system_modified_at = attributes[:system_modified_at]
  @owning_unit_id = attributes[:owning_unit_id]
  @funder_id = attributes[:funder_id]

end