Exemplo n.º 1
0
        /// <summary>
        /// 更改卡券信息接口
        /// 支持更新部分通用字段及特殊卡券(会员卡、飞机票、电影票、红包)中特定字段的信息。
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="cardType">卡券种类,会员卡、飞机票、电影票、红包中的一种</param>
        /// <param name="data">创建卡券需要的数据,格式可以看CardUpdateData.cs</param>
        /// <param name="cardId"></param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static WxJsonResult CardUpdate(string accessTokenOrAppId, CardType cardType, object data, string cardId = null, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var urlFormat = string.Format("https://api.weixin.qq.com/card/update?access_token={0}", accessToken);

                BaseCardUpdateInfo cardData = null;

                switch (cardType)
                {
                case CardType.MEMBER_CARD:
                    cardData = new CardUpdate_MemberCard()
                    {
                        card_id = cardId,
                        member_card = data as Card_MemberCardUpdateData
                    };
                    break;

                case CardType.BOARDING_PASS:
                    cardData = new CardUpdate_BoardingPass()
                    {
                        card_id = cardId,
                        boarding_pass = data as Card_BoardingPassData
                    };
                    break;

                case CardType.MOVIE_TICKET:
                    cardData = new CardUpdate_MovieTicket()
                    {
                        card_id = cardId,
                        movie_ticket = data as Card_MovieTicketData
                    };
                    break;

                case CardType.SCENIC_TICKET:
                    cardData = new CardUpdate_ScenicTicket()
                    {
                        card_id = cardId,
                        scenic_ticket = data as Card_ScenicTicketData
                    };
                    break;

                default:
                    break;
                }

                return CommonJsonSend.Send <WxJsonResult>(null, urlFormat, cardData, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更改卡券信息接口
        /// 支持更新部分通用字段及特殊卡券(会员卡、飞机票、电影票、红包)中特定字段的信息。
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="cardType">卡券种类,会员卡、飞机票、电影票、红包中的一种</param>
        /// <param name="data">创建卡券需要的数据,格式可以看CardUpdateData.cs</param>
        /// <param name="cardId"></param>
        /// <returns></returns>
        public static WxJsonResult CardUpdate(string accessToken,CardType cardType, object data, string cardId = null)
        {
            var urlFormat = string.Format("https://api.weixin.qq.com/card/update?access_token={0}", accessToken);

            BaseCardUpdateInfo cardData = null;

            switch (cardType)
            {
                case CardType.MEMBER_CARD:
                    cardData = new CardUpdate_MemberCard()
                    {
                        card_id = cardId,
                        member_card = data as Card_MemberCardUpdateData
                    };
                    break;
                case CardType.BOARDING_PASS:
                    cardData = new CardUpdate_BoardingPass()
                    {
                        card_id = cardId,
                        boarding_pass = data as Card_BoardingPassData
                    };
                    break;
                case CardType.MOVIE_TICKET:
                    cardData = new CardUpdate_MovieTicket()
                    {
                        card_id = cardId,
                        movie_ticket = data as Card_MovieTicketData
                    };
                    break;
                case CardType.SCENIC_TICKET:
                    cardData = new CardUpdate_ScenicTicket()
                    {
                        card_id = cardId,
                        scenic_ticket = data as Card_ScenicTicketData
                    };
                    break;
                default:
                    break;
            }

            return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, cardData);
        }