Inheritance: MonoBehaviour
Beispiel #1
0
        public void should_be_able_to_parse_button_response()
        {
            var json = @"{
   ""success"":true,
   ""button"":{
      ""code"":""39b2d09f2bf9c88f113aa6fecb13d258"",
      ""type"":""buy_now"",
      ""style"":""custom_large"",
      ""text"":""Pay With Bitcoin"",
      ""name"":""Order Name"",
      ""description"":""Order Description"",
      ""custom"":""Custom_Order_Id"",
      ""callback_url"":""http://www.bitarmory.com/callback"",
      ""success_url"":""http://www.bitarmory.com/success"",
      ""cancel_url"":""http://www.bitarmory.com/cancel"",
      ""info_url"":""http://www.bitarmory.com/info"",
      ""price"":{
         ""cents"":7999,
         ""currency_iso"":""USD""
      },
      ""variable_price"":false,
      ""choose_price"":false,
      ""include_address"":false,
      ""include_email"":false
   }
}";
            var obj  = JsonConvert.DeserializeObject <ButtonResponse>(json);

            obj.Should().NotBeNull();

            var truth = new ButtonResponse()
            {
                Success = true,
                Button  = new ButtonCreated()
                {
                    Code        = "39b2d09f2bf9c88f113aa6fecb13d258",
                    Type        = ButtonType.BuyNow,
                    Style       = ButtonStyle.CustomLarge,
                    Text        = "Pay With Bitcoin",
                    Name        = "Order Name",
                    Description = "Order Description",
                    Custom      = "Custom_Order_Id",
                    CallbackUrl = "http://www.bitarmory.com/callback",
                    SuccessUrl  = "http://www.bitarmory.com/success",
                    CancelUrl   = "http://www.bitarmory.com/cancel",
                    InfoUrl     = "http://www.bitarmory.com/info",
                    Price       = new Price
                    {
                        Cents    = 7999,
                        Currency = Currency.USD
                    },
                    VariablePrice  = false,
                    ChoosePrice    = false,
                    IncludeAddress = false,
                    IncludeEmail   = false
                }
            };

            obj.ShouldBeEquivalentTo(truth);
        }
Beispiel #2
0
 public ButtonPlus(int x, int y, int normalID, int pressedID, int buttonID, string name, ButtonResponse callback)
     : base(x, y, normalID, pressedID, buttonID, GumpButtonType.Reply, 0)
 {
     this._Name = name;
     this._Callback = callback;
     this._Param = null;
 }
Beispiel #3
0
        /// <summary>
        /// 转换为按钮
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        private ButtonInfo ToButton(ButtonResponse dto)
        {
            var result = new ButtonInfo
            {
                Id     = dto.Id,
                Code   = dto.Code,
                Text   = dto.Name,
                Icon   = dto.Icon,
                SortId = dto.SortId
            };

            return(result);
        }
Beispiel #4
0
        public static Button CreatePaymentButton(
            Button button,
            APIKey apiKey
            )
        {
            ButtonResponse buttonResponse = (ButtonResponse)PostResource(
                "buttons",
                button,
                typeof(Button),
                typeof(ButtonResponse),
                apiKey
                );

            return(buttonResponse.Button);
        }
        public async Task <bool> TryResponse(SocketMessage msg)
        {
            ButtonResponse BR;
            await _locker.WaitAsync().ConfigureAwait(false);

            try
            {
                if (msg == null || msg.Author.IsBot || msg.Channel.Id != Game.Channel)
                {
                    return(false);
                }

                int response = ResponseParse(msg.Content);
                if (response == -1)
                {
                    return(false);
                }

                var usr = msg.Author as IGuildUser;
                if (usr == null)
                {
                    return(false);
                }

                BR = new ButtonResponse()
                {
                    UserID = msg.Author.Id,
                    Pushed = Convert.ToBoolean(response)
                };

                if (Game.Responses.Any(x => x.UserID == msg.Author.Id))
                {
                    return(false);
                }

                if (!Game.Responses.Add(BR))
                {
                    return(false);
                }

                var _ = OnResponse?.Invoke(msg as IUserMessage, usr);
            }
            finally { _locker.Release(); }
            return(true);
        }
Beispiel #6
0
        /// <summary>
        /// Authenticated resource which lets you generate an order associated with a button. After generating an order, you can send bitcoin to the address associated with the order to complete the order. The status of this newly created order will be ‘new’.
        /// </summary>
        public OrderResponse CreateOrder(ButtonResponse response)
        {
            var code = response.Button.Code;

            var client = CreateClient();

            var post = CreateRequest("buttons/{code}/create_order")
                       .AddUrlSegment("code", code);

            var resp = client.Execute <OrderResponse>(post);

            if (resp.ErrorException != null)
            {
                throw resp.ErrorException;
            }

            return(resp.Data);
        }
Beispiel #7
0
        public ModalUI SetCancelButtonResponse(ButtonResponse cancelResponse)
        {
            cancelButtonResponse = cancelResponse;

            return(this);
        }
Beispiel #8
0
        public ModalUI SetOKButtonResponse(ButtonResponse okResponse)
        {
            okButtonResponse = okResponse;

            return(this);
        }