Go wrapper for CodesWholesale API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
account.go
codeswholesale.go
codeswholesale_test.go
common.go
order.go
product.go
util.go

README.md

Go CodesWholesale API

Build Status GoDoc

codeswholesale is a Go client library for the CodesWholesale API.

Start using it

  1. Download and install it:

    $ go get github.com/MarinX/codeswholesale
  2. Import it in your code:

    import "github.com/MarinX/codeswholesale"
  3. (Optional) Run test

    $ go test -v

API Examples

Get Account

	cw := codeswholesale.New("ClientID", "ClientSecret", codeswholesale.MODE_SANDBOX)

	account, err := cw.GetAccount()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("%+v", account)

Get all products

	cw := codeswholesale.New("ClientID", "ClientSecret", codeswholesale.MODE_SANDBOX)

	products, err := cw.GetProducts()
	if err != nil {
		fmt.Println(err)
		return
	}

	for _, val := range products {
		fmt.Printf("%+v\n", val)
	}

Get Single Product

	cw := codeswholesale.New("ClientID", "ClientSecret", codeswholesale.MODE_SANDBOX)

	product, err := cw.GetProductByID("product-cwid")
	if err != nil {
		fmt.Println(err)
		return
	}
	
	fmt.Printf("%+v\n", product)

Order single code

	cw := codeswholesale.New("ClientID", "ClientSecret", codeswholesale.MODE_SANDBOX)

	order, err := cw.SingleCodeOrder("product-cwid")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Printf("%+v\n", order)

Multiple code order

	cw := codeswholesale.New("ClientID", "ClientSecret", codeswholesale.MODE_SANDBOX)

	orders, err := cw.MultipleCodeOrder("product-cwid",5)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("Order ID %s", orders.OrderID)

	for _, val := range orders.Items {
		fmt.Printf("%+v\n", val)
	}

License

This library is under the MIT License