/// <summary>
        /// Iterate through the merchant report - fetches pages as necessary.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="filter">delegate mapping merchant record to a boolean. If false, the record is excluded from the report.</param>
        /// <param name="session"></param>
        /// <returns></returns>
        public static IEnumerable <Merchant> Report(MerchantsReportRequest request, Func <Merchant, bool> filter = null, ISession session = null)
        {
            if (session == null)
            {
                session = Globals.DefaultSession;
            }
            request.Page = 0;
            MerchantsPageResponse page;

            do
            {
                var response = MerchantsPage(request, session).GetAwaiter().GetResult();
                if (!response.Success)
                {
                    break;
                }
                page          = response.APIResponse;
                request.Page += 1;
                foreach (var t in page.Content)
                {
                    if (filter == null || (filter != null && filter(t)))
                    {
                        yield return(t);
                    }
                }
            } while (!page.LastPage);
        }
 /// <summary>
 /// Method to get a single page of the merchants report
 /// </summary>
 /// <param name="request"></param>
 /// <param name="session"></param>
 /// <returns></returns>
 public async static Task <ShippingApiResponse <MerchantsPageResponse> > MerchantsPage(MerchantsReportRequest request, ISession session = null)
 {
     if (session == null)
     {
         session = Globals.DefaultSession;
     }
     request.Authorization = new StringBuilder(session.AuthToken.AccessToken);
     return(await WebMethod.Get <MerchantsPageResponse, MerchantsReportRequest>("/v1/developers/{DeveloperId}/merchants", request, session));
 }
 /// <summary>
 /// Method to get a single page of the merchants report
 /// </summary>
 /// <param name="request"></param>
 /// <param name="session"></param>
 /// <returns></returns>
 public async static Task <ShippingApiResponse <MerchantsPageResponse> > MerchantsPage(MerchantsReportRequest request, ISession session = null)
 {
     if (session == null)
     {
         session = Globals.DefaultSession;
     }
     return(await WebMethod.Get <MerchantsPageResponse, MerchantsReportRequest>("/shippingservices/v1/developers/{DeveloperId}/merchants", request, session));
 }