Skip to content

Commit

Permalink
int to int64 type conversion for ID fields (#46)
Browse files Browse the repository at this point in the history
* Convert internal ids to int64 from straight int
  • Loading branch information
dougyss4 authored and rickywiens committed Mar 28, 2019
1 parent d4d43e9 commit 480fb25
Show file tree
Hide file tree
Showing 49 changed files with 307 additions and 306 deletions.
8 changes: 4 additions & 4 deletions applicationcharge.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const applicationChargesBasePath = "admin/application_charges"
// See https://help.shopify.com/api/reference/billing/applicationcharge
type ApplicationChargeService interface {
Create(ApplicationCharge) (*ApplicationCharge, error)
Get(int, interface{}) (*ApplicationCharge, error)
Get(int64, interface{}) (*ApplicationCharge, error)
List(interface{}) ([]ApplicationCharge, error)
Activate(ApplicationCharge) (*ApplicationCharge, error)
}
Expand All @@ -24,9 +24,9 @@ type ApplicationChargeServiceOp struct {
}

type ApplicationCharge struct {
ID int `json:"id"`
ID int64 `json:"id"`
Name string `json:"name"`
APIClientID int `json:"api_client_id"`
APIClientID int64 `json:"api_client_id"`
Price *decimal.Decimal `json:"price"`
Status string `json:"status"`
ReturnURL string `json:"return_url"`
Expand Down Expand Up @@ -58,7 +58,7 @@ func (a ApplicationChargeServiceOp) Create(charge ApplicationCharge) (*Applicati
}

// Get gets individual application charge.
func (a ApplicationChargeServiceOp) Get(chargeID int, options interface{}) (*ApplicationCharge, error) {
func (a ApplicationChargeServiceOp) Get(chargeID int64, options interface{}) (*ApplicationCharge, error) {
path := fmt.Sprintf("%s/%d.json", applicationChargesBasePath, chargeID)
resource := &ApplicationChargeResource{}
return resource.Charge, a.client.Get(path, resource, options)
Expand Down
4 changes: 2 additions & 2 deletions applicationcharge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func applicationChargeTests(t *testing.T, charge ApplicationCharge) {
expected interface{}
actual interface{}
}{
{"ID", 1017262355, charge.ID},
{"ID", int64(1017262355), charge.ID},
{"Name", "Super Duper Expensive action", charge.Name},
{"APIClientID", 755357713, charge.APIClientID},
{"APIClientID", int64(755357713), charge.APIClientID},
{"Price", decimal.NewFromFloat(100.00).String(), charge.Price.String()},
{"Status", "pending", charge.Status},
{"ReturnURL", "http://super-duper.shopifyapps.com/", charge.ReturnURL},
Expand Down
20 changes: 10 additions & 10 deletions asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const assetsBasePath = "admin/themes"
// of the Shopify API.
// See: https://help.shopify.com/api/reference/asset
type AssetService interface {
List(int, interface{}) ([]Asset, error)
Get(int, string) (*Asset, error)
Update(int, Asset) (*Asset, error)
Delete(int, string) error
List(int64, interface{}) ([]Asset, error)
Get(int64, string) (*Asset, error)
Update(int64, Asset) (*Asset, error)
Delete(int64, string) error
}

// AssetServiceOp handles communication with the asset related methods of
Expand All @@ -32,7 +32,7 @@ type Asset struct {
Size int `json:"size"`
SourceKey string `json:"source_key"`
Src string `json:"src"`
ThemeID int `json:"theme_id"`
ThemeID int64 `json:"theme_id"`
Value string `json:"value"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Expand All @@ -50,19 +50,19 @@ type AssetsResource struct {

type assetGetOptions struct {
Key string `url:"asset[key]"`
ThemeID int `url:"theme_id"`
ThemeID int64 `url:"theme_id"`
}

// List the metadata for all assets in the given theme
func (s *AssetServiceOp) List(themeID int, options interface{}) ([]Asset, error) {
func (s *AssetServiceOp) List(themeID int64, options interface{}) ([]Asset, error) {
path := fmt.Sprintf("%s/%d/assets.json", assetsBasePath, themeID)
resource := new(AssetsResource)
err := s.client.Get(path, resource, options)
return resource.Assets, err
}

// Get an asset by key from the given theme
func (s *AssetServiceOp) Get(themeID int, key string) (*Asset, error) {
func (s *AssetServiceOp) Get(themeID int64, key string) (*Asset, error) {
path := fmt.Sprintf("%s/%d/assets.json", assetsBasePath, themeID)
options := assetGetOptions{
Key: key,
Expand All @@ -74,7 +74,7 @@ func (s *AssetServiceOp) Get(themeID int, key string) (*Asset, error) {
}

// Update an asset
func (s *AssetServiceOp) Update(themeID int, asset Asset) (*Asset, error) {
func (s *AssetServiceOp) Update(themeID int64, asset Asset) (*Asset, error) {
path := fmt.Sprintf("%s/%d/assets.json", assetsBasePath, themeID)
wrappedData := AssetResource{Asset: &asset}
resource := new(AssetResource)
Expand All @@ -83,7 +83,7 @@ func (s *AssetServiceOp) Update(themeID int, asset Asset) (*Asset, error) {
}

// Delete an asset
func (s *AssetServiceOp) Delete(themeID int, key string) error {
func (s *AssetServiceOp) Delete(themeID int64, key string) error {
path := fmt.Sprintf("%s/%d/assets.json?asset[key]=%s", assetsBasePath, themeID, key)
return s.client.Delete(path)
}
10 changes: 5 additions & 5 deletions blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const blogsBasePath = "admin/blogs"
type BlogService interface {
List(interface{}) ([]Blog, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*Blog, error)
Get(int64, interface{}) (*Blog, error)
Create(Blog) (*Blog, error)
Update(Blog) (*Blog, error)
Delete(int) error
Delete(int64) error
}

// BlogServiceOp handles communication with the blog related methods of
Expand All @@ -27,7 +27,7 @@ type BlogServiceOp struct {

// Blog represents a Shopify blog
type Blog struct {
ID int `json:"id"`
ID int64 `json:"id"`
Title string `json:"title"`
Commentable string `json:"commentable"`
Feedburner string `json:"feedburner"`
Expand Down Expand Up @@ -65,7 +65,7 @@ func (s *BlogServiceOp) Count(options interface{}) (int, error) {
}

// Get single blog
func (s *BlogServiceOp) Get(blogId int, options interface{}) (*Blog, error) {
func (s *BlogServiceOp) Get(blogId int64, options interface{}) (*Blog, error) {
path := fmt.Sprintf("%s/%d.json", blogsBasePath, blogId)
resource := new(BlogResource)
err := s.client.Get(path, resource, options)
Expand All @@ -91,6 +91,6 @@ func (s *BlogServiceOp) Update(blog Blog) (*Blog, error) {
}

// Delete an blog
func (s *BlogServiceOp) Delete(blogId int) error {
func (s *BlogServiceOp) Delete(blogId int64) error {
return s.client.Delete(fmt.Sprintf("%s/%d.json", blogsBasePath, blogId))
}
4 changes: 2 additions & 2 deletions blog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestBlogCreate(t *testing.T) {
t.Errorf("Blog.Create returned error: %v", err)
}

expectedInt := 241253187
expectedInt := int64(241253187)
if returnedBlog.ID != expectedInt {
t.Errorf("Blog.ID returned %+v, expected %+v", returnedBlog.ID, expectedInt)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestBlogUpdate(t *testing.T) {
t.Errorf("Blog.Update returned error: %v", err)
}

expectedInt := 241253187
expectedInt := int64(241253187)
if returnedBlog.ID != expectedInt {
t.Errorf("Blog.ID returned %+v, expected %+v", returnedBlog.ID, expectedInt)
}
Expand Down
6 changes: 3 additions & 3 deletions collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ type CollectServiceOp struct {

// Collect represents a Shopify collect
type Collect struct {
ID int `json:"id,omitempty"`
CollectionID int `json:"collection_id,omitempty"`
ProductID int `json:"product_id,omitempty"`
ID int64 `json:"id,omitempty"`
CollectionID int64 `json:"collection_id,omitempty"`
ProductID int64 `json:"product_id,omitempty"`
Featured bool `json:"featured,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
Expand Down
22 changes: 11 additions & 11 deletions customcollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const customCollectionsResourceName = "collections"
type CustomCollectionService interface {
List(interface{}) ([]CustomCollection, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*CustomCollection, error)
Get(int64, interface{}) (*CustomCollection, error)
Create(CustomCollection) (*CustomCollection, error)
Update(CustomCollection) (*CustomCollection, error)
Delete(int) error
Delete(int64) error

// MetafieldsService used for CustomCollection resource to communicate with Metafields resource
MetafieldsService
Expand All @@ -31,7 +31,7 @@ type CustomCollectionServiceOp struct {

// CustomCollection represents a Shopify custom collection.
type CustomCollection struct {
ID int `json:"id"`
ID int64 `json:"id"`
Handle string `json:"handle"`
Title string `json:"title"`
UpdatedAt *time.Time `json:"updated_at"`
Expand Down Expand Up @@ -70,7 +70,7 @@ func (s *CustomCollectionServiceOp) Count(options interface{}) (int, error) {
}

// Get individual custom collection
func (s *CustomCollectionServiceOp) Get(collectionID int, options interface{}) (*CustomCollection, error) {
func (s *CustomCollectionServiceOp) Get(collectionID int64, options interface{}) (*CustomCollection, error) {
path := fmt.Sprintf("%s/%d.json", customCollectionsBasePath, collectionID)
resource := new(CustomCollectionResource)
err := s.client.Get(path, resource, options)
Expand All @@ -97,42 +97,42 @@ func (s *CustomCollectionServiceOp) Update(collection CustomCollection) (*Custom
}

// Delete an existing custom collection.
func (s *CustomCollectionServiceOp) Delete(collectionID int) error {
func (s *CustomCollectionServiceOp) Delete(collectionID int64) error {
return s.client.Delete(fmt.Sprintf("%s/%d.json", customCollectionsBasePath, collectionID))
}

// List metafields for a custom collection
func (s *CustomCollectionServiceOp) ListMetafields(customCollectionID int, options interface{}) ([]Metafield, error) {
func (s *CustomCollectionServiceOp) ListMetafields(customCollectionID int64, options interface{}) ([]Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customCollectionsResourceName, resourceID: customCollectionID}
return metafieldService.List(options)
}

// Count metafields for a custom collection
func (s *CustomCollectionServiceOp) CountMetafields(customCollectionID int, options interface{}) (int, error) {
func (s *CustomCollectionServiceOp) CountMetafields(customCollectionID int64, options interface{}) (int, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customCollectionsResourceName, resourceID: customCollectionID}
return metafieldService.Count(options)
}

// Get individual metafield for a custom collection
func (s *CustomCollectionServiceOp) GetMetafield(customCollectionID int, metafieldID int, options interface{}) (*Metafield, error) {
func (s *CustomCollectionServiceOp) GetMetafield(customCollectionID int64, metafieldID int64, options interface{}) (*Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customCollectionsResourceName, resourceID: customCollectionID}
return metafieldService.Get(metafieldID, options)
}

// Create a new metafield for a custom collection
func (s *CustomCollectionServiceOp) CreateMetafield(customCollectionID int, metafield Metafield) (*Metafield, error) {
func (s *CustomCollectionServiceOp) CreateMetafield(customCollectionID int64, metafield Metafield) (*Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customCollectionsResourceName, resourceID: customCollectionID}
return metafieldService.Create(metafield)
}

// Update an existing metafield for a custom collection
func (s *CustomCollectionServiceOp) UpdateMetafield(customCollectionID int, metafield Metafield) (*Metafield, error) {
func (s *CustomCollectionServiceOp) UpdateMetafield(customCollectionID int64, metafield Metafield) (*Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customCollectionsResourceName, resourceID: customCollectionID}
return metafieldService.Update(metafield)
}

// // Delete an existing metafield for a custom collection
func (s *CustomCollectionServiceOp) DeleteMetafield(customCollectionID int, metafieldID int) error {
func (s *CustomCollectionServiceOp) DeleteMetafield(customCollectionID int64, metafieldID int64) error {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customCollectionsResourceName, resourceID: customCollectionID}
return metafieldService.Delete(metafieldID)
}
2 changes: 1 addition & 1 deletion customcollection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func customCollectionTests(t *testing.T, collection CustomCollection) {
expected interface{}
actual interface{}
}{
{"ID", 30497275952, collection.ID},
{"ID", int64(30497275952), collection.ID},
{"Handle", "macbooks", collection.Handle},
{"Title", "Macbooks", collection.Title},
{"BodyHTML", "Macbook Body", collection.BodyHTML},
Expand Down
28 changes: 14 additions & 14 deletions customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const customersResourceName = "customers"
type CustomerService interface {
List(interface{}) ([]Customer, error)
Count(interface{}) (int, error)
Get(int, interface{}) (*Customer, error)
Get(int64, interface{}) (*Customer, error)
Search(interface{}) ([]Customer, error)
Create(Customer) (*Customer, error)
Update(Customer) (*Customer, error)
Delete(int) error
ListOrders(int, interface{}) ([]Order, error)
Delete(int64) error
ListOrders(int64, interface{}) ([]Order, error)
ListTags(interface{}) ([]string, error)

// MetafieldsService used for Customer resource to communicate with Metafields resource
Expand All @@ -36,7 +36,7 @@ type CustomerServiceOp struct {

// Customer represents a Shopify customer
type Customer struct {
ID int `json:"id,omitempty"`
ID int64 `json:"id,omitempty"`
Email string `json:"email,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Expand All @@ -49,7 +49,7 @@ type Customer struct {
TotalSpent *decimal.Decimal `json:"total_spent,omitempty"`
Phone string `json:"phone,omitempty"`
Tags string `json:"tags,omitempty"`
LastOrderId int `json:"last_order_id,omitempty"`
LastOrderId int64 `json:"last_order_id,omitempty"`
LastOrderName string `json:"last_order_name,omitempty"`
AcceptsMarketing bool `json:"accepts_marketing,omitempty"`
DefaultAddress *CustomerAddress `json:"default_address,omitempty"`
Expand Down Expand Up @@ -98,7 +98,7 @@ func (s *CustomerServiceOp) Count(options interface{}) (int, error) {
}

// Get customer
func (s *CustomerServiceOp) Get(customerID int, options interface{}) (*Customer, error) {
func (s *CustomerServiceOp) Get(customerID int64, options interface{}) (*Customer, error) {
path := fmt.Sprintf("%s/%v.json", customersBasePath, customerID)
resource := new(CustomerResource)
err := s.client.Get(path, resource, options)
Expand All @@ -124,7 +124,7 @@ func (s *CustomerServiceOp) Update(customer Customer) (*Customer, error) {
}

// Delete an existing customer
func (s *CustomerServiceOp) Delete(customerID int) error {
func (s *CustomerServiceOp) Delete(customerID int64) error {
path := fmt.Sprintf("%s/%d.json", customersBasePath, customerID)
return s.client.Delete(path)
}
Expand All @@ -138,43 +138,43 @@ func (s *CustomerServiceOp) Search(options interface{}) ([]Customer, error) {
}

// List metafields for a customer
func (s *CustomerServiceOp) ListMetafields(customerID int, options interface{}) ([]Metafield, error) {
func (s *CustomerServiceOp) ListMetafields(customerID int64, options interface{}) ([]Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customersResourceName, resourceID: customerID}
return metafieldService.List(options)
}

// Count metafields for a customer
func (s *CustomerServiceOp) CountMetafields(customerID int, options interface{}) (int, error) {
func (s *CustomerServiceOp) CountMetafields(customerID int64, options interface{}) (int, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customersResourceName, resourceID: customerID}
return metafieldService.Count(options)
}

// Get individual metafield for a customer
func (s *CustomerServiceOp) GetMetafield(customerID int, metafieldID int, options interface{}) (*Metafield, error) {
func (s *CustomerServiceOp) GetMetafield(customerID int64, metafieldID int64, options interface{}) (*Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customersResourceName, resourceID: customerID}
return metafieldService.Get(metafieldID, options)
}

// Create a new metafield for a customer
func (s *CustomerServiceOp) CreateMetafield(customerID int, metafield Metafield) (*Metafield, error) {
func (s *CustomerServiceOp) CreateMetafield(customerID int64, metafield Metafield) (*Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customersResourceName, resourceID: customerID}
return metafieldService.Create(metafield)
}

// Update an existing metafield for a customer
func (s *CustomerServiceOp) UpdateMetafield(customerID int, metafield Metafield) (*Metafield, error) {
func (s *CustomerServiceOp) UpdateMetafield(customerID int64, metafield Metafield) (*Metafield, error) {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customersResourceName, resourceID: customerID}
return metafieldService.Update(metafield)
}

// // Delete an existing metafield for a customer
func (s *CustomerServiceOp) DeleteMetafield(customerID int, metafieldID int) error {
func (s *CustomerServiceOp) DeleteMetafield(customerID int64, metafieldID int64) error {
metafieldService := &MetafieldServiceOp{client: s.client, resource: customersResourceName, resourceID: customerID}
return metafieldService.Delete(metafieldID)
}

// ListOrders retrieves all orders from a customer
func (s *CustomerServiceOp) ListOrders(customerID int, options interface{}) ([]Order, error) {
func (s *CustomerServiceOp) ListOrders(customerID int64, options interface{}) ([]Order, error) {
path := fmt.Sprintf("%s/%d/orders.json", customersBasePath, customerID)
resource := new(OrdersResource)
err := s.client.Get(path, resource, options)
Expand Down
Loading

0 comments on commit 480fb25

Please sign in to comment.