-
Notifications
You must be signed in to change notification settings - Fork 14
/
Event.cs
530 lines (478 loc) · 19.5 KB
/
Event.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using GoCardless.Internals;
namespace GoCardless.Resources
{
/// <summary>
/// Represents a event resource.
///
/// Events are stored for all webhooks. An event refers to a resource which
/// has been updated, for example a payment which has been collected, or a
/// mandate which has been transferred. Event creation is an asynchronous
/// process, so it can take some time between an action occurring and its
/// corresponding event getting included in API responses. See
/// [here](#event-actions) for a complete list of event types.
/// </summary>
public class Event
{
/// <summary>
/// What has happened to the resource. See [Event
/// Actions](#event-actions) for the possible actions.
/// </summary>
[JsonProperty("action")]
public string Action { get; set; }
/// <summary>
/// Fixed [timestamp](#api-usage-time-zones--dates), recording when this
/// resource was created.
/// </summary>
[JsonProperty("created_at")]
public DateTimeOffset? CreatedAt { get; set; }
/// <summary>
/// Present only in webhooks when an integrator is authorised to send
/// their own
/// notifications. See
/// [here](/getting-started/api/handling-customer-notifications/)
/// for further information.
///
/// </summary>
[JsonProperty("customer_notifications")]
public List<EventCustomerNotification> CustomerNotifications { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("details")]
public EventDetails Details { get; set; }
/// <summary>
/// Unique identifier, beginning with "EV".
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
/// <summary>
/// Resources linked to this Event.
/// </summary>
[JsonProperty("links")]
public EventLinks Links { get; set; }
/// <summary>
/// The metadata that was passed when making the API request that
/// triggered the event
/// (for instance, cancelling a mandate).
///
/// This field will only be populated if the `details[origin]` field is
/// `api` otherwise it will be an empty object.
///
/// </summary>
[JsonProperty("metadata")]
public IDictionary<string, string> Metadata { get; set; }
/// <summary>
/// The metadata of the resource that the event is for. For example,
/// this field will have the same
/// value of the `mandate[metadata]` field on the response you would
/// receive from performing a GET request on a mandate.
///
/// </summary>
[JsonProperty("resource_metadata")]
public IDictionary<string, string> ResourceMetadata { get; set; }
/// <summary>
/// The resource type for this event. One of:
/// <ul>
/// <li>`billing_requests`</li>
/// <li>`creditors`</li>
/// <li>`instalment_schedules`</li>
/// <li>`mandates`</li>
/// <li>`payer_authorisations`</li>
/// <li>`payments`</li>
/// <li>`payouts`</li>
/// <li>`refunds`</li>
/// <li>`scheme_identifiers`</li>
/// <li>`subscriptions`</li>
/// </ul>
/// </summary>
[JsonProperty("resource_type")]
public EventResourceType? ResourceType { get; set; }
}
/// <summary>
/// Present only in webhooks when an integrator is authorised to send their
/// own
/// notifications. See
/// [here](/getting-started/api/handling-customer-notifications/)
/// for further information.
///
/// </summary>
public class EventCustomerNotification
{
/// <summary>
/// Time after which GoCardless will send the notification by email.
/// </summary>
[JsonProperty("deadline")]
public string Deadline { get; set; }
/// <summary>
/// The id of the notification.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
/// <summary>
/// Whether or not the notification must be sent.
/// </summary>
[JsonProperty("mandatory")]
public bool? Mandatory { get; set; }
/// <summary>
/// See [here](#core-endpoints-customer-notifications) for a complete
/// list of customer notification types.
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
}
public class EventDetails
{
/// <summary>
/// When we send a creditor `new_payout_currency_added` webhook, we also
/// send the bank account id of the new account
/// </summary>
[JsonProperty("bank_account_id")]
public string BankAccountId { get; set; }
/// <summary>
/// What triggered the event. _Note:_ `cause` is our simplified and
/// predictable key indicating what triggered the event.
/// </summary>
[JsonProperty("cause")]
public string Cause { get; set; }
/// <summary>
/// When we send a creditor `new_payout_currency_added` webhook, we also
/// send the currency of the new account
/// </summary>
[JsonProperty("currency")]
public string Currency { get; set; }
/// <summary>
/// Human readable description of the cause. _Note:_ Changes to event
/// descriptions are not considered breaking.
/// </summary>
[JsonProperty("description")]
public string Description { get; set; }
/// <summary>
/// When will_attempt_retry is set to false, this field will contain
/// the reason the payment was not retried. This can be one of:
/// <ul>
/// <li>`failure_filter_applied`: The payment won't be intelligently
/// retried as
/// there is a high likelihood of failure on retry.</li>
/// <li>`other`: The payment won't be intelligently retried due to any
/// other
/// reason.</li>
/// </ul>
/// </summary>
[JsonProperty("not_retried_reason")]
public string NotRetriedReason { get; set; }
/// <summary>
/// Who initiated the event. One of:
/// <ul>
/// <li>`bank`: this event was triggered by a report from the banks</li>
/// <li>`gocardless`: this event was performed by GoCardless
/// automatically</li>
/// <li>`api`: this event was triggered by an API endpoint</li>
/// <li>`customer`: this event was triggered by a Customer</li>
/// <li>`payer`: this event was triggered by a Payer</li>
/// </ul>
/// </summary>
[JsonProperty("origin")]
public EventDetailsOrigin? Origin { get; set; }
/// <summary>
/// When we send a creditor `creditor_updated` webhook, this tells you
/// which property on the creditor has been updated
/// </summary>
[JsonProperty("property")]
public string Property { get; set; }
/// <summary>
/// Set when a `bank` is the origin of the event. This is the reason
/// code received in the report from the customer's bank. See the
/// [GoCardless Direct Debit
/// guide](https://gocardless.com/direct-debit/receiving-messages) for
/// information on the meanings of different reason codes. _Note:_
/// `reason_code` is payment scheme-specific and can be inconsistent
/// between banks.
/// </summary>
[JsonProperty("reason_code")]
public string ReasonCode { get; set; }
/// <summary>
/// A bank payment scheme. Set when a bank is the origin of the event.
/// </summary>
[JsonProperty("scheme")]
public EventDetailsScheme? Scheme { get; set; }
/// <summary>
/// Whether the payment will be retried automatically. Set on a payment
/// failed event.
/// </summary>
[JsonProperty("will_attempt_retry")]
public bool? WillAttemptRetry { get; set; }
}
/// <summary>
/// Who initiated the event. One of:
/// <ul>
/// <li>`bank`: this event was triggered by a report from the banks</li>
/// <li>`gocardless`: this event was performed by GoCardless automatically</li>
/// <li>`api`: this event was triggered by an API endpoint</li>
/// <li>`customer`: this event was triggered by a Customer</li>
/// <li>`payer`: this event was triggered by a Payer</li>
/// </ul>
/// </summary>
[JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)]
public enum EventDetailsOrigin {
/// <summary>Unknown status</summary>
[EnumMember(Value = "unknown")]
Unknown = 0,
/// <summary>`origin` with a value of "bank"</summary>
[EnumMember(Value = "bank")]
Bank,
/// <summary>`origin` with a value of "api"</summary>
[EnumMember(Value = "api")]
Api,
/// <summary>`origin` with a value of "gocardless"</summary>
[EnumMember(Value = "gocardless")]
Gocardless,
/// <summary>`origin` with a value of "customer"</summary>
[EnumMember(Value = "customer")]
Customer,
/// <summary>`origin` with a value of "payer"</summary>
[EnumMember(Value = "payer")]
Payer,
}
/// <summary>
/// A bank payment scheme. Set when a bank is the origin of the event.
/// </summary>
[JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)]
public enum EventDetailsScheme {
/// <summary>Unknown status</summary>
[EnumMember(Value = "unknown")]
Unknown = 0,
/// <summary>`scheme` with a value of "ach"</summary>
[EnumMember(Value = "ach")]
Ach,
/// <summary>`scheme` with a value of "autogiro"</summary>
[EnumMember(Value = "autogiro")]
Autogiro,
/// <summary>`scheme` with a value of "bacs"</summary>
[EnumMember(Value = "bacs")]
Bacs,
/// <summary>`scheme` with a value of "becs"</summary>
[EnumMember(Value = "becs")]
Becs,
/// <summary>`scheme` with a value of "becs_nz"</summary>
[EnumMember(Value = "becs_nz")]
BecsNz,
/// <summary>`scheme` with a value of "betalingsservice"</summary>
[EnumMember(Value = "betalingsservice")]
Betalingsservice,
/// <summary>`scheme` with a value of "faster_payments"</summary>
[EnumMember(Value = "faster_payments")]
FasterPayments,
/// <summary>`scheme` with a value of "pad"</summary>
[EnumMember(Value = "pad")]
Pad,
/// <summary>`scheme` with a value of "pay_to"</summary>
[EnumMember(Value = "pay_to")]
PayTo,
/// <summary>`scheme` with a value of "sepa_core"</summary>
[EnumMember(Value = "sepa_core")]
SepaCore,
/// <summary>`scheme` with a value of "sepa_cor1"</summary>
[EnumMember(Value = "sepa_cor1")]
SepaCor1,
}
/// <summary>
/// Resources linked to this Event
/// </summary>
public class EventLinks
{
/// <summary>
/// ID of a [bank authorisation](#billing-requests-bank-authorisations).
/// </summary>
[JsonProperty("bank_authorisation")]
public string BankAuthorisation { get; set; }
/// <summary>
/// ID of a [billing request](#billing-requests-billing-requests).
/// </summary>
[JsonProperty("billing_request")]
public string BillingRequest { get; set; }
/// <summary>
/// ID of a [billing request
/// flow](#billing-requests-billing-request-flows).
/// </summary>
[JsonProperty("billing_request_flow")]
public string BillingRequestFlow { get; set; }
/// <summary>
/// If `resource_type` is `creditor`, this is the ID of the
/// [creditor](#core-endpoints-creditors) which has been updated.
/// </summary>
[JsonProperty("creditor")]
public string Creditor { get; set; }
/// <summary>
/// ID of a [customer](#core-endpoints-customers).
/// </summary>
[JsonProperty("customer")]
public string Customer { get; set; }
/// <summary>
/// ID of a [customer bank
/// account](#core-endpoints-customer-bank-accounts).
/// </summary>
[JsonProperty("customer_bank_account")]
public string CustomerBankAccount { get; set; }
/// <summary>
/// If `resource_type` is `instalment_schedule`, this is the ID of the
/// [instalment schedule](#core-endpoints-instalment-schedules) which
/// has been updated.
/// </summary>
[JsonProperty("instalment_schedule")]
public string InstalmentSchedule { get; set; }
/// <summary>
/// If `resource_type` is `mandates`, this is the ID of the
/// [mandate](#core-endpoints-mandates) which has been updated.
/// </summary>
[JsonProperty("mandate")]
public string Mandate { get; set; }
/// <summary>
/// If `resource_type` is `billing_requests`, this is the ID of the
/// [mandate](#core-endpoints-mandates) which has been created.
/// </summary>
[JsonProperty("mandate_request_mandate")]
public string MandateRequestMandate { get; set; }
/// <summary>
/// This is only included for mandate transfer events, when it is the ID
/// of the [customer bank
/// account](#core-endpoints-customer-bank-accounts) which the mandate
/// is being transferred to.
/// </summary>
[JsonProperty("new_customer_bank_account")]
public string NewCustomerBankAccount { get; set; }
/// <summary>
/// This is only included for mandate replaced events, when it is the ID
/// of the new [mandate](#core-endpoints-mandates) that replaces the
/// existing mandate.
/// </summary>
[JsonProperty("new_mandate")]
public string NewMandate { get; set; }
/// <summary>
/// If the event is included in a [webhook](#webhooks-overview) to an
/// [OAuth app](#appendix-oauth), this is the ID of the account to which
/// it belongs.
/// </summary>
[JsonProperty("organisation")]
public string Organisation { get; set; }
/// <summary>
/// If this event was caused by another, this is the ID of the cause.
/// For example, if a mandate is cancelled it automatically cancels all
/// pending payments associated with it; in this case, the payment
/// cancellation events would have the ID of the mandate cancellation
/// event in this field.
/// </summary>
[JsonProperty("parent_event")]
public string ParentEvent { get; set; }
/// <summary>
/// ID of a [payer authorisation](#core-endpoints-payer-authorisations).
/// </summary>
[JsonProperty("payer_authorisation")]
public string PayerAuthorisation { get; set; }
/// <summary>
/// If `resource_type` is `payments`, this is the ID of the
/// [payment](#core-endpoints-payments) which has been updated.
/// </summary>
[JsonProperty("payment")]
public string Payment { get; set; }
/// <summary>
/// If `resource_type` is `billing_requests`, this is the ID of the
/// [payment](#core-endpoints-payments) which has been created for
/// Instant Bank Payment.
/// </summary>
[JsonProperty("payment_request_payment")]
public string PaymentRequestPayment { get; set; }
/// <summary>
/// If `resource_type` is `payouts`, this is the ID of the
/// [payout](#core-endpoints-payouts) which has been updated.
/// </summary>
[JsonProperty("payout")]
public string Payout { get; set; }
/// <summary>
/// This is only included for mandate transfer events, when it is the ID
/// of the [customer bank
/// account](#core-endpoints-customer-bank-accounts) which the mandate
/// is being transferred from.
/// </summary>
[JsonProperty("previous_customer_bank_account")]
public string PreviousCustomerBankAccount { get; set; }
/// <summary>
/// If `resource_type` is `refunds`, this is the ID of the
/// [refund](#core-endpoints-refunds) which has been updated.
/// </summary>
[JsonProperty("refund")]
public string Refund { get; set; }
/// <summary>
/// If `resource_type` is `scheme_identifiers`, this is the ID of the
/// [scheme_identifier](#core-endpoints-scheme-identifiers) which has
/// been updated.
/// </summary>
[JsonProperty("scheme_identifier")]
public string SchemeIdentifier { get; set; }
/// <summary>
/// If `resource_type` is `subscription`, this is the ID of the
/// [subscription](#core-endpoints-subscriptions) which has been
/// updated.
/// </summary>
[JsonProperty("subscription")]
public string Subscription { get; set; }
}
/// <summary>
/// The resource type for this event. One of:
/// <ul>
/// <li>`billing_requests`</li>
/// <li>`creditors`</li>
/// <li>`instalment_schedules`</li>
/// <li>`mandates`</li>
/// <li>`payer_authorisations`</li>
/// <li>`payments`</li>
/// <li>`payouts`</li>
/// <li>`refunds`</li>
/// <li>`scheme_identifiers`</li>
/// <li>`subscriptions`</li>
/// </ul>
/// </summary>
[JsonConverter(typeof(GcStringEnumConverter), (int)Unknown)]
public enum EventResourceType {
/// <summary>Unknown status</summary>
[EnumMember(Value = "unknown")]
Unknown = 0,
/// <summary>`resource_type` with a value of "billing_requests"</summary>
[EnumMember(Value = "billing_requests")]
BillingRequests,
/// <summary>`resource_type` with a value of "creditors"</summary>
[EnumMember(Value = "creditors")]
Creditors,
/// <summary>`resource_type` with a value of "instalment_schedules"</summary>
[EnumMember(Value = "instalment_schedules")]
InstalmentSchedules,
/// <summary>`resource_type` with a value of "mandates"</summary>
[EnumMember(Value = "mandates")]
Mandates,
/// <summary>`resource_type` with a value of "organisations"</summary>
[EnumMember(Value = "organisations")]
Organisations,
/// <summary>`resource_type` with a value of "payer_authorisations"</summary>
[EnumMember(Value = "payer_authorisations")]
PayerAuthorisations,
/// <summary>`resource_type` with a value of "payments"</summary>
[EnumMember(Value = "payments")]
Payments,
/// <summary>`resource_type` with a value of "payouts"</summary>
[EnumMember(Value = "payouts")]
Payouts,
/// <summary>`resource_type` with a value of "refunds"</summary>
[EnumMember(Value = "refunds")]
Refunds,
/// <summary>`resource_type` with a value of "scheme_identifiers"</summary>
[EnumMember(Value = "scheme_identifiers")]
SchemeIdentifiers,
/// <summary>`resource_type` with a value of "subscriptions"</summary>
[EnumMember(Value = "subscriptions")]
Subscriptions,
}
}