@@ -63,7 +63,7 @@ func NewStoreClient(config *StoreConfig) *StoreClient {
63
63
return client
64
64
}
65
65
66
- // NewWithClient creates a appstore server api client with a custom http client.
66
+ // NewStoreClientWithHTTPClient NewWithClient creates an App Store server api client with a custom http client.
67
67
func NewStoreClientWithHTTPClient (config * StoreConfig , httpClient * http.Client ) * StoreClient {
68
68
token := & Token {}
69
69
token .WithConfig (config )
@@ -387,7 +387,7 @@ func (a *StoreClient) GetTestNotificationStatus(ctx context.Context, testNotific
387
387
func (a * StoreClient ) ParseSignedTransactions (transactions []string ) ([]* JWSTransaction , error ) {
388
388
result := make ([]* JWSTransaction , 0 )
389
389
for _ , v := range transactions {
390
- trans , err := a .parseSignedTransaction (v )
390
+ trans , err := a .ParseSignedTransaction (v )
391
391
if err == nil && trans != nil {
392
392
result = append (result , trans )
393
393
}
@@ -396,7 +396,8 @@ func (a *StoreClient) ParseSignedTransactions(transactions []string) ([]*JWSTran
396
396
return result , nil
397
397
}
398
398
399
- func (a * StoreClient ) parseSignedTransaction (transaction string ) (* JWSTransaction , error ) {
399
+ // ParseSignedTransaction parse one jws singed transaction for API like GetTransactionInfo
400
+ func (a * StoreClient ) ParseSignedTransaction (transaction string ) (* JWSTransaction , error ) {
400
401
tran := & JWSTransaction {}
401
402
402
403
rootCertBytes , err := a .cert .extractCertByIndex (transaction , 2 )
@@ -444,7 +445,7 @@ func (a *StoreClient) parseSignedTransaction(transaction string) (*JWSTransactio
444
445
return tran , nil
445
446
}
446
447
447
- // Per doc: https://developer.apple.com/documentation/appstoreserverapi#topics
448
+ // Do Per doc: https://developer.apple.com/documentation/appstoreserverapi#topics
448
449
func (a * StoreClient ) Do (ctx context.Context , method string , url string , body io.Reader ) (int , []byte , error ) {
449
450
authToken , err := a .Token .GenerateIfExpired ()
450
451
if err != nil {
@@ -467,17 +468,17 @@ func (a *StoreClient) Do(ctx context.Context, method string, url string, body io
467
468
}
468
469
defer resp .Body .Close ()
469
470
470
- bytes , err := io .ReadAll (resp .Body )
471
+ bodyBytes , err := io .ReadAll (resp .Body )
471
472
if err != nil {
472
473
return resp .StatusCode , nil , fmt .Errorf ("appstore read http body err %w" , err )
473
474
}
474
475
475
476
if resp .StatusCode != http .StatusOK {
476
477
// try to extract detailed error.
477
- if rErr , ok := newErrorFromJSON (bytes ); ok {
478
- return resp .StatusCode , bytes , rErr
478
+ if rErr , ok := newErrorFromJSON (bodyBytes ); ok {
479
+ return resp .StatusCode , bodyBytes , rErr
479
480
}
480
481
}
481
482
482
- return resp .StatusCode , bytes , err
483
+ return resp .StatusCode , bodyBytes , err
483
484
}
0 commit comments