Skip to content

Unofficially kenall (ケンオール) client written by Go

License

Notifications You must be signed in to change notification settings

osamingo/go-kenall

Repository files navigation

go-kenall

CI codecov Go Report Card Go Reference GitHub license

About

Unofficially kenall (ケンオール) client written by Go.

Install

$ go get github.com/osamingo/go-kenall/v2@latest

APIs supported by this library

Usage

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/osamingo/go-kenall/v2"
)

func main() {
	cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN"))
	if err != nil {
		log.Fatal(err)
	}

	resAddr, err := cli.GetAddress(context.Background(), "1000001")
	if err != nil {
		log.Fatal(err)
	}
	addr := resAddr.Addresses[0]
	fmt.Println(addr.Prefecture, addr.City, addr.Town)
	// Output: 東京都 千代田区 千代田

	resCity, err := cli.GetCity(context.Background(), "13")
	if err != nil {
		log.Fatal(err)
	}
	city := resCity.Cities[0]
	fmt.Println(city.Prefecture, city.City)
	// Output: 東京都 千代田区

	res, err := cli.GetCorporation(context.Background(), "7000012050002")
	if err != nil {
		log.Fatal(err)
	}
	corp := res.Corporation
	fmt.Println(corp.PrefectureName, corp.CityName) 
	// Output: 東京都 千代田区
}

Articles

License

Released under the MIT License.