// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificate = GetGiftCertificateByOidCall(); // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // ReSharper disable once MemberCanBePrivate.Global public static GiftCertificate GetGiftCertificateByOidCall() { var api = new GiftCertificateApi(Constants.API_KEY); const int giftCertificateOid = 676713; // by_oid does not take an expansion variable. it will return the entire object by default. var gcResponse = api.GetGiftCertificateByOid(giftCertificateOid); return(gcResponse.GiftCertificate); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificates = GetGiftCertificatesByEmailCall(); // Utility.DumpObject(giftCertificates, "Gift Certificates"); // foreach (var gc in giftCertificates) // { // Utility.DumpObject(gc, "Gift Certificate"); // } // // } // ReSharper disable once MemberCanBePrivate.Global public static List <GiftCertificate> GetGiftCertificatesByEmailCall() { var api = new GiftCertificateApi(Constants.API_KEY); const string email = "*****@*****.**"; // by_email does not take an expansion variable. it will return the entire object by default. var gcResponse = api.GetGiftCertificatesByEmail(email); return(gcResponse.GiftCertificates); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificate = GetGiftCertificateByCodeCall(); // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // ReSharper disable once MemberCanBePrivate.Global public static GiftCertificate GetGiftCertificateByCodeCall() { var api = new GiftCertificateApi(Constants.API_KEY); const string code = "X8PV761V2Z"; // by_code does not take an expansion variable. it will return the entire object by default. var gcResponse = api.GetGiftCertificateByCode(code); return(gcResponse.GiftCertificate); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificate = DeleteGiftCertificateCall(); // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // ReSharper disable once MemberCanBePrivate.Global public static GiftCertificate DeleteGiftCertificateCall() { var api = new GiftCertificateApi(Constants.API_KEY); const int giftCertificateOid = 676713; api.DeleteGiftCertificate(giftCertificateOid); // if I re-query the gift certificate after deleting, I will still get an object back, but the // deleted flag on the object will be true. // by_oid does not take an expansion variable. it will return the entire object by default. var gcResponse = api.GetGiftCertificateByOid(giftCertificateOid); return(gcResponse.GiftCertificate); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificate = UpdateGiftCertificateCall(); // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // ReSharper disable once MemberCanBePrivate.Global public static GiftCertificate UpdateGiftCertificateCall() { var api = new GiftCertificateApi(Constants.API_KEY); const int giftCertificateOid = 676713; var gcResponse = api.GetGiftCertificateByOid(giftCertificateOid); var giftCertificate = gcResponse.GiftCertificate; giftCertificate.Email = "*****@*****.**"; // update does not take an expansion variable. it will return the entire object by default. gcResponse = api.UpdateGiftCertificate(giftCertificateOid, giftCertificate); return(gcResponse.GiftCertificate); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificates = GetGiftCertificateByQueryCall(); // foreach (var giftCertificate in giftCertificates) // { // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // } private static List <GiftCertificate> GetGiftCertificateChunk(GiftCertificateApi api, int offset, int limit) { const string expansion = "ledger"; // leaving query empty, so no filtering, and I should get all records returned. GiftCertificateQuery query = new GiftCertificateQuery(); var gcResponse = api.GetGiftCertificatesByQuery(query, limit, offset, null, null, expansion); if (gcResponse.Success == true && gcResponse.GiftCertificates != null) { return(gcResponse.GiftCertificates); } return(new List <GiftCertificate>()); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificate = CreateGiftCertificateCall(); // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // ReSharper disable once MemberCanBePrivate.Global public static GiftCertificate CreateGiftCertificateCall() { var api = new GiftCertificateApi(Constants.API_KEY); GiftCertificateCreateRequest createRequest = new GiftCertificateCreateRequest() { Amount = new Decimal(200.00), InitialLedgerDescription = "Created via C# SDK", MerchantNote = "Internal comment here", Email = "*****@*****.**", ExpirationDts = DateTime.UtcNow.AddMonths(3).ToString("s", System.Globalization.CultureInfo.InvariantCulture) }; // create does not take an expansion variable. it will return the entire object by default. var gcResponse = api.CreateGiftCertificate(createRequest); return(gcResponse.GiftCertificate); }
// uncomment to run. C# projects can only have one main. // public static void Main() // { // var giftCertificate = AddGiftCertificateLedgerEntryCall(); // Utility.DumpObject(giftCertificate, "Gift Certificate"); // } // ReSharper disable once MemberCanBePrivate.Global public static GiftCertificate AddGiftCertificateLedgerEntryCall() { var api = new GiftCertificateApi(Constants.API_KEY); const int giftCertificateOid = 676713; GiftCertificateLedgerEntry ledgerEntry = new GiftCertificateLedgerEntry() { Amount = new Decimal(-15.35), // this is the change amount in the gift certificate. this is not a balance. it will be subtracted from it. Description = "Customer bought something over the counter using this gift certificate.", EntryDts = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture), GiftCertificateLedgerOid = 0, // the system will assign an oid. do not assign one here. GiftCertificateOid = giftCertificateOid, // this is an existing gift certificate oid. I created it using createGiftCertificate.ts ReferenceOrderId = "BLAH-12345" // if this ledger entry is related to an order, add it here, else use null. }; // add ledger entry does not take an expansion variable. it will return the entire object by default. var gcResponse = api.AddGiftCertificateLedgerEntry(giftCertificateOid, ledgerEntry); return(gcResponse.GiftCertificate); }
// ReSharper disable once MemberCanBePrivate.Global public static List <GiftCertificate> GetGiftCertificateByQueryCall() { var api = new GiftCertificateApi(Constants.API_KEY); List <GiftCertificate> giftCertificates = new List <GiftCertificate>(); var iteration = 1; var offset = 0; var limit = 200; var moreRecordsToFetch = true; while (moreRecordsToFetch) { System.Console.WriteLine("executing iteration " + iteration); var chuckOfCertificates = GetGiftCertificateChunk(api, offset, limit); giftCertificates.AddRange(chuckOfCertificates); offset += limit; moreRecordsToFetch = chuckOfCertificates.Count == limit; iteration++; } return(giftCertificates); }