Method: Camdram::Client#get_org

Defined in:
lib/camdram/client.rb

#get_org(id) ⇒ Camdram::Organisation

Lookup an organisation by its ID or slug

Parameters:

  • id (Integer)

    The numeric ID of the organisation.

  • id (String)

    The slug of the organisation.

Returns:

Raises:

  • (ArgumentError)

    Error raised when an integer or string is not provided.



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/camdram/client.rb', line 109

def get_org(id)
  url = nil
  if id.is_a? Integer
    url = "#{Organisation.url}/by-id/#{id}.json"
  elsif id.is_a? String
    url = "#{Organisation.url}/#{id}.json"
  else
    raise ArgumentError.new 'id must be an integer, or slug must be a string'
  end
  response = get(url)
  Organisation.new(response)
end