Giter Site home page Giter Site logo

delibird's Introduction

Delibird

License GoDoc Go Report Card Coverage Status Build Status

Deploy

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

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

  1. Fork it ( https://github.com/purpleworks/delibird/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Released under the MIT License.

delibird's People

Contributors

difro avatar kucuny avatar subicura avatar tsyoum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delibird's Issues

Only CJ courier unit test is failed.

Hi contributors.

I just forked your awesome application, but I met "failure" message.
Only CJ test is failed although Travis CI indicates "PASSING".
Is there any dependency of system? First time I tried to go test, gcc is needed.

$ go test -v -coverprofile=couriers.coverprofile ./couriers
=== RUN TestCJCourier

CJ test
Invalid tracking number test .
Start courier test x
Complete courier test x

Failures:

  • C:/workspace/golang/src/github.com/purpleworks/delibird/couriers/cj_test.go
    Line 41:
    Expected: '51'
    Actual: '0'
    (Should be equal)
  • C:/workspace/golang/src/github.com/purpleworks/delibird/couriers/cj_test.go
    Line 51:
    Expected: '91'
    Actual: '0'
    (Should be equal)

3 total assertions

--- FAIL: TestCJCourier (0.10s)
=== RUN TestCourier

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.