Skip to content

Commit

Permalink
Merge pull request #3 from alexanderjordanbaker/NotificationHistoryEn…
Browse files Browse the repository at this point in the history
…dpoint

Add the Get Notification history endpoint and add the ci-release.yml file
  • Loading branch information
alexanderjordanbaker committed Jun 7, 2023
2 parents 345b16c + 952a6c5 commit efa07f9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish Library
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
19 changes: 19 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export { DecodedSignedData } from './models/DecodedSignedData'
export { AppTransaction } from './models/AppTransaction'

import jsonwebtoken = require('jsonwebtoken');
import { NotificationHistoryRequest } from './models/NotificationHistoryRequest';
import { NotificationHistoryResponse, NotificationHistoryResponseValidator } from './models/NotificationHistoryResponse';

export class AppStoreServerAPIClient {
private static PRODUCTION_URL = "https://api.storekit.itunes.apple.com";
Expand Down Expand Up @@ -234,6 +236,23 @@ export class AppStoreServerAPIClient {
return await this.makeRequest("/inApps/v1/notifications/test/" + testNotificationToken, "GET", {}, null, new CheckTestNotificationResponseValidator());
}

/**
* Get a list of notifications that the App Store server attempted to send to your server.
*
* @param paginationToken An optional token you use to get the next set of up to 20 notification history records. All responses that have more records available include a paginationToken. Omit this parameter the first time you call this endpoint.
* @param notificationHistoryRequest The request body that includes the start and end dates, and optional query constraints.
* @return A response that contains the App Store Server Notifications history for your app.
* @throws APIException If a response was returned indicating the request could not be processed
* {@link https://developer.apple.com/documentation/appstoreserverapi/get_notification_histor Get Notification History}
*/
public async getNotificationHistory(paginationToken: string | null, notificationHistoryRequest: NotificationHistoryRequest): Promise<NotificationHistoryResponse> {
const queryParameters: { [key: string]: [string]} = {}
if (paginationToken != null) {
queryParameters["paginationToken"] = [paginationToken];
}
return await this.makeRequest("/inApps/v1/notifications/history", "POST", queryParameters, notificationHistoryRequest, new NotificationHistoryResponseValidator());
}

/**
* Get a customer’s in-app purchase transaction history for your app.
*
Expand Down
2 changes: 1 addition & 1 deletion models/NotificationHistoryRequest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Apple Inc. Licensed under MIT License.

import { NotificationTypeV2 } from "./NotificationTypeV2";
import { Subtype, SubtypeValidator } from "./Subtype";
import { Subtype } from "./Subtype";

/**
* The request body for notification history.
Expand Down

0 comments on commit efa07f9

Please sign in to comment.