first drafts for inventory sync page
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
)
|
||||
|
||||
//go:generate oapi-codegen -generate types,client -package generated_client -o generated_client/client.go openapi.3.0.2.json
|
||||
//go:generate concurry -s Platform
|
||||
|
||||
// TODO:
|
||||
// - [x] document the flow in the README.md
|
||||
@@ -36,11 +37,6 @@ type (
|
||||
apiSharedSecret string
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
PlatformWithContext struct {
|
||||
ctx context.Context
|
||||
p *Platform
|
||||
}
|
||||
)
|
||||
|
||||
// oauth scopes
|
||||
@@ -77,10 +73,7 @@ func NewPlatform(oAuthRedirectURI func(acctID int64) string, apiKeystring, apiSh
|
||||
}
|
||||
|
||||
func (p *Platform) WithContext(ctx context.Context) *PlatformWithContext {
|
||||
return &PlatformWithContext{
|
||||
ctx: ctx,
|
||||
p: p,
|
||||
}
|
||||
return NewPlatformWithContext(ctx, p)
|
||||
}
|
||||
|
||||
func (p *Platform) GenerateConnectionURLForNewAccount(ctx context.Context, acctID int64) (*url.URL, error) {
|
||||
@@ -113,10 +106,6 @@ func (p *Platform) GenerateConnectionURLForNewAccount(ctx context.Context, acctI
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PlatformWithContext) GenerateConnectionURLForNewAccount(acctID int64) (*url.URL, error) {
|
||||
return p.p.GenerateConnectionURLForNewAccount(p.ctx, acctID)
|
||||
}
|
||||
|
||||
// HandleNewAuthCode handles the auth code to get api access
|
||||
func (p *Platform) HandleNewAuthCode(ctx context.Context, acctID int64, state, authCode string) (bool, error) {
|
||||
// look up matching oauth request
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// Code generated by concurry DO NOT EDIT.
|
||||
// https://github.com/angelbeltran/concurry
|
||||
// concurry
|
||||
package etsy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/google/uuid"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PlatformWithContext struct {
|
||||
ctx context.Context
|
||||
*Platform
|
||||
}
|
||||
|
||||
func NewPlatformWithContext(ctx context.Context, v *Platform) *PlatformWithContext {
|
||||
return &PlatformWithContext{
|
||||
ctx: ctx,
|
||||
Platform: v,
|
||||
}
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) GenerateConnectionURLForNewAccount(acctID int64) (*url.URL, error) {
|
||||
return v_ctx.Platform.GenerateConnectionURLForNewAccount(v_ctx.ctx, acctID)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) HandleNewAuthCode(acctID int64, state string, authCode string) (bool, error) {
|
||||
return v_ctx.Platform.HandleNewAuthCode(v_ctx.ctx, acctID, state, authCode)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) parseAccessCodeResponseBody(body []byte) (string, string, time.Time, int64, error) {
|
||||
return v_ctx.Platform.parseAccessCodeResponseBody(v_ctx.ctx, body)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) getNewUserShopID(accessToken string, userID int64) (int64, error) {
|
||||
return v_ctx.Platform.getNewUserShopID(v_ctx.ctx, accessToken, userID)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) GetUserPointerByAccountID(acctID int64) (*EtsyUser, error) {
|
||||
return v_ctx.Platform.GetUserPointerByAccountID(v_ctx.ctx, acctID)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) saveNewEtsyUser(user EtsyUser, tokens etsyAccessTokens) error {
|
||||
return v_ctx.Platform.saveNewEtsyUser(v_ctx.ctx, user, tokens)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) createNewOAuthRequest(acctID int64) (oauth2Request, error) {
|
||||
return v_ctx.Platform.createNewOAuthRequest(v_ctx.ctx, acctID)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) getOauthRequest(state uuid.UUID) (oauth2Request, bool, error) {
|
||||
return v_ctx.Platform.getOauthRequest(v_ctx.ctx, state)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) InvalidateState(state string) error {
|
||||
return v_ctx.Platform.InvalidateState(v_ctx.ctx, state)
|
||||
}
|
||||
|
||||
func (v_ctx *PlatformWithContext) deleteOauthRequest(state uuid.UUID) error {
|
||||
return v_ctx.Platform.deleteOauthRequest(v_ctx.ctx, state)
|
||||
}
|
||||
@@ -73,10 +73,6 @@ func (p *Platform) GetUserPointerByAccountID(ctx context.Context, acctID int64)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *PlatformWithContext) GetUserPointerByAccountID(acctID int64) (*EtsyUser, error) {
|
||||
return p.p.GetUserPointerByAccountID(p.ctx, acctID)
|
||||
}
|
||||
|
||||
func (p *Platform) saveNewEtsyUser(
|
||||
ctx context.Context,
|
||||
user EtsyUser,
|
||||
|
||||
Reference in New Issue
Block a user