Skip to content

Commit 848d108

Browse files
authored
Merge pull request #212 from sheldon5/master
change parseSignedTransaction to public
2 parents 1fabbc2 + 7b6656f commit 848d108

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

appstore/api/store.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewStoreClient(config *StoreConfig) *StoreClient {
6363
return client
6464
}
6565

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.
6767
func NewStoreClientWithHTTPClient(config *StoreConfig, httpClient *http.Client) *StoreClient {
6868
token := &Token{}
6969
token.WithConfig(config)
@@ -387,7 +387,7 @@ func (a *StoreClient) GetTestNotificationStatus(ctx context.Context, testNotific
387387
func (a *StoreClient) ParseSignedTransactions(transactions []string) ([]*JWSTransaction, error) {
388388
result := make([]*JWSTransaction, 0)
389389
for _, v := range transactions {
390-
trans, err := a.parseSignedTransaction(v)
390+
trans, err := a.ParseSignedTransaction(v)
391391
if err == nil && trans != nil {
392392
result = append(result, trans)
393393
}
@@ -396,7 +396,8 @@ func (a *StoreClient) ParseSignedTransactions(transactions []string) ([]*JWSTran
396396
return result, nil
397397
}
398398

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) {
400401
tran := &JWSTransaction{}
401402

402403
rootCertBytes, err := a.cert.extractCertByIndex(transaction, 2)
@@ -444,7 +445,7 @@ func (a *StoreClient) parseSignedTransaction(transaction string) (*JWSTransactio
444445
return tran, nil
445446
}
446447

447-
// Per doc: https://developer.apple.com/documentation/appstoreserverapi#topics
448+
// Do Per doc: https://developer.apple.com/documentation/appstoreserverapi#topics
448449
func (a *StoreClient) Do(ctx context.Context, method string, url string, body io.Reader) (int, []byte, error) {
449450
authToken, err := a.Token.GenerateIfExpired()
450451
if err != nil {
@@ -467,17 +468,17 @@ func (a *StoreClient) Do(ctx context.Context, method string, url string, body io
467468
}
468469
defer resp.Body.Close()
469470

470-
bytes, err := io.ReadAll(resp.Body)
471+
bodyBytes, err := io.ReadAll(resp.Body)
471472
if err != nil {
472473
return resp.StatusCode, nil, fmt.Errorf("appstore read http body err %w", err)
473474
}
474475

475476
if resp.StatusCode != http.StatusOK {
476477
// 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
479480
}
480481
}
481482

482-
return resp.StatusCode, bytes, err
483+
return resp.StatusCode, bodyBytes, err
483484
}

0 commit comments

Comments
 (0)