Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start defining structs and wrappers for Shopify APIs #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified LICENSE
100644 → 100755
Empty file.
72 changes: 39 additions & 33 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,61 @@ Installation
go get github.com/rapito/go-shopify
```

How-to-use
Dependencies
------------
```
go get github.com/parnurzeal/gorequest
```

Test dependencies
------------
```
go get github.com/bitly/go-simplejson
go get github.com/bmizerany/assert
```

Use it
----------


- Get Requests
- GET Requests

```
import "fmt"
import "github.com/rapito/go-shopify/shopify"
...

shop := shopify.New(storeDomain,apiKey,pass)
result, _ := shop.Get("products")

fmt.Println(string(result))
```go
import "fmt"
import "github.com/rapito/go-shopify/shopify"

shop := shopify.New(storeDomain,apiKey,pass)
result, _ := shop.Get("products")

fmt.Println(string(result))
```

- Check out the *examples* folder for simple usage.
- Read some of the tests at *shopify_test.go* for complete CRUD examples.

- There are some built-in wrappers than you can use, you are welcome to add new ones:
- `GetOrders()`
- `GetOrder(orderID)`
- `GetOrderTransactions(orderID)`
- `GetOrderTransactionsCount(orderID)`
- `GetOrdersCount()`
- `GetProducts()`
- `GetProduct(productID)`
- `GetProductImages(productID)`
- `GetProductVariants(productID)`

Contribution
------------

- You may fork this library and modify it as you please.
- You can make a pull request and I will be happy to check it out and merge it.
- If you find a bug, create an issue and I will do my best to fix it (someday).
- If you find a bug, create an issue and I will do my best to fix it (someday).

Original Work
-------------

While I was looking for something cool to do with this new language im learning
(Go, obviously), I ran into [hammond-bones'](https://github.com/hammond-bones/) **go-shopify**
library. Which inspired me to start creating this one.
While I was looking for something cool to do with this new language im learning
(Go, obviously), I ran into [hammond-bones'](https://github.com/hammond-bones/) **go-shopify**
library. Which inspired me to start creating this one.

- Fork it at: [go-shopify](https://github.com/hammond-bones/go-shopify)

Links
-----

While I was on my *go-trip* to create this api, I found some awesome libs which made
my life easier.
Check them out, hopefully they'll do the same for you:

- http://github.com/parnurzeal/gorequest
- http://github.com/bmizerany/assert
- http://github.com/avelino/awesome-go

Other APIs
----------

- http://github.com/rapito/go-spotify

17 changes: 17 additions & 0 deletions shopify/discountCode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package shopify

import (
"fmt"
)

//CreateDiscountCode creates a discount code
func (shop *Shopify) CreateDiscountCode(priceRule string, discountCode DiscountCode) (*DiscountCode, []error) {
var discountCodeResponse DiscountCodeResponse
response, errors := shop.Post(fmt.Sprintf("price_rules/%v/discount_codes", priceRule), map[string]interface{}{
"discount_code": discountCode,
})
if err := unmarshal(response, errors, &discountCodeResponse); len(err) > 0 {
return nil, err
}
return &discountCodeResponse.DiscountCode, nil
}
Loading