Skip to content

Commit caf3aab

Browse files
committed
Minor clean up to clarify usage
1 parent 63eb95b commit caf3aab

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

apps/sparkpost-samples-app/src/main/java/com/sparkpost/samples/DeliverabilityMetricsSample.java

+34-37
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public class DeliverabilityMetricsSample extends SparkPostBaseApp {
3434

3535
static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
3636

37-
private Client client;
38-
3937
public static void main(String[] args) throws SparkPostException, IOException {
4038
Logger.getRootLogger().setLevel(Level.DEBUG);
4139

@@ -204,7 +202,7 @@ public static void main(String[] args) throws SparkPostException, IOException {
204202
* See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics/deliverability-metrics-summary
205203
*/
206204
private void deliverabilityMetric() throws SparkPostException, IOException {
207-
this.client = this.newConfiguredClient();
205+
Client client = this.newConfiguredClient();
208206

209207
String from = FROM_DATE;
210208
String to = null;
@@ -216,7 +214,7 @@ private void deliverabilityMetric() throws SparkPostException, IOException {
216214
String metrics = MetricsFields.ALL_FIELDS;
217215
String timezone = null;
218216

219-
RestConnection connection = new RestConnection(this.client, getEndPoint());
217+
RestConnection connection = new RestConnection(client, getEndPoint());
220218
DeliverabiltyMetricsResponse response = ResourceMetrics
221219
.getDeliverabilityMetricsSummary(connection, from, to, domains, campaigns, templates, metrics, timezone);
222220

@@ -228,7 +226,6 @@ private void deliverabilityMetric() throws SparkPostException, IOException {
228226
}
229227

230228
logger.debug("-------------- LINKS -------------");
231-
232229
List<MetricLinkResponse> links = response.getLinks();
233230
for (MetricLinkResponse link : links) {
234231
logger.debug("Link: " + link.getRel());
@@ -240,7 +237,7 @@ private void deliverabilityMetric() throws SparkPostException, IOException {
240237
* See: https://developers.sparkpost.com/api/#/reference/metrics/discoverability-links/deliverability-metrics-by-domain
241238
*/
242239
private void deliverabilityDomainMetric() throws SparkPostException, IOException {
243-
this.client = this.newConfiguredClient();
240+
Client client = this.newConfiguredClient();
244241

245242
String from = FROM_DATE;
246243
String to = null;
@@ -254,7 +251,7 @@ private void deliverabilityDomainMetric() throws SparkPostException, IOException
254251
String orderBy = null;
255252
String limit = null;
256253

257-
RestConnection connection = new RestConnection(this.client, getEndPoint());
254+
RestConnection connection = new RestConnection(client, getEndPoint());
258255
DeliverabiltyMetricsResponse response = ResourceMetrics
259256
.getDeliverabilityMetricsByDomain(connection, from, to, domains, campaigns, templates, metrics, timezone, orderBy, limit);
260257

@@ -272,7 +269,7 @@ private void deliverabilityDomainMetric() throws SparkPostException, IOException
272269
* See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics-by-binding/deliverability-metrics-by-campaign
273270
*/
274271
private void deliverabilityCampaignMetric() throws SparkPostException, IOException {
275-
this.client = this.newConfiguredClient();
272+
Client client = this.newConfiguredClient();
276273

277274
String from = FROM_DATE;
278275
String to = null;
@@ -286,7 +283,7 @@ private void deliverabilityCampaignMetric() throws SparkPostException, IOExcepti
286283
String orderBy = null;
287284
String limit = null;
288285

289-
RestConnection connection = new RestConnection(this.client, getEndPoint());
286+
RestConnection connection = new RestConnection(client, getEndPoint());
290287
DeliverabiltyMetricsResponse response = ResourceMetrics
291288
.getDeliverabilityMetricsByCampaign(connection, from, to, domains, campaigns, templates, metrics, timezone, orderBy, limit);
292289

@@ -304,7 +301,7 @@ private void deliverabilityCampaignMetric() throws SparkPostException, IOExcepti
304301
* See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics-by-binding-group/deliverability-metrics-by-template
305302
*/
306303
private void deliverabilityTemplateMetric() throws SparkPostException, IOException {
307-
this.client = this.newConfiguredClient();
304+
Client client = this.newConfiguredClient();
308305

309306
String from = FROM_DATE;
310307
String to = null;
@@ -318,7 +315,7 @@ private void deliverabilityTemplateMetric() throws SparkPostException, IOExcepti
318315
String orderBy = null;
319316
String limit = null;
320317

321-
RestConnection connection = new RestConnection(this.client, getEndPoint());
318+
RestConnection connection = new RestConnection(client, getEndPoint());
322319
DeliverabiltyMetricsResponse response = ResourceMetrics
323320
.getDeliverabilityMetricsByTemplate(connection, from, to, domains, campaigns, templates, metrics, timezone, orderBy, limit);
324321

@@ -337,7 +334,7 @@ private void deliverabilityTemplateMetric() throws SparkPostException, IOExcepti
337334
* See: https://developers.sparkpost.com/api/#/reference/metrics/deliverability-metrics-by-binding-group/deliverability-metrics-by-watched-domain
338335
*/
339336
private void deliverabilityWatchedDomainMetric() throws SparkPostException, IOException {
340-
this.client = this.newConfiguredClient();
337+
Client client = this.newConfiguredClient();
341338

342339
String from = FROM_DATE;
343340
String to = null;
@@ -351,7 +348,7 @@ private void deliverabilityWatchedDomainMetric() throws SparkPostException, IOEx
351348
String orderBy = null;
352349
String limit = null;
353350

354-
RestConnection connection = new RestConnection(this.client, getEndPoint());
351+
RestConnection connection = new RestConnection(client, getEndPoint());
355352
DeliverabiltyMetricsResponse response = ResourceMetrics
356353
.getDeliverabilityMetricsByWatchedDomain(connection, from, to, domains, campaigns, templates, metrics, timezone, orderBy, limit);
357354

@@ -369,7 +366,7 @@ private void deliverabilityWatchedDomainMetric() throws SparkPostException, IOEx
369366
* See: https://developers.sparkpost.com/api/#/reference/metrics/time-series/time-series-metrics
370367
*/
371368
private void deliverabilityTimeSeriesMetrics(String precision) throws SparkPostException, IOException {
372-
this.client = this.newConfiguredClient();
369+
Client client = this.newConfiguredClient();
373370

374371
String from = FROM_DATE;
375372
String to = null;
@@ -381,7 +378,7 @@ private void deliverabilityTimeSeriesMetrics(String precision) throws SparkPostE
381378
String metrics = MetricsFields.ALL_FIELDS;
382379
String timezone = null;
383380

384-
RestConnection connection = new RestConnection(this.client, getEndPoint());
381+
RestConnection connection = new RestConnection(client, getEndPoint());
385382
DeliverabiltyMetricsResponse response = ResourceMetrics
386383
.getTimeSeriesMetrics(connection, from, to, domains, campaigns, templates, precision, metrics, timezone);
387384

@@ -400,7 +397,7 @@ private void deliverabilityTimeSeriesMetrics(String precision) throws SparkPostE
400397
* See: https://developers.sparkpost.com/api/#/reference/metrics/time-series/bounce-reason-metrics
401398
*/
402399
private void deliverabilityBounceReasonMetrics() throws SparkPostException, IOException {
403-
this.client = this.newConfiguredClient();
400+
Client client = this.newConfiguredClient();
404401

405402
String from = FROM_DATE;
406403
String to = null;
@@ -413,7 +410,7 @@ private void deliverabilityBounceReasonMetrics() throws SparkPostException, IOEx
413410
String timezone = null;
414411
String limit = null;
415412

416-
RestConnection connection = new RestConnection(this.client, getEndPoint());
413+
RestConnection connection = new RestConnection(client, getEndPoint());
417414
DeliverabiltyMetricsResponse response = ResourceMetrics
418415
.getBounceReasonMetrics(connection, from, to, domains, campaigns, templates, metrics, timezone, limit);
419416

@@ -431,7 +428,7 @@ private void deliverabilityBounceReasonMetrics() throws SparkPostException, IOEx
431428
* See: https://developers.sparkpost.com/api/#/reference/metrics/bounce-reasons-by-domain/bounce-reason-metrics-by-domain
432429
*/
433430
private void deliverabilityBounceReasonByDomainMetrics() throws SparkPostException, IOException {
434-
this.client = this.newConfiguredClient();
431+
Client client = this.newConfiguredClient();
435432

436433
String from = FROM_DATE;
437434
String to = null;
@@ -444,7 +441,7 @@ private void deliverabilityBounceReasonByDomainMetrics() throws SparkPostExcepti
444441
String timezone = null;
445442
String limit = null;
446443

447-
RestConnection connection = new RestConnection(this.client, getEndPoint());
444+
RestConnection connection = new RestConnection(client, getEndPoint());
448445
DeliverabiltyMetricsResponse response = ResourceMetrics
449446
.getBounceReasonMetricsByDomain(connection, from, to, domains, campaigns, templates, metrics, timezone, limit);
450447

@@ -462,7 +459,7 @@ private void deliverabilityBounceReasonByDomainMetrics() throws SparkPostExcepti
462459
* See: https://developers.sparkpost.com/api/#/reference/metrics/bounce-reasons/bounce-classification-metrics
463460
*/
464461
private void deliverabilityBounceReasonByClassificationMetrics() throws SparkPostException, IOException {
465-
this.client = this.newConfiguredClient();
462+
Client client = this.newConfiguredClient();
466463

467464
String from = FROM_DATE;
468465
String to = null;
@@ -475,7 +472,7 @@ private void deliverabilityBounceReasonByClassificationMetrics() throws SparkPos
475472
String timezone = null;
476473
String limit = null;
477474

478-
RestConnection connection = new RestConnection(this.client, getEndPoint());
475+
RestConnection connection = new RestConnection(client, getEndPoint());
479476
DeliverabiltyMetricsResponse response = ResourceMetrics
480477
.getBounceClassificationMetrics(connection, from, to, domains, campaigns, templates, metrics, timezone, limit);
481478

@@ -493,7 +490,7 @@ private void deliverabilityBounceReasonByClassificationMetrics() throws SparkPos
493490
* See: https://developers.sparkpost.com/api/#/reference/metrics/rejection-reasons/rejection-reason-metrics
494491
*/
495492
private void deliverabilityRejectionMetrics() throws SparkPostException, IOException {
496-
this.client = this.newConfiguredClient();
493+
Client client = this.newConfiguredClient();
497494

498495
String from = FROM_DATE;
499496
String to = null;
@@ -505,7 +502,7 @@ private void deliverabilityRejectionMetrics() throws SparkPostException, IOExcep
505502
String timezone = null;
506503
String limit = null;
507504

508-
RestConnection connection = new RestConnection(this.client, getEndPoint());
505+
RestConnection connection = new RestConnection(client, getEndPoint());
509506
DeliverabiltyMetricsResponse response = ResourceMetrics.getRejectionReasonMetrics(connection, from, to, domains, campaigns, templates, timezone, limit);
510507

511508
List<Map<String, Object>> results = response.getResults();
@@ -522,7 +519,7 @@ private void deliverabilityRejectionMetrics() throws SparkPostException, IOExcep
522519
* See: https://developers.sparkpost.com/api/#/reference/metrics/bounce-classifications/rejection-reason-metrics-by-domain
523520
*/
524521
private void deliverabilityRejectionDomainMetrics() throws SparkPostException, IOException {
525-
this.client = this.newConfiguredClient();
522+
Client client = this.newConfiguredClient();
526523

527524
String from = FROM_DATE;
528525
String to = null;
@@ -534,7 +531,7 @@ private void deliverabilityRejectionDomainMetrics() throws SparkPostException, I
534531
String timezone = null;
535532
String limit = null;
536533

537-
RestConnection connection = new RestConnection(this.client, getEndPoint());
534+
RestConnection connection = new RestConnection(client, getEndPoint());
538535
DeliverabiltyMetricsResponse response = ResourceMetrics
539536
.getRejectionReasonMetricsByDomain(connection, from, to, domains, campaigns, templates, timezone, limit);
540537

@@ -552,7 +549,7 @@ private void deliverabilityRejectionDomainMetrics() throws SparkPostException, I
552549
* See: https://developers.sparkpost.com/api/#/reference/metrics/rejection-reasons-by-domain/delay-reason-metrics
553550
*/
554551
private void deliverabilityDelayMetrics() throws SparkPostException, IOException {
555-
this.client = this.newConfiguredClient();
552+
Client client = this.newConfiguredClient();
556553

557554
String from = FROM_DATE;
558555
String to = null;
@@ -564,7 +561,7 @@ private void deliverabilityDelayMetrics() throws SparkPostException, IOException
564561
String timezone = null;
565562
String limit = null;
566563

567-
RestConnection connection = new RestConnection(this.client, getEndPoint());
564+
RestConnection connection = new RestConnection(client, getEndPoint());
568565
DeliverabiltyMetricsResponse response = ResourceMetrics.getDelayReasonMetrics(connection, from, to, domains, campaigns, templates, timezone, limit);
569566

570567
List<Map<String, Object>> results = response.getResults();
@@ -581,7 +578,7 @@ private void deliverabilityDelayMetrics() throws SparkPostException, IOException
581578
* See: https://developers.sparkpost.com/api/#/reference/metrics/delay-reasons-by-domain/delay-reason-metrics-by-domain
582579
*/
583580
private void deliverabilityDelayDomainMetrics() throws SparkPostException, IOException {
584-
this.client = this.newConfiguredClient();
581+
Client client = this.newConfiguredClient();
585582

586583
String from = FROM_DATE;
587584
String to = null;
@@ -593,7 +590,7 @@ private void deliverabilityDelayDomainMetrics() throws SparkPostException, IOExc
593590
String timezone = null;
594591
String limit = null;
595592

596-
RestConnection connection = new RestConnection(this.client, getEndPoint());
593+
RestConnection connection = new RestConnection(client, getEndPoint());
597594
DeliverabiltyMetricsResponse response = ResourceMetrics
598595
.getDelayReasonMetricsByDomain(connection, from, to, domains, campaigns, templates, timezone, limit);
599596

@@ -611,7 +608,7 @@ private void deliverabilityDelayDomainMetrics() throws SparkPostException, IOExc
611608
* See: https://developers.sparkpost.com/api/#/reference/metrics/engagement-details/engagement-details
612609
*/
613610
private void deliverabilityEngagementMetrics() throws SparkPostException, IOException {
614-
this.client = this.newConfiguredClient();
611+
Client client = this.newConfiguredClient();
615612

616613
String from = FROM_DATE;
617614
String to = null;
@@ -623,7 +620,7 @@ private void deliverabilityEngagementMetrics() throws SparkPostException, IOExce
623620
String limit = null;
624621
String metrics = MetricsEngagementFields.ALL_FIELDS;
625622

626-
RestConnection connection = new RestConnection(this.client, getEndPoint());
623+
RestConnection connection = new RestConnection(client, getEndPoint());
627624
DeliverabiltyMetricsResponse response = ResourceMetrics.getEngagementDetails(connection, from, to, timezone, metrics, campaigns, templates, limit);
628625

629626
List<Map<String, Object>> results = response.getResults();
@@ -640,7 +637,7 @@ private void deliverabilityEngagementMetrics() throws SparkPostException, IOExce
640637
* See: https://developers.sparkpost.com/api/#/reference/metrics/deliveries-by-attempt
641638
*/
642639
private void deliverabilityDeliveriesMetrics() throws SparkPostException, IOException {
643-
this.client = this.newConfiguredClient();
640+
Client client = this.newConfiguredClient();
644641

645642
String from = FROM_DATE;
646643
String to = null;
@@ -649,7 +646,7 @@ private void deliverabilityDeliveriesMetrics() throws SparkPostException, IOExce
649646
String templates = null;
650647
String timezone = null;
651648

652-
RestConnection connection = new RestConnection(this.client, getEndPoint());
649+
RestConnection connection = new RestConnection(client, getEndPoint());
653650
DeliverabiltyMetricsResponse response = ResourceMetrics.getDeliveriesByAttempt(connection, from, to, domains, campaigns, templates, timezone);
654651

655652
List<Map<String, Object>> results = response.getResults();
@@ -662,12 +659,12 @@ private void deliverabilityDeliveriesMetrics() throws SparkPostException, IOExce
662659
}
663660

664661
private void deliverabilityCampaignListMetrics() throws SparkPostException, IOException {
665-
this.client = this.newConfiguredClient();
662+
Client client = this.newConfiguredClient();
666663

667664
String match = null;
668665
String limit = null;
669666

670-
RestConnection connection = new RestConnection(this.client, getEndPoint());
667+
RestConnection connection = new RestConnection(client, getEndPoint());
671668
CampaignListResponse response = ResourceMetrics.getCampaignsList(connection, match, limit);
672669

673670
List<String> results = response.getCampaignList();
@@ -679,12 +676,12 @@ private void deliverabilityCampaignListMetrics() throws SparkPostException, IOEx
679676
}
680677

681678
private void deliverabilityDomainListMetrics() throws SparkPostException, IOException {
682-
this.client = this.newConfiguredClient();
679+
Client client = this.newConfiguredClient();
683680

684681
String match = null;
685682
String limit = null;
686683

687-
RestConnection connection = new RestConnection(this.client, getEndPoint());
684+
RestConnection connection = new RestConnection(client, getEndPoint());
688685
DomainListResponse response = ResourceMetrics.getDomainsList(connection, match, limit);
689686

690687
List<String> results = response.getDomainList();

0 commit comments

Comments
 (0)