Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toyokumo/kintone-client
A kintone client for Clojure and ClojureScript
https://github.com/toyokumo/kintone-client
clojure clojurescript kintone kintone-api
Last synced: 2 months ago
JSON representation
A kintone client for Clojure and ClojureScript
- Host: GitHub
- URL: https://github.com/toyokumo/kintone-client
- Owner: toyokumo
- License: apache-2.0
- Created: 2019-08-22T02:20:54.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-21T07:22:20.000Z (4 months ago)
- Last Synced: 2024-11-28T12:35:30.219Z (2 months ago)
- Topics: clojure, clojurescript, kintone, kintone-api
- Language: Clojure
- Homepage:
- Size: 230 KB
- Stars: 6
- Watchers: 7
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# kintone-client
A [kintone](https://www.kintone.com) client for Clojure and ClojureScript.
[![CircleCI](https://circleci.com/gh/toyokumo/kintone-client.svg?style=svg)](https://circleci.com/gh/toyokumo/kintone-client)
[![cljdoc badge](https://cljdoc.org/badge/toyokumo/kintone-client)](https://cljdoc.org/d/toyokumo/kintone-client/CURRENT)
[![Clojars Project](https://img.shields.io/clojars/v/toyokumo/kintone-client.svg)](https://clojars.org/toyokumo/kintone-client)## Overview
The SDK provides an easy way to use kintone API from Clojure or ClojureScript.
Every API run asynchronously to use [clj-http](https://github.com/dakrone/clj-http) for Clojure
, [cljs-ajax](https://github.com/JulianBirch/cljs-ajax) for ClojureScript and
[core.async](https://github.com/clojure/core.async).
They return a channel of core.async.- `kintone-client.authentication` : Make Auth object.
- `kintone-client.connection` : Make connection object.
- `kintone-client.types` : Type definitions such as response object.
- `kintone-client.record` : kintone REST Record API.
- `kintone-client.app` : kintone REST App API.
- `kintone-client.user`: cybozu.com User API. (API Tokens cannot be used with user API.)
- `kintone-client.url`: kintone url utilities.## Usage
Follow bellow the steps.
1. Make `Auth` object
1. Make `Connection` object
1. Call API with `Connection` object### Make `Auth` object
`Auth` object is used in order to make `Connection` object.
This step is not necessary in case that you run JavaScript(ClojureScript)
on kintone as customize script for kintone app or portal.```clojure
(require '[kintone-client.authentication :as auth]);; API token
(auth/new-auth {:api-token "xyz..."});; Basic authentication and password authentication
(auth/new-auth {:basic {:username "basic-username" :password "basic-password"}
:password {:username "login-name" :password "login-password"}});; Basic authentication, password authentication and API token
;; In this case, the API token is going to be ignored,
;; and the basic authentication and the password authentication is going to be used.
(auth/new-auth {:basic {:username "basic-username" :password "basic-password"}
:password {:username "login-name" :password "login-password"}
:api-token "xyz..."})
```### Make `Connection` object
```clojure
(require '[kintone-client.authentication :as auth])
(require '[kintone-client.connection :as conn]);; Auth and domain
(conn/new-connection {:auth (auth/new-auth {:api-token "xyz.."})
:domain "sample.kintone.com"});; To guest space
(conn/new-connection {:auth (auth/new-auth {:api-token "xyz.."})
:domain "sample.kintone.com"
:guest-space-id 1});; It is only accepted on ClojureScript that there is no auth.
(conn/new-connection {:domain "sample.cybozu.com"})
```### Call API
You should use `Connection` object as the first argument on every API call.
```clojure
(require '[kintone-client.authentication :as auth])
(require '[kintone-client.connection :as conn])
(require '[kintone-client.record :as record]);; Clojure
(require '[clojure.core.async :refer [ {:record {:$id {:type "__ID__", :value "1"} ...}
;; fail => {:status 404
;; :status-text "Not Found"
;; :failure :error
;; :response {:code "GAIA_RE01" ...}};; ClojureScript
(require '[cljs.core.async :refer [ "https://hoge.cybozu.com"
(parse-base-url "https://hoge.kintone.com/k/12")
;; => {:domain "kintone.com", :subdomain "hoge"}
(valid-base-url? "https://hoge.cybozu.com/k/12")
;; => true
(extract-app-url "https://hoge.cybozu.com/k/12/show")
;; => "https://hoge.cybozu.com/k/12"
(parse-app-url "https://foo.s.cybozu.com/k/guest/11/1")
;; => {:domain "cybozu.com", :subdomain "foo", :guest-space-id "11", :app-id "1"}
(valid-app-url? "https://hoge.cybozu.com")
;; => true
```For more information, See [API documents](https://cljdoc.org/d/toyokumo/kintone-client/CURRENT), `test/`, and `dev/test.clj`.
## dev/test.clj
These tests actually interact with a kintone app and space (not included in CI).
These are good examples of the usage of kintone-client.### How to run
- import dev-resources/kintone-clj-test.zip
- create kintone space (the tests create many apps in this space)
- fill dev-resources/config.edn
```edn
{:auth {:basic {:username "username" :password "password"}
:api-token "api-token"}
:domain "domain"
:app 9999
:space 99}
```
- try tests## Note
- kintone-client doesn't convert a camelCase keyword (in kintone REST api response map) into kebab-case.
It costs too much to do so (response map can be so complicated, and keyword can be non-ascii character).## License
```
Copyright 2019 TOYOKUMO,Inc.Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```For src/kintone_client/url.cljc and test/kintone_client/url_test.cljc:
```
MIT LicenseCopyright (c) 2017 ayato-p
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```