Skip to content

Commit

Permalink
release v1.1.5 collection
Browse files Browse the repository at this point in the history
  • Loading branch information
fareskato committed Mar 3, 2024
1 parent 59ed158 commit d94802b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions collections.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fkshopify

import (
"fmt"
"net/http"

"github.com/fareskato/fkshopify/fkhttp"
)

type shopifyCollection struct {
ShopifyID int `json:"id"`
Title string `json:"title"`
ProductsCount int `json:"products_count"`
}

type shopifyCollectionResponse struct {
Collection shopifyCollection `json:"collection"`
}

func (s Shopify) GetShopifyCollection(id string) (*shopifyCollection, error) {
var colRes shopifyCollectionResponse
colUrl := fmt.Sprintf("%s/collections/%s.json", s.InitStoreUrl(), id)
colres, res, err := fkhttp.HttpGet(colRes, colUrl)
if err != nil {
return nil, err
}
if res.StatusCode != http.StatusOK {
return nil, err
}
return &colres.Collection, nil
}

0 comments on commit d94802b

Please sign in to comment.