1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Net . Http ;
4+ using System . Threading ;
5+ using System . Threading . Tasks ;
6+
7+ namespace WebPush
8+ {
9+ public interface IWebPushClient : IDisposable
10+ {
11+ /// <summary>
12+ /// When sending messages to a GCM endpoint you need to set the GCM API key
13+ /// by either calling setGcmApiKey() or passing in the API key as an option
14+ /// to sendNotification()
15+ /// </summary>
16+ /// <param name="gcmApiKey">The API key to send with the GCM request.</param>
17+ void SetGcmApiKey ( string gcmApiKey ) ;
18+
19+ /// <summary>
20+ /// When marking requests where you want to define VAPID details, call this method
21+ /// before sendNotifications() or pass in the details and options to
22+ /// sendNotification.
23+ /// </summary>
24+ /// <param name="vapidDetails"></param>
25+ void SetVapidDetails ( VapidDetails vapidDetails ) ;
26+
27+ /// <summary>
28+ /// When marking requests where you want to define VAPID details, call this method
29+ /// before sendNotifications() or pass in the details and options to
30+ /// sendNotification.
31+ /// </summary>
32+ /// <param name="subject">This must be either a URL or a 'mailto:' address</param>
33+ /// <param name="publicKey">The public VAPID key as a base64 encoded string</param>
34+ /// <param name="privateKey">The private VAPID key as a base64 encoded string</param>
35+ void SetVapidDetails ( string subject , string publicKey , string privateKey ) ;
36+
37+ /// <summary>
38+ /// To get a request without sending a push notification call this method.
39+ /// This method will throw an ArgumentException if there is an issue with the input.
40+ /// </summary>
41+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
42+ /// <param name="payload">The payload you wish to send to the user</param>
43+ /// <param name="options">
44+ /// Options for the GCM API key and vapid keys can be passed in if they are unique for each
45+ /// notification.
46+ /// </param>
47+ /// <returns>A HttpRequestMessage object that can be sent.</returns>
48+ HttpRequestMessage GenerateRequestDetails ( PushSubscription subscription , string payload ,
49+ Dictionary < string , object > options = null ) ;
50+
51+ /// <summary>
52+ /// To send a push notification call this method with a subscription, optional payload and any options
53+ /// Will exception if unsuccessful
54+ /// </summary>
55+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
56+ /// <param name="payload">The payload you wish to send to the user</param>
57+ /// <param name="options">
58+ /// Options for the GCM API key and vapid keys can be passed in if they are unique for each
59+ /// notification.
60+ /// </param>
61+ void SendNotification ( PushSubscription subscription , string payload = null ,
62+ Dictionary < string , object > options = null ) ;
63+
64+ /// <summary>
65+ /// To send a push notification call this method with a subscription, optional payload and any options
66+ /// Will exception if unsuccessful
67+ /// </summary>
68+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
69+ /// <param name="payload">The payload you wish to send to the user</param>
70+ /// <param name="vapidDetails">The vapid details for the notification.</param>
71+ void SendNotification ( PushSubscription subscription , string payload , VapidDetails vapidDetails ) ;
72+
73+ /// <summary>
74+ /// To send a push notification call this method with a subscription, optional payload and any options
75+ /// Will exception if unsuccessful
76+ /// </summary>
77+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
78+ /// <param name="payload">The payload you wish to send to the user</param>
79+ /// <param name="gcmApiKey">The GCM API key</param>
80+ void SendNotification ( PushSubscription subscription , string payload , string gcmApiKey ) ;
81+
82+ /// <summary>
83+ /// To send a push notification asynchronous call this method with a subscription, optional payload and any options
84+ /// Will exception if unsuccessful
85+ /// </summary>
86+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
87+ /// <param name="payload">The payload you wish to send to the user</param>
88+ /// <param name="options">
89+ /// Options for the GCM API key and vapid keys can be passed in if they are unique for each
90+ /// notification.
91+ /// </param>
92+ /// <param name="cancellationToken">The cancellation token to cancel operation.</param>
93+ Task SendNotificationAsync ( PushSubscription subscription , string payload = null ,
94+ Dictionary < string , object > options = null , CancellationToken cancellationToken = default ) ;
95+
96+ /// <summary>
97+ /// To send a push notification asynchronous call this method with a subscription, optional payload and any options
98+ /// Will exception if unsuccessful
99+ /// </summary>
100+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
101+ /// <param name="payload">The payload you wish to send to the user</param>
102+ /// <param name="vapidDetails">The vapid details for the notification.</param>
103+ /// <param name="cancellationToken"></param>
104+ Task SendNotificationAsync ( PushSubscription subscription , string payload ,
105+ VapidDetails vapidDetails , CancellationToken cancellationToken = default ) ;
106+
107+ /// <summary>
108+ /// To send a push notification asynchronous call this method with a subscription, optional payload and any options
109+ /// Will exception if unsuccessful
110+ /// </summary>
111+ /// <param name="subscription">The PushSubscription you wish to send the notification to.</param>
112+ /// <param name="payload">The payload you wish to send to the user</param>
113+ /// <param name="gcmApiKey">The GCM API key</param>
114+ /// <param name="cancellationToken"></param>
115+ Task SendNotificationAsync ( PushSubscription subscription , string payload , string gcmApiKey , CancellationToken cancellationToken = default ) ;
116+ }
117+ }
0 commit comments