# -*- coding: utf-8 -*-

"""
instagramapi

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""

from deprecation import deprecated
from instagramapi.api_helper import APIHelper
from instagramapi.configuration import Server
from instagramapi.controllers.base_controller import BaseController
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter
from instagramapi.http.http_method_enum import HttpMethodEnum
from apimatic_core.authentication.multiple.single_auth import Single
from apimatic_core.authentication.multiple.or_auth_group import Or
from instagramapi.models.media_list_response import MediaListResponse


class GeographiesController(BaseController):

    """A Controller to access Endpoints in the instagramapi API."""
    def __init__(self, config):
        super(GeographiesController, self).__init__(config)

    @deprecated()
    def get_recent_media_from_a_custom_geo_id(self,
                                              geo_id,
                                              count=None,
                                              min_id=None):
        """Does a GET request to /geographies/{geo-id}/media/recent.

        Get recent media from a geography subscription that you created.
        **Note:** You can only access Geographies that were explicitly created
        by your OAuth client. Check the
        Geography Subscriptions section of the [real-time updates
        page](https://instagram.com/developer/realtime/).
        When you create a subscription to some geography that you define, you
        will be returned a unique `geo-id` that
        can be used in this query. To backfill photos from the location
        covered by this geography, use the
        [media search
        endpoint](https://instagram.com/developer/endpoints/media/).
        **Warning:** [Deprecated](http://instagram.com/developer/changelog/)
        for Apps created **on or after** Nov 17, 2015

        Args:
            geo_id (str): The geography ID.
            count (int, optional): Max number of media to return.
            min_id (str, optional): Return media before this `min_id`.

        Returns:
            MediaListResponse: Response from the API. List of recent media
                entries from a geography subscription.

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path('/geographies/{geo-id}/media/recent')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('geo-id')
                            .value(geo_id)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('count')
                         .value(count))
            .query_param(Parameter()
                         .key('min_id')
                         .value(min_id))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('api_key'), Single('instagram_auth')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(MediaListResponse.from_dictionary)
        ).execute()
