forked from s-norris/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from xiatechs/upstream-upgrade
Upgrade upstream to v3.12.0
- Loading branch information
Showing
14 changed files
with
108 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package goshopify | ||
|
||
type AccessScopesService interface { | ||
List(interface{}) ([]AccessScope, error) | ||
} | ||
|
||
type AccessScope struct { | ||
Handle string `json:"handle,omitempty"` | ||
} | ||
|
||
// AccessScopesResource represents the result from the oauth/access_scopes.json endpoint | ||
type AccessScopesResource struct { | ||
AccessScopes []AccessScope `json:"access_scopes,omitempty"` | ||
} | ||
|
||
// AccessScopesServiceOp handles communication with the Access Scopes | ||
// related methods of the Shopify API | ||
type AccessScopesServiceOp struct { | ||
client *Client | ||
} | ||
|
||
// List gets access scopes based on used oauth token | ||
func (s *AccessScopesServiceOp) List(options interface{}) ([]AccessScope, error) { | ||
path := "oauth/access_scopes.json" | ||
resource := new(AccessScopesResource) | ||
err := s.client.Get(path, resource, options) | ||
return resource.AccessScopes, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package goshopify | ||
|
||
import ( | ||
"testing" | ||
"fmt" | ||
"reflect" | ||
|
||
"github.com/jarcoal/httpmock" | ||
) | ||
|
||
func TestAccessScopesServiceOp_List(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
httpmock.RegisterResponder( | ||
"GET", | ||
fmt.Sprintf("https://fooshop.myshopify.com/%s/oauth/access_scopes.json", client.pathPrefix), | ||
httpmock.NewBytesResponder(200, loadFixture("access_scopes.json")), | ||
) | ||
|
||
scopeResponse, err := client.AccessScopes.List(nil) | ||
if err != nil { | ||
t.Errorf("AccessScopes.List returned an error: %v", err) | ||
} | ||
|
||
expected := []AccessScope{ | ||
{ | ||
Handle: "scope_1", | ||
}, | ||
{ | ||
Handle: "scope_2", | ||
}, | ||
} | ||
if !reflect.DeepEqual(scopeResponse, expected) { | ||
t.Errorf("AccessScopes.List returned %+v, expected %+v", expected, expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"access_scopes": [ | ||
{ | ||
"handle": "scope_1" | ||
}, | ||
{ | ||
"handle": "scope_2" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters