class Paya::LocationService < Paya::ApplicationService
  def initialize(school, method)
    @method = method
    super(school)
  end

  def call
    response = if @method == :show
      params = { params: { location_api_id: @school.id.to_s } }
      RestClient.get(endpoint, headers.merge(params))
    end

    JSON.parse(response)
  rescue RestClient::Exception => e
    JSON.parse(e.response.body)
  end

  private
    def endpoint
      "#{base_uri}/locations"
    end
end
