Delibird
Delibird is a shipment tracking library for Golang.
Delibird๋ ํ๋ฐฐ์ฌ์ ๋ฐฐ์ก์กฐํ ํ์ด์ง๋ฅผ ํ์ฑํ์ฌ ์ ํํ๋ ํํ๋ก ๋ฐ๊ฟ์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋๋ค.
Courier List
์ง์ํ๋ ํ๋ฐฐ์ฌ ๋ชฉ๋ก์ ๋๋ค.
Name | Contributor |
---|---|
Korean Post / ์ฐ์ฒด๊ตญํ๋ฐฐ | @purpleworks |
CJ KoreaExpress / CJ๋ํํต์ด | @purpleworks |
KG Logis / KG๋ก์ง์ค | @serendip811 |
Logen / ๋ก์ ํ๋ฐฐ | @purpleworks |
Installation
$ go get github.com/purpleworks/delibird
Usage
Code
package package_name
import "github.com/purpleworks/delibird"
import "github.com/purpleworks/delibird/couriers"
func GetCjTracking(n string) {
courier, _ := couriers.New("CJ")
data, _ := courier.Parse(n)
fmt.Println("%s -> %s : %s", data.Sender, data.Receiver, data.StatusText)
}
API Server
Build and run API server:
$ ./build
$ bin/delibird_server
or
$ PORT=8080 bin/delibird_server
Server Configuration
- ENVIRONMENT: development or production(optimize json output) (default development)
- PORT: server port (default 9000)
- ENABLE_CORS: enable cors if true (default false)
Request URL
- local: http://localhost:9000/tracking/{COURIER_CODE}/{TRACKING_NUMBER}
- try now: https://delibird.herokuapp.com/tracking/{COURIER_CODE}/{TRACKING_NUMBER}
- swagger ui: http://petstore.swagger.io
Request Parameters
COURIER_CODE
Code | Name |
---|---|
KPOST | Korean Post / ์ฐ์ฒด๊ตญํ๋ฐฐ |
CJ | CJ Korea express / CJ๋ํํต์ด |
KG | KG Logis / KG๋ก์ง์ค |
LOGEN | Logen / ๋ก์ ํ๋ฐฐ |
Response
Key | Description | Example |
---|---|---|
TrackingNumber | ์ก์ฅ๋ฒํธ | 1234567890123 |
CompanyCode | ํ๋ฐฐ์ฌ์ฝ๋ | KPOST, CJ, ... |
CompanyName | ํ๋ฐฐ์ฌ๋ช | CJ๋ํํต์ด |
Sender | ๋ณด๋ด๋๋ถ | ํ*๋ผ |
Receiver | ๋ฐ๋๋ถ | ํ *ํธ |
Signer | ์๋ น์ธ | ๋ณธ์ธ |
StatusCode | ์ํ์ฝ๋ | ํ๋จ ์ฐธ๊ณ |
StatusText | ์ํ | ๋ฐฐ์ก์๋ฃ |
History | ๋ฐฐ์ก ์ํฉ(array) | ํ๋จ ์ฐธ๊ณ |
Status Code
-1
(UnknownStatus) - ์์์์1
(Pending) - ์ ์ ๋๊ธฐ2
(Ready) - ์์ ์ ์ ์ (SM์ ๊ณ )3
(PickupComplete) - ์งํ์ฒ๋ฆฌ4
(Loading) - ๊ฐ์ ์์ฐจ / ๋ฌผ๊ฑด ์ค์ / ์ค๊ฐ ์งํ์ง ์ถ๋ฐ5
(Unloading) - ๊ฐ์ ํ์ฐจ / ๋ถ๋ฅ / ์ค๊ฐ ์งํ์ง ๋์ฐฉ51
(DeleveryStart) - ๋ฐฐ์ก์ถ๋ฐ91
(DeleveryComplete) - ๋ฐฐ์ก์๋ฃ99
(DoNotDelevery) - ๋ฏธ๋ฐฐ๋ฌ
History
Area
- ์์นTel
- ์ ํ๋ฒํธDate
- ์๊ฐ(timestamp)DateText
- ์๊ฐ(YYYY-MM-DD hh:mm)StatusCode
- ์ํ์ฝ๋StatusText
- ์ํ
Response example
{
"tracking_number": "xxxxxx",
"company_code": "CJ",
"company_name": "CJ๋ํํต์ด",
"sender": "ํ*๋ผ",
"receiver": "ํ
*ํธ",
"signer": "๊ฒฝ๋น์ค",
"status_code": 91,
"status_text": "๋ฐฐ๋ฌ์๋ฃ",
"history": [
{
"area": "์กํB์ง์(์ฐจ์๋ฌธ)",
"tel": "02-6937-6842",
"date": 1460013885,
"date_text": "2016-04-07 16:24",
"status_code": 3,
"status_text": "์งํ์ฒ๋ฆฌ"
},
{
"area": "์กํB์ง์(์ฐจ์๋ฌธ)",
"tel": "02-6937-6842",
"date": 1460013885,
"date_text": "2016-04-07 16:24",
"status_code": 2,
"status_text": "SM์
๊ณ "
},
{
"area": "์กํA",
"tel": "02-6937-6836",
"date": 1460026859,
"date_text": "2016-04-07 20:00",
"status_code": 4,
"status_text": "๊ฐ์ ์์ฐจ"
},
{
"area": "์ฉ์ธHUB",
"date": 1460050614,
"date_text": "2016-04-08 02:36",
"status_code": 5,
"status_text": "๊ฐ์ ํ์ฐจ"
},
{
"area": "์ฉ์ธHUB",
"date": 1460050669,
"date_text": "2016-04-08 02:37",
"status_code": 5,
"status_text": "๊ฐ์ ํ์ฐจ"
},
{
"area": "์ฉ์ธHUB",
"date": 1460050694,
"date_text": "2016-04-08 02:38",
"status_code": 4,
"status_text": "๊ฐ์ ์์ฐจ"
},
{
"area": "์ฉ์ธHUB",
"date": 1460050750,
"date_text": "2016-04-08 02:39",
"status_code": 4,
"status_text": "๊ฐ์ ์์ฐจ"
},
{
"area": "๋
ธ์",
"tel": "02-2129-1278",
"date": 1460067554,
"date_text": "2016-04-08 07:19",
"status_code": 5,
"status_text": "๊ฐ์ ํ์ฐจ"
},
{
"area": "์์ธ์๋
ธ์",
"tel": "070-4191-7643",
"date": 1460068287,
"date_text": "2016-04-08 07:31",
"status_code": 51,
"status_text": "๋ฐฐ๋ฌ์ถ๋ฐ"
},
{
"area": "์์ธ์๋
ธ์",
"tel": "070-4191-7643",
"date": 1460098645,
"date_text": "2016-04-08 15:57",
"status_code": 91,
"status_text": "๋ฐฐ๋ฌ์๋ฃ"
}
]
}
Docker
docker build
$ DOCKER_BUILD=1 ./build
$ docker build -t purpleworks/delibird .
docker run
$ docker run --rm \
-p 9000:9000 \
-e ENVIRONMENT=production \
-e ENABLE_CORS=ture \
purpleworks/delibird
Test
Test with goconvey
$ go get github.com/smartystreets/goconvey
In the browser
$ goconvey
In the terminal
$ go test && go test ./server && go test ./couriers
$ go test -v && go test -v ./server && go test ./couriers # include the story
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/purpleworks/delibird
- Fork it ( https://github.com/purpleworks/delibird/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
License
Released under the MIT License.