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

"""
instagramapi

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

from apimatic_core.configurations.global_configuration import GlobalConfiguration
from apimatic_core.decorators.lazy_property import LazyProperty
from instagramapi.configuration import Configuration
from instagramapi.controllers.base_controller import BaseController
from instagramapi.configuration import Environment
from instagramapi.http.auth.api_key import ApiKey
from instagramapi.http.auth.instagram_auth import InstagramAuth
from instagramapi.controllers.users_controller import UsersController
from instagramapi.controllers.relationships_controller\
    import RelationshipsController
from instagramapi.controllers.media_controller import MediaController
from instagramapi.controllers.comments_controller import CommentsController
from instagramapi.controllers.likes_controller import LikesController
from instagramapi.controllers.tags_controller import TagsController
from instagramapi.controllers.locations_controller import LocationsController
from instagramapi.controllers.geographies_controller\
    import GeographiesController


class InstagramapiClient(object):
    @LazyProperty
    def users(self):
        return UsersController(self.global_configuration)

    @LazyProperty
    def relationships(self):
        return RelationshipsController(self.global_configuration)

    @LazyProperty
    def media(self):
        return MediaController(self.global_configuration)

    @LazyProperty
    def comments(self):
        return CommentsController(self.global_configuration)

    @LazyProperty
    def likes(self):
        return LikesController(self.global_configuration)

    @LazyProperty
    def tags(self):
        return TagsController(self.global_configuration)

    @LazyProperty
    def locations(self):
        return LocationsController(self.global_configuration)

    @LazyProperty
    def geographies(self):
        return GeographiesController(self.global_configuration)

    @property
    def instagram_auth(self):
        return self.auth_managers['instagram_auth']

    def __init__(self, http_client_instance=None,
                 override_http_client_configuration=False, http_call_back=None,
                 timeout=60, max_retries=0, backoff_factor=2,
                 retry_statuses=None, retry_methods=None,
                 environment=Environment.PRODUCTION, api_key_credentials=None,
                 instagram_auth_credentials=None, config=None):
        self.config = config or Configuration(
            http_client_instance=http_client_instance,
            override_http_client_configuration=override_http_client_configuration,
            http_call_back=http_call_back, timeout=timeout,
            max_retries=max_retries, backoff_factor=backoff_factor,
            retry_statuses=retry_statuses, retry_methods=retry_methods,
            environment=environment, api_key_credentials=api_key_credentials,
            instagram_auth_credentials=instagram_auth_credentials)

        self.global_configuration = GlobalConfiguration(self.config)\
            .global_errors(BaseController.global_errors())\
            .base_uri_executor(self.config.get_base_uri)\
            .user_agent(BaseController.user_agent(), BaseController.user_agent_parameters())

        self.auth_managers = {key: None for key in ['api_key',
                                                    'instagram_auth']}
        self.auth_managers['api_key'] = ApiKey(self.config.api_key_credentials)
        self.auth_managers['instagram_auth'] = InstagramAuth(
            self.config.instagram_auth_credentials, self.global_configuration)
        self.global_configuration = self.global_configuration.auth_managers(self.auth_managers)

