from .base import APIView
from django.http import Http404

from three import Three

class QCThree(Three):
	def __init__(self):
		self.endpoint = "http://dev-api.ville.quebec.qc.ca/open311/v2/"
		self.format = "json"
		self.jurisdiction = "ville.quebec.qc.ca"

QC_three = QCThree()

class ServicesView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.services())

class RequestsView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.requests())
	
class RequestView(APIView):
	
	def get(self, request, id):
		requests = QC_three.request(id)
		if requests:
			return self.OkAPIResponse(requests[0])
		else:
			raise Http404
		
from three import Three
from django.http import Http404

from .base import APIView

QC_three = Three(
	endpoint = "http://dev-api.ville.quebec.qc.ca/open311/v2/",
	format = "json",
	jurisdiction = "ville.quebec.qc.ca",
)


class ServicesView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.services())

class RequestsView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.requests())
	
class RequestView(APIView):
	
	def get(self, request, id):
		requests = QC_three.request(id)
		if requests:
			return self.OkAPIResponse(requests[0])
		else:
			raise Http404
		
Initialize the three API wrapper differently to fix a bug.
Initialize the three API wrapper differently to fix a bug.

- from .base import APIView
+ from three import Three
  from django.http import Http404
  
- from three import Three
+ from .base import APIView
  
+ QC_three = Three(
- class QCThree(Three):
- 	def __init__(self):
- 		self.endpoint = "http://dev-api.ville.quebec.qc.ca/open311/v2/"
+ 	endpoint = "http://dev-api.ville.quebec.qc.ca/open311/v2/",
- 		self.format = "json"
+ 	format = "json",
- 		self.jurisdiction = "ville.quebec.qc.ca"
+ 	jurisdiction = "ville.quebec.qc.ca",
+ )
  
- QC_three = QCThree()
  
  class ServicesView(APIView):
  	def get(self, request):
  		return self.OkAPIResponse(QC_three.services())
  
  class RequestsView(APIView):
  	def get(self, request):
  		return self.OkAPIResponse(QC_three.requests())
  	
  class RequestView(APIView):
  	
  	def get(self, request, id):
  		requests = QC_three.request(id)
  		if requests:
  			return self.OkAPIResponse(requests[0])
  		else:
  			raise Http404
  		
Initialize the three API wrapper differently to fix a bug.
## Code Before:
from .base import APIView
from django.http import Http404

from three import Three

class QCThree(Three):
	def __init__(self):
		self.endpoint = "http://dev-api.ville.quebec.qc.ca/open311/v2/"
		self.format = "json"
		self.jurisdiction = "ville.quebec.qc.ca"

QC_three = QCThree()

class ServicesView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.services())

class RequestsView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.requests())
	
class RequestView(APIView):
	
	def get(self, request, id):
		requests = QC_three.request(id)
		if requests:
			return self.OkAPIResponse(requests[0])
		else:
			raise Http404
		
## Instruction:
Initialize the three API wrapper differently to fix a bug.
## Code After:
from three import Three
from django.http import Http404

from .base import APIView

QC_three = Three(
	endpoint = "http://dev-api.ville.quebec.qc.ca/open311/v2/",
	format = "json",
	jurisdiction = "ville.quebec.qc.ca",
)


class ServicesView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.services())

class RequestsView(APIView):
	def get(self, request):
		return self.OkAPIResponse(QC_three.requests())
	
class RequestView(APIView):
	
	def get(self, request, id):
		requests = QC_three.request(id)
		if requests:
			return self.OkAPIResponse(requests[0])
		else:
			raise Http404
		