icoxfog417 / pykintone

Python library to access kintone
Apache License 2.0
27 stars 12 forks source link

Support the US and Chinese region #33

Open yamaryu0508 opened 6 years ago

yamaryu0508 commented 6 years ago

Now just Japanese region is available. Could you please support the US and Chinese region like go-kintone or cli-kintone ?

Here is my idea.

# account.py
class Account(object):
    def __init__(self, domain,
                 login_id="", login_password="",
                 basic_id="", basic_password=""):
        self.login_id = login_id
        self.login_password = login_password
        self.basic_id = basic_id
        self.basic_password = basic_password
        if '.' in self.domain:
          self.domain = domain
        else:
          self.domain = "{0}.cybozu.com".format(domain)

    def to_header(self, api_token="", with_content_type=True):
        header = {}
        header["Host"] = "{0}:443".format(self.domain)

# application.py
class Application(BaseAPI):
    API_ROOT = "https://{0}/k/v1/{1}"

# any other...

Thanks.

icoxfog417 commented 6 years ago

Thank you for the reporting issue. I don't know cybozu.com is only Japan!

There is an issue related to the region (language setting?) (#27). So I think to get the region information (ja, cn, en?) as an argument will be suitable for Account.

What do you think about this?

will-yama commented 6 years ago

I will share what I know about the language settings in kintone.

The language settings of the API is the same as the language settings of the user who authenticated the API. By default, on all regions, all user's Language settings are set to "Use Web Browser settings". If you were to call an API using that user from a server, the server will not know what language to call the API in. In this case, it looks at the domain's "Localization" language settings (the system locale). This is information is saved within the Administrator settings. The API will call the API in that language automatically.

Different regions have different "Localization" language settings set on them, by default: cybozu.com (JP region) -> English kintone.com (US region) -> Japanese cybozu.cn (CN region) -> Simplified Chinese

[Case 1.] US region user has their language settings set as "Use Web Browser settings" -> API from server will be called in English

[Case 2.] US region user has their language settings set as "Japanese" -> API from server will be called in Japanese

[Case 3.] JP region user has their language settings set as "Use Web Browser settings" -> API from server will be called in Japanese

[Case 4.] CN region user has their language settings set as "English" -> API from server will be called in English

There are many things to consider when calling APIs and handling languages. I have summed up some examples in kintone here https://qiita.com/will-yama/items/662de9d8cb8f42343ef1

I think yamaryu0508's suggestion is a good place to start off. If won't cover every issue, but I think we can fix other issues as we go on.

icoxfog417 commented 6 years ago

@will-yama Thank you for letting me know. It seems to be difficult to determine the language setting explicitly. So I'll implement the simple @yamaryu0508 solution.

will-yama commented 6 years ago

@icoxfog417 Thank you! I will plan to play around with the SDK on a US region environment :)