// GET (one)

        public Attachment GetAttachmentFor <TModel>(TModel model)
            where TModel : ModelBase, IAttachmentParent
        {
            // List the attachments against this model.
            var modelItemId = ModelTypeHelper.GetModelItemId(model);

            var allAttachmentsXml = _integrationProxy.FindAttachments(typeof(TModel).Name, modelItemId);

            var allAttachments = ModelSerializer.DeserializeTo <Response>(allAttachmentsXml).Attachments;

            if (allAttachments == null || allAttachments.Count == 0)
            {
                return(null);
            }

            var theFirstAttachment = allAttachments.First();

            // Get the attachment content
            var content = _integrationProxy.FindOneAttachment(
                typeof(TModel).Name,
                modelItemId,
                theFirstAttachment.AttachmentID.ToString());

            return(theFirstAttachment.WithContent(content));
        }
        public Attachment Create <TModel>(TModel model, Attachment attachment)
            where TModel : ModelBase, IAttachmentParent
        {
            string xml = _integrationProxy.CreateAttachment(
                typeof(TModel).Name,
                ModelTypeHelper.GetModelItemId(model),
                attachment);

            return(ModelSerializer.DeserializeTo <Response>(xml).Attachments.First());
        }