class Contentful::Management::Link

Resource Class for Links www.contentful.com/developers/documentation/content-delivery-api/#links

Public Instance Methods

resolve(space_id = nil, environment_id = nil) click to toggle source

Queries contentful for the Resource the Link is referring to @param [String] space_id @param [String] environment_id

# File lib/contentful/management/link.rb, line 14
def resolve(space_id = nil, environment_id = nil)
  return client.spaces.find(id) if link_type == 'Space'

  method = Contentful::Management::Support.base_path_for(link_type).to_sym

  if space_id && environment_id.nil?
    return client.public_send(
      method,
      space_id
    ).find(id)
  elsif space_id && environment_id
    return client.public_send(
      method,
      space_id,
      environment_id
    ).find(id)
  end

  client.public_send(method).find(id)
end