# Path: pykintone/account.py
# class kintoneService(object):
#     ENCODE = "utf-8"
#     SELECT_LIMIT = 500
#     UPDATE_LIMIT = 100
# 
#     DATE_FORMAT = "%Y-%m-%d"
#     TIME_FORMAT = "%H:%M"
#     DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
#     TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
#     from tzlocal import get_localzone
#     __TIME_ZONE = get_localzone()
# 
#     def __init__(self, account):
#         self.account = account
#         self.__apps = []
# 
#     def __len__(self):
#         return len(self.__apps)
# 
#     def app(self, app_id="", api_token="", app_name=""):
#         from pykintone.application import Application
#         if not app_id:
#             return self.__apps[0]
#         else:
#             existed = [a for a in self.__apps if a.app_id == app_id]
#             # register if not exist
#             if len(existed) > 0:
#                 return existed[0]
#             else:
#                 _a = Application(self.account, app_id, api_token, app_name)
#                 self.__apps.append(_a)
#                 return _a
# 
#     def administration(self,requests_options=()):
#         from pykintone.application_settings.administrator import Administrator
#         return Administrator(self.account, requests_options=requests_options)
# 
#     def user_api(self, requests_options=()):
#         from pykintone.user_api import UserAPI
#         api = UserAPI(self.account, requests_options)
#         return api
# 
#     @classmethod
#     def value_to_date(cls, value):
#         return value if not value else datetime.strptime(value, cls.DATE_FORMAT)
# 
#     @classmethod
#     def value_to_time(cls, value):
#         return value if not value else datetime.strptime(value, cls.TIME_FORMAT)
# 
#     @classmethod
#     def value_to_datetime(cls, value):
#         if value:
#             d = datetime.strptime(value, cls.DATETIME_FORMAT)
#             return cls._to_local(d)
#         else:
#             return None
# 
#     @classmethod
#     def value_to_timestamp(cls, value):
#         if value:
#             d = datetime.strptime(value, cls.TIMESTAMP_FORMAT)
#             return cls._to_local(d)
#         else:
#             return None
# 
#     @classmethod
#     def _to_local(cls, d):
#         utc = d.replace(tzinfo=pytz.utc)  # configure timezone (on kintone, time is utc)
#         local = utc.astimezone(cls.__TIME_ZONE).replace(tzinfo=None)  # to local, and to native
#         return local
# 
#     @classmethod
#     def date_to_value(cls, date):
#         return date.strftime(cls.DATE_FORMAT)
# 
#     @classmethod
#     def time_to_value(cls, time):
#         return time.strftime(cls.TIME_FORMAT)
# 
#     @classmethod
#     def datetime_to_value(cls, dt):
#         local = dt.replace(tzinfo=cls.__TIME_ZONE)
#         utc = local.astimezone(pytz.utc)
#         value = utc.strftime(cls.DATETIME_FORMAT)
#         return value
# 
#     @classmethod
#     def get_default_field_list(cls, as_str=False):
#         from pykintone.structure import FieldType
#         fields = [
#             FieldType.CATEGORY,
#             FieldType.STATUS,
#             FieldType.RECORD_NUMBER,
#             FieldType.CREATED_TIME,
#             FieldType.CREATOR,
#             FieldType.STATUS_ASSIGNEE,
#             FieldType.UPDATED_TIME,
#             FieldType.MODIFIER
#         ]
#         if as_str:
#             str_fields = [f.value for f in fields]
#             return str_fields
#         else:
#             return fields


import re
import inspect
import pykintone.structure_field as sf
from enum import Enum
from datetime import datetime
from pykintone.account import kintoneService as ks


class kintoneStructure(object):

    def __init__(self):
        self._property_details = []

    def _pd(self, name, field_type=None, sub_type=None, unsent=False, field_name="", name_style_conversion=False):
        # sugar syntax for adding property detail
        snake_to_camel = lambda fn: "".join([n if i == 0 else n.capitalize() for i, n in enumerate(fn.split("_"))])
        _field_name = field_name if (field_name and not name_style_conversion) else snake_to_camel(name)
        self._property_details.append(PropertyDetail(name, field_type, sub_type, unsent, _field_name))

    @classmethod
    def _get_property_names(cls, instance):

# Path: pykintone/account.py
# class kintoneService(object):
#     ENCODE = "utf-8"
#     SELECT_LIMIT = 500
#     UPDATE_LIMIT = 100
# 
#     DATE_FORMAT = "%Y-%m-%d"
#     TIME_FORMAT = "%H:%M"
#     DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
#     TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
#     from tzlocal import get_localzone
#     __TIME_ZONE = get_localzone()
# 
#     def __init__(self, account):
#         self.account = account
#         self.__apps = []
# 
#     def __len__(self):
#         return len(self.__apps)
# 
#     def app(self, app_id="", api_token="", app_name=""):
#         from pykintone.application import Application
#         if not app_id:
#             return self.__apps[0]
#         else:
#             existed = [a for a in self.__apps if a.app_id == app_id]
#             # register if not exist
#             if len(existed) > 0:
#                 return existed[0]
#             else:
#                 _a = Application(self.account, app_id, api_token, app_name)
#                 self.__apps.append(_a)
#                 return _a
# 
#     def administration(self,requests_options=()):
#         from pykintone.application_settings.administrator import Administrator
#         return Administrator(self.account, requests_options=requests_options)
# 
#     def user_api(self, requests_options=()):
#         from pykintone.user_api import UserAPI
#         api = UserAPI(self.account, requests_options)
#         return api
# 
#     @classmethod
#     def value_to_date(cls, value):
#         return value if not value else datetime.strptime(value, cls.DATE_FORMAT)
# 
#     @classmethod
#     def value_to_time(cls, value):
#         return value if not value else datetime.strptime(value, cls.TIME_FORMAT)
# 
#     @classmethod
#     def value_to_datetime(cls, value):
#         if value:
#             d = datetime.strptime(value, cls.DATETIME_FORMAT)
#             return cls._to_local(d)
#         else:
#             return None
# 
#     @classmethod
#     def value_to_timestamp(cls, value):
#         if value:
#             d = datetime.strptime(value, cls.TIMESTAMP_FORMAT)
#             return cls._to_local(d)
#         else:
#             return None
# 
#     @classmethod
#     def _to_local(cls, d):
#         utc = d.replace(tzinfo=pytz.utc)  # configure timezone (on kintone, time is utc)
#         local = utc.astimezone(cls.__TIME_ZONE).replace(tzinfo=None)  # to local, and to native
#         return local
# 
#     @classmethod
#     def date_to_value(cls, date):
#         return date.strftime(cls.DATE_FORMAT)
# 
#     @classmethod
#     def time_to_value(cls, time):
#         return time.strftime(cls.TIME_FORMAT)
# 
#     @classmethod
#     def datetime_to_value(cls, dt):
#         local = dt.replace(tzinfo=cls.__TIME_ZONE)
#         utc = local.astimezone(pytz.utc)
#         value = utc.strftime(cls.DATETIME_FORMAT)
#         return value
# 
#     @classmethod
#     def get_default_field_list(cls, as_str=False):
#         from pykintone.structure import FieldType
#         fields = [
#             FieldType.CATEGORY,
#             FieldType.STATUS,
#             FieldType.RECORD_NUMBER,
#             FieldType.CREATED_TIME,
#             FieldType.CREATOR,
#             FieldType.STATUS_ASSIGNEE,
#             FieldType.UPDATED_TIME,
#             FieldType.MODIFIER
#         ]
#         if as_str:
#             str_fields = [f.value for f in fields]
#             return str_fields
#         else:
#             return fields


# Path: pykintone/structure.py
import re
import inspect
import pykintone.structure_field as sf
from enum import Enum
from datetime import datetime
from pykintone.account import kintoneService as ks



class kintoneStructure(object):

    def __init__(self):
        self._property_details = []

    def _pd(self, name, field_type=None, sub_type=None, unsent=False, field_name="", name_style_conversion=False):
        # sugar syntax for adding property detail
        snake_to_camel = lambda fn: "".join([n if i == 0 else n.capitalize() for i, n in enumerate(fn.split("_"))])
        _field_name = field_name if (field_name and not name_style_conversion) else snake_to_camel(name)
        self._property_details.append(PropertyDetail(name, field_type, sub_type, unsent, _field_name))

    @classmethod
    def _get_property_names(cls, instance):

        properties = inspect.getmembers(instance, lambda m: not (inspect.isbuiltin(m) or inspect.isroutine(m)))