MCPcopy Create free account
hub / github.com/AndroidPoet/playconsole-cli / NewClient

Function NewClient

internal/api/client.go:42–78  ·  view source on GitHub ↗

NewClient creates a new API client

(packageName string, timeout time.Duration)

Source from the content-addressed store, hash-verified

40
41// NewClient creates a new API client
42func NewClient(packageName string, timeout time.Duration) (*Client, error) {
43 ctx := context.Background()
44 timeout = cli.ResolveTimeout(timeout)
45
46 // Get credentials
47 creds, err := config.GetCredentials()
48 if err != nil {
49 return nil, err
50 }
51
52 // Create JWT config
53 jwtConfig, err := google.JWTConfigFromJSON(creds, androidpublisher.AndroidpublisherScope)
54 if err != nil {
55 return nil, fmt.Errorf("failed to parse credentials: %w", err)
56 }
57
58 // Create HTTP client
59 httpClient := jwtConfig.Client(ctx)
60
61 // Add debug transport if enabled
62 if config.IsDebug() {
63 httpClient.Transport = &debugTransport{base: httpClient.Transport}
64 }
65
66 // Create service
67 service, err := androidpublisher.NewService(ctx, option.WithHTTPClient(httpClient))
68 if err != nil {
69 return nil, fmt.Errorf("failed to create API client: %w", err)
70 }
71
72 return &Client{
73 service: service,
74 packageName: packageName,
75 timeout: timeout,
76 debug: config.IsDebug(),
77 }, nil
78}
79
80// GetService returns the underlying Android Publisher service
81func (c *Client) GetService() *androidpublisher.Service {

Callers 15

runListFunction · 0.92
runGrantFunction · 0.92
runRevokeFunction · 0.92
runUploadFunction · 0.92
runListFunction · 0.92
runFindFunction · 0.92
runWaitFunction · 0.92
runCreateFunction · 0.92
runGetFunction · 0.92
runValidateFunction · 0.92
runCommitFunction · 0.92
runDeleteFunction · 0.92

Calls 3

ResolveTimeoutFunction · 0.92
GetCredentialsFunction · 0.92
IsDebugFunction · 0.92

Tested by

no test coverage detected