Skip to content

UnOfficial Raja Ongkir SDK for Go Programming Language

License

Notifications You must be signed in to change notification settings

Bhinneka/go-rajaongkir

Repository files navigation

UnOfficial Raja Ongkir SDK for Go Programming Language

Raja Ongkir's Website (https://rajaongkir.com)

Build Status License

Bhinneka 💙 Golang

Install

go get github.com/Bhinneka/go-rajaongkir

Simple Usage

  • Get Cost Data

    package main
    
    import (
    	"fmt"
    	"time"
    
    	"github.com/Bhinneka/go-rajaongkir"
    )
    
    func main() {
    
      // Raja Ongkir Constructor, simply call ro.New
      // Parameter 1: "Raja Ongkir API KEY"
      // Parameter 2: HTTP Request Timeout
    	raja := ro.New("your-api-key", 10*time.Second)
      //by default after construct, raja ongkir used Starter Env(Free account)
      //to change Env, simply just change the env
      //raja.Env = ro.Basic for basic account
      //or raja.Env = ro.Pro for pro account
    
      // Parameter 1: City Origin ID
      // Parameter 2: City Destination ID
      // Parameter 3: Item's Weight
      // Parameter 4: Courier's Name
    	q := ro.QueryRequest{Origin: "501", Destination: "114", Weight: 1700, Courier: "tiki"}
    	result := raja.GetCost(q)
    
    	if result.Error != nil {
    		fmt.Println(result.Error.Error())
    	}
    
    	cost, ok := result.Result.(ro.Cost)
    	if !ok {
    		fmt.Println("Result is not Cost")
    	}
    
    	fmt.Println(cost)
    }

TODO

  • Create Service for Starter(Free Account)
  • Create Service for Basic and Pro Raja Ongkir Account
  • Create Unit Testing
  • Integration with Travis CI

Authors

Releases

No releases published

Packages

No packages published

Languages