Exemple #1
0
        /// <summary>
        /// Add an album restriction to a coupon
        /// </summary>
        /// <param name="CouponAlbum">A specific album</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
        public async Task <bool> AddRestrictionAsync(Album CouponAlbum, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], CouponID [required], AlbumID [required], Callback, Extras, Pretty, Strict
            var resp = await ch.ExecuteMethod <CouponResponse>("smugmug.coupons.restrictions.albums.add", basic, "CouponID", this.id, "AlbumID", CouponAlbum.id, "Extras", Extras);

            if (resp.stat == "ok")
            {
                if (this.Restrictions == null)
                {
                    this.Restrictions = new Restrictions();
                }
                if (this.Restrictions.Albums == null)
                {
                    this.Restrictions.Albums = new List <Album>();
                }
                this.Restrictions.Albums.Add(CouponAlbum);
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #2
0
        /// <summary>
        /// Get the request Token from SmugMug
        /// </summary>
        public Token GetRequestToken()
        {
            CommunicationHelper ch = new CommunicationHelper();
            var auth = ch.ExecuteMethod <GetTokenResponse>("smugmug.auth.getRequestToken", null).Result;

            return(auth.Auth.Token);
        }
Exemple #3
0
        /// <summary>
        /// Get the request Token from SmugMug
        /// </summary>
        public async Task <Token> GetRequestTokenAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            var auth = await ch.ExecuteMethod <GetTokenResponse>("smugmug.auth.getRequestToken", null);

            return(auth.Auth.Token);
        }
Exemple #4
0
        /// <summary>
        /// Retrieves a list of subcategories within a specified category for a given user
        /// </summary>
        /// <param name="Associative">Returns an associative array.Default: false.</param>
        /// <param name="SitePassword">The site password for a specific user</param>
        /// <returns>List of SubCategories (id, Name, NiceName)</returns>
        public async Task <List <SubCategory> > GetSubCategoriesAsync(bool Associative, string SitePassword)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], CategoryID [required], Associative, Callback, NickName, Pretty, SitePassword, Strict
            var resp = await ch.ExecuteMethod <SubCategoryResponse>("smugmug.subcategories.get", basic, "NickName", basic.NickName, "CategoryID", id, "Associative", Associative, "SitePassword", SitePassword);

            if (resp.stat == "ok")
            {
                var subCategoryList = new List <SubCategory>();
                subCategoryList.AddRange(resp.SubCategories);
                if (subCategoryList != null)
                {
                    foreach (var item in subCategoryList)
                    {
                        item.basic = basic;
                        // Add the Category for this Subcategory, as it's not returned
                        item.Category = this;
                    }
                }
                return(subCategoryList);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #5
0
        /// <summary>
        /// Modify an existing coupon and request the return of certain attributes
        /// (the coupon must be modified locally first - except if the only change is in Restrictions).
        /// </summary>
        /// <param name="AlbumIDs">A comma separated string of AlbumIDs to restrict the coupon</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response. (can be empty)</param>
        /// <returns>True if the request completed successfully</returns>
        public async Task <bool> ModifyAsync(string AlbumIDs, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], CouponID [required], AlbumIDs (string), Callback, Code, Description, Discount, Enabled, Extras,
            // International, MaxDiscount, MaxUses, MinPurchase, Pretty, Shipping, Strict, Title, ValidFrom, ValidTo
            var ls   = BuildPropertiesValueList(this, "Restrictions", "Status", "Type", "Uses");
            var resp = await ch.ExecuteMethod <CouponResponse>("smugmug.coupons.modify", basic, "AlbumIDs", AlbumIDs, ls.ToArray());

            if (resp.stat == "ok")
            {
                var tempCoupon = resp.Coupon;
                if (tempCoupon != null)
                {
                    if (this.id != tempCoupon.id)
                    {
                        this.id = tempCoupon.id;
                    }
                }
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #6
0
        /// <summary>
        /// Get the access Token from SmugMug
        /// </summary>
        public async Task <Token> GetAccessTokenAsync(Token requestToken)
        {
            CommunicationHelper ch      = new CommunicationHelper();
            SmugMugBase         session = new SmugMugBase();

            session.AccessToken = requestToken;

            var auth = await ch.ExecuteMethod <GetTokenResponse>("smugmug.auth.getAccessToken", session, "oauth_token_secret", requestToken.Secret);

            return(auth.Auth.Token);
        }
Exemple #7
0
        /// <summary>
        /// Updates specific settings (Dissolve, ImageID, Location, Name) for the current printmark. If any of the parameters are missing or are empty strings "", they're ignored and the current settings are preserved. Otherwise, they're updated with the new settings.
        /// </summary>
        /// <param name="Name">The name for the printmark</param>
        /// <param name="Location">The location of the printmark on the target image. Values: TopLeft, TopRight, BottomLeft, BottomRight, Top, Bottom</param>
        /// <param name="Dissolve">The opacity of the printmark on the target image. Min: 0. Max: 100</param>
        /// <param name="ImageID">The id for a specific image</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response.</param>
        /// <returns>Returns an empty successful response, if it completes without error</returns>
        public async Task <bool> ModifyAsync(string Dissolve, string ImageID, string Location, string Name, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], PrintmarkID [required], Callback, Dissolve, Extras, ImageID, Location, Name, Pretty, Strict
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.printmarks.modify", basic, "PrintmarkID", this.id, "Dissolve", Dissolve, "Extras", Extras, "ImageID", ImageID, "Location", Location, "Name", Name);

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #8
0
        /// <summary>
        /// Populate the current printmark with info from the site  (id, Name, Dissolve, Image struct - id, key; Location)
        /// </summary>
        /// <returns></returns>
        public async Task PopulatePrintmarkWithInfoFromSiteAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], PrintmarkID [required], Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <PrintmarkResponse>("smugmug.printmarks.getInfo", basic, "PrintmarkID", id);

            if (resp.stat == "ok")
            {
                PopulateWithResponse(resp.Printmark, this);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #9
0
        /// <summary>
        /// Pings SmugMug
        /// </summary>
        /// <returns>Returns an empty successful response, if it completes without error.</returns>
        public async Task <bool> PingAsync()
        {
            // APIKey [required], Callback, Pretty
            CommunicationHelper ch = new CommunicationHelper();
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.service.ping", null);

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
        /// <summary>
        /// Deletes an existing subcategory
        /// </summary>
        /// <returns></returns>
        public bool Delete()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], SubCategoryID [required], Callback, Pretty, Strict
            var resp = ch.ExecuteMethod <SmugMugResponse>("smugmug.subcategories.delete", basic, "SubCategoryID", id);

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #11
0
        /// <summary>
        /// Deletes  a specified sharegroup
        /// </summary>
        /// <returns>Returns an empty successful response, if it completes without error</returns>
        public async Task <bool> DeleteAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupID [required], Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.sharegroups.delete", basic, "ShareGroupID", id);

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #12
0
        /// <summary>
        /// Populate the current sharegroup with info from the site  (id, Tag, AccessPassworded, AlbumCount, Albums array - id, key, Title; Description, Name, Password, PasswordHint, Passworded, URL)
        /// </summary>
        /// <param name="Password">The password for the sharegroup</param>
        /// <param name="ShareGroupTag">The tag (public id) for the sharegroup</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
        public async Task PopulateShareGroupWithInfoFromSiteAsync(string Password, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupID [required], Callback, Extras, Password, Pretty, SharegroupTag, Strict
            var resp = await ch.ExecuteMethod <ShareGroupResponse>("smugmug.sharegroups.getInfo", basic, "ShareGroupID", id, "Password", Password, "ShareGroupTag", this.Tag, "Extras", Extras);

            if (resp.stat == "ok")
            {
                PopulateWithResponse(resp.ShareGroup, this);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #13
0
        /// <summary>
        /// Updates specific settings (Dissolve, ImageID, Location, Name) for a the current sharegroup. If any of the parameters are missing or are empty strings "", they're ignored and the current settings are preserved. Otherwise, they're updated with the new settings.
        /// </summary>
        /// <param name="AccessPassworded">Allow access to password protected albums from the sharegroup without the password. Default: false.</param>
        /// <param name="Description">The description for the sharegroup</param>
        /// <param name="Name">The name for the sharegroup</param>
        /// <param name="Password">The password for the sharegroup</param>
        /// <param name="PasswordHint">The password hint for the sharegroup</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
        /// <returns>Returns an empty successful response, if it completes without error</returns>
        public async Task <bool> ModifyAsync(bool AccessPassworded, string Description, string Name, string Password, string PasswordHint, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupID [required], AccessPassworded, Callback, Description, Extras, Name, Password, PasswordHint, Pretty, Strict
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.sharegroups.modify", basic, "AccessPassworded", AccessPassworded, "Description", Description, "Extras", Extras, "Name", Name, "Password", Password, "PasswordHint", PasswordHint);

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #14
0
        /// <summary>
        /// Renames an existing category with the given name
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Extras">A comma seperated string of additional attributes to return in the response.</param>
        /// <returns></returns>
        public async Task <bool> RenameAsync(string Name, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], CategoryID [required], Callback, Extras, Pretty, Strict, Name
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.categories.rename", basic, "CategoryID", id, "Name", Name, "Extras", Extras);

            if (resp.stat == "ok")
            {
                this.Name = Name;
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #15
0
        /// <summary>
        /// Retrieve information for a printmark.
        /// </summary>
        /// <returns>New printmark object (id, Name, Dissolve, Image struct - id, key; Location)</returns>
        public async Task <Printmark> GetInfoAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], PrintmarkID [required], Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <PrintmarkResponse>("smugmug.printmarks.getInfo", basic, "PrintmarkID", id);

            if (resp.stat == "ok")
            {
                var myPrintmark = resp.Printmark;
                myPrintmark.basic = basic;
                return(myPrintmark);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
        /// <summary>
        /// Retrieves the information for a watermark (Name, Dissolve, Image (id, Key), Pinned, Thumbs)
        /// </summary>
        /// <returns>Watermark with id, Name, Dissolve, Image (id, Key), Pinned, Thumbs</returns>
        public Watermark GetInfo()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], WatermarkID [required], Callback, Pretty, Strict
            var resp = ch.ExecuteMethod <WatermarkResponse>("smugmug.watermarks.getInfo", basic, "WatermarkID", id);

            if (resp.stat == "ok")
            {
                var myWatermark = resp.Watermark;
                myWatermark.basic = basic;
                return(myWatermark);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
        /// <summary>
        /// Renames an existing subcategory with the given name
        /// </summary>
        /// <param name="Name">The name for the subcategory</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
        /// <returns>Bool (actually returns a SubCategory object with id)</returns>
        public bool Rename(string Name, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], SubCategoryID [required], Name [required], Callback, Extras, Pretty, Strict
            var resp = ch.ExecuteMethod <SubCategoryResponse>("smugmug.subcategories.rename", basic, "SubCategoryID", id, "Name", Name, "Extras", Extras);

            if (resp.stat == "ok")
            {
                // If the rename works, change the name of the current object as well
                this.Name = Name;
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #18
0
        /// <summary>
        /// Retrieves a list of style templates
        /// </summary>
        /// <param name="Associative">Returns an associative array. Default: false </param>
        /// <returns>List of Templates (id and Name)</returns>
        public async Task <List <Template> > StylesGetTemplatesAsync(bool Associative)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // Associative, Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <TemplateResponse>("smugmug.styles.getTemplates", null, "Associative", Associative);

            if (resp.stat == "ok")
            {
                var temp = new List <Template>();
                temp.AddRange(resp.Templates);
                return(temp);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #19
0
        /// <summary>
        /// Retrieves a list of albums for a sharegroup (also populates the current sharegroup with this list)
        /// </summary>
        /// <param name="Associative">Returns an associative array. Default: false.</param>
        /// <param name="Password">The password for the sharegroup</param>
        /// <param name="Extras">A comma separated string of additional attributes to return in the response</param>
        /// <returns></returns>
        public async Task <List <Album> > GetAlbumsAsync(bool Associative, string Password, string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupTag [required], Associative, Callback, Extras, Password, Pretty, Strict
            var resp = await ch.ExecuteMethod <ShareGroupResponse>("smugmug.sharegroups.albums.get", basic, "ShareGroupTag", Tag, "Associative", Associative, "Password", Password, "Extras", Extras);

            if (resp.stat == "ok")
            {
                var shareGroupAlbums = resp.ShareGroup.Albums;
                if (shareGroupAlbums != null)
                {
                    foreach (var item in shareGroupAlbums)
                    {
                        bool flag = true;
                        item.basic = basic;
                        foreach (var myAlbum in this.Albums)
                        {
                            if (item.id == myAlbum.id)
                            {
                                flag = false;
                                break;
                            }
                        }
                        // Populate the current sharegroup with its albums from the site
                        if (flag)
                        {
                            if (this.Albums == null)
                            {
                                this.Albums = new List <Album>();
                            }
                            this.Albums.AddRange(shareGroupAlbums);
                        }
                    }
                    this.AlbumCount = shareGroupAlbums.Count;
                }

                return(shareGroupAlbums);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #20
0
        /// <summary>
        /// Check if the token is still valid.
        /// </summary>
        private oAuthUser CheckAccessToken(ref Token accessToken)
        {
            CommunicationHelper ch = new CommunicationHelper();
            var auth = ch.ExecuteMethod <GetTokenResponse>("smugmug.auth.checkAccessToken",
                                                           new SmugMugBase()
            {
                AccessToken = accessToken
            }, "oauth_token_secret", accessToken.Secret).Result;

            if (auth == null || auth.Auth == null)
            {
                return(null);
            }

            // Update the token
            accessToken = auth.Auth.Token;

            return(auth.Auth.User);
        }
Exemple #21
0
        /// <summary>
        /// Check if the token is still valid.
        /// </summary>
        private async Task <Tuple <oAuthUser, Token> > CheckAccessTokenAsync(Token accessToken)
        {
            CommunicationHelper ch = new CommunicationHelper();
            var auth = await ch.ExecuteMethod <GetTokenResponse>("smugmug.auth.checkAccessToken",
                                                                 new SmugMugBase()
            {
                AccessToken = accessToken
            }, "oauth_token_secret", accessToken.Secret);

            if (auth == null || auth.Auth == null)
            {
                return(null);
            }

            // Update the token
            accessToken = auth.Auth.Token;

            return(new Tuple <oAuthUser, Token>(auth.Auth.User, accessToken));
        }
Exemple #22
0
        /// <summary>
        /// Modifies an existing album template
        /// </summary>
        /// <returns></returns>
        public async Task <bool> ChangeSettingsAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], AlbumTemplateID [required], Callback, Pretty, Strict, AlbumTemplateName, Backprinting, CanRank, Clean, Comments, CommunityID, DefaultColor (deprecated), EXIF, External, FamilyEdit, FriendEdit, Geography, Header, HideOwner, InterceptShipping, Larges, Originals, PackagingBranding, Password, PasswordHint, Printable, ProofDays, Protected, Public, Share, SmugSearchable, SortDirection, SortMethod, SquareThumbs, UnsharpAmount, UnsharpRadius, UnsharpSigma, UnsharpThreshold, WatermarkID, Watermarking, WordSearchable, X2Larges, X3Larges, XLarges
            var ls = BuildPropertiesValueList(this);

            ls.Add("AlbumTemplateID"); ls.Add(this.id.ToString());
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.albumtemplates.changeSettings", basic, ls.ToArray());

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #23
0
        /// <summary>
        /// Changes the settings of a watermark (Callback, Dissolve, ImageID, Name, Pinned, Pretty, Strict, Thumbs)
        /// </summary>
        /// <param name="Extras">A comma seperated string of additional attributes to return in the response.</param>
        /// <returns></returns>
        public async Task <bool> ChangeSettingsAsync(string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], WatermarkID [required], Callback, Dissolve, Extras, ImageID, Name, Pinned, Pretty, Strict, Thumbs
            var ls = BuildPropertiesValueList(this, "Image");

            ls.Add("WatermarkID"); ls.Add(this.id.ToString());
            ls.Add("Extras"); ls.Add(Extras);
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.watermarks.changeSettings", basic, ls.ToArray());

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #24
0
        /// <summary>
        /// Update on SmugMug a sharegroup modified locally (AccessPassworded, Description, Name, Password, PasswordHint). If any of the parameters are missing or are empty strings "", they're ignored and the current settings are preserved. Otherwise, they're updated with the new settings.
        /// </summary>
        public async Task <bool> ModifyAsync(string Extras)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupID [required], AccessPassworded, Callback, Description, Extras, Name, Password, PasswordHint, Pretty, Strict
            var ls = BuildPropertiesValueList(this, "id", "Tag", "AlbumCount", "Albums", "Passworded", "URL");

            ls.Add("ShareGroupID"); ls.Add(this.id.ToString());
            ls.Add("Extras"); ls.Add(Extras);
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.sharegroups.modify", basic, ls.ToArray());

            if (resp.stat == "ok")
            {
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #25
0
        /// <summary>
        /// Creates a new album template with the specified parameters (SessionID [required], AlbumTemplateName [required], Callback, Pretty, Strict, Backprinting, CanRank, Clean, ColorCorrection, Comments, CommunityID, DefaultColor, EXIF, External, FamilyEdit, FriendEdit, Geography, Header, HideOwner, InterceptShipping, Larges, Originals, PackagingBranding, Password, PasswordHint, Printable, ProofDays, Protected, Public, Share, SmugSearchable, SortDirection, SquareThumbs, UnsharpAmount, UnsharpRadius, UnsharpSigma, UnsharpThreshold, WatermarkID, Watermarking, WordSearchable, X2Larges, X3Larges, XLarges)
        /// </summary>
        /// <returns>AlbumTemplate (id and AlbumTemplateName)</returns>
        internal async Task <AlbumTemplate> CreateAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], AlbumTemplateName [required], Callback, Pretty, Strict, Backprinting, CanRank, Clean, ColorCorrection, Comments, CommunityID, DefaultColor, EXIF, External, FamilyEdit, FriendEdit, Geography, Header, HideOwner, Larges, Originals, Password, PasswordHint, Printable, ProofDays, Protected, Public, Share, SmugSearchable, SortDirection, SortMethod, SquareThumbs, UnsharpAmount, UnsharpRadius, UnsharpSigma, UnsharpThreshold, WatermarkID, Watermarking, WordSearchable, X2Larges, X3Larges, XLarges
            var ls   = BuildPropertiesValueList(this, "id", "Filenames", "Position");
            var resp = await ch.ExecuteMethod <AlbumTemplateResponse>("smugmug.albumtemplates.create", basic, ls.ToArray());

            if (resp.stat == "ok")
            {
                var myAlbumTemplate = resp.AlbumTemplate;
                myAlbumTemplate.basic             = basic;
                myAlbumTemplate.AlbumTemplateName = this.AlbumTemplateName;
                return(myAlbumTemplate);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #26
0
        /// <summary>
        /// Retrieve information for a coupon
        /// </summary>
        public async Task <bool> GetInfoAsync()
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], CouponID [required], Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <CouponResponse>("smugmug.coupons.getInfo", basic, "CouponID", this.id);

            if (resp.stat == "ok")
            {
                if (resp.Coupon != null)
                {
                    resp.Coupon.basic = basic;
                    PopulateWithResponse(resp.Coupon, this);
                }
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #27
0
        /// <summary>
        /// Removes an album from a specified sharegroup
        /// </summary>
        /// <param name="AlbumToRemove">Album to be removed from the sharegroup</param>
        /// <returns></returns>
        public async Task <bool> RemoveAlbumAsync(Album AlbumToRemove)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupID [required], AlbumID [required], Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.sharegroups.albums.remove", basic, "ShareGroupID", id, "AlbumID", AlbumToRemove.id);

            if (resp.stat == "ok")
            {
                if (this.Albums != null)
                {
                    // Remove the album from this sharegroup
                    this.Albums.Remove(AlbumToRemove);
                    // Decrease the no of albums this sharegroup has
                    this.AlbumCount--;
                }
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }
Exemple #28
0
        /// <summary>
        /// Creates a new subcategory with the given name for the specified category (also adds it as a subcategory to the current object)
        /// </summary>
        /// <param name="Name">The name for the subcategory</param>
        /// <param name="Unique">Create a subcategory if one of the same name doesn't already exist in the current hierarchy. Default: false</param>
        /// <param name="Extras">A comma seperated string of additional attributes to return in the response.</param>
        /// <returns>SubCategory (id)</returns>
        public async Task <SubCategory> CreateSubCategoryAsync(string Name, bool Unique, string Extras)
        {
            var mySubCategory = await this.FindSubCategoryAsync(Name);

            if (mySubCategory == null)
            {
                CommunicationHelper ch = new CommunicationHelper();
                // SessionID [required], CategoryID [required], Name [required], Callback, Extras, Pretty, Strict, Unique
                var resp = await ch.ExecuteMethod <SubCategoryResponse>("smugmug.subcategories.create", basic, "Name", Name, "CategoryID", this.id, "Unique", Unique, "Extras", Extras);

                if (resp.stat == "ok")
                {
                    var returnedSubCategory = resp.SubCategory;
                    if (returnedSubCategory != null)
                    {
                        returnedSubCategory.basic    = basic;
                        returnedSubCategory.Name     = Name;
                        returnedSubCategory.Category = this;
                        if (this.SubCategories == null)
                        {
                            this.SubCategories = new List <SubCategory>();
                        }
                        this.SubCategories.Add(returnedSubCategory);
                    }
                    return(returnedSubCategory);
                }
                else
                {
                    Console.WriteLine(resp.message);
                    throw new SmugMugException(resp.code, resp.message, resp.method);
                }
            }
            else
            {
                return(mySubCategory);
            }
        }
Exemple #29
0
        /// <summary>
        /// Adds an album to a specified sharegroup
        /// </summary>
        /// <param name="AlbumToAdd">Album to be added to the sharegroup.</param>
        /// <returns></returns>
        public async Task <bool> AddAlbumAsync(Album AlbumToAdd)
        {
            CommunicationHelper ch = new CommunicationHelper();
            // SessionID [required], ShareGroupID [required], AlbumID [required], Callback, Pretty, Strict
            var resp = await ch.ExecuteMethod <SmugMugResponse>("smugmug.sharegroups.albums.add", basic, "ShareGroupID", this.id, "AlbumID", AlbumToAdd.id);

            if (resp.stat == "ok")
            {
                if (this.Albums == null)
                {
                    this.Albums = new List <Album>();
                }
                // Add the album to the current object
                this.Albums.Add(AlbumToAdd);
                // Increase the no of albums this sharegroup has
                this.AlbumCount++;
                return(true);
            }
            else
            {
                Console.WriteLine(resp.message);
                throw new SmugMugException(resp.code, resp.message, resp.method);
            }
        }