Ejemplo n.º 1
0
        public SendCodeResponse Send(SendCodeRequest sendCode)
        {
            this.ValidatedAndParseFields(sendCode);

            StringBuilder verifyRequestUrl = new StringBuilder("/verify");

            if (this.IsResend)
            {
                verifyRequestUrl.Append("/resend");
            }
            else
            {
                verifyRequestUrl.Append("/req");
            }

            if (this.Channel == Channel.Sms)
            {
                verifyRequestUrl.Append("/sms");
            }

            string responseStr      = this.ApiRequest.Post(verifyRequestUrl.ToString(), this.parameters);
            var    sendCodeResponse = (SendCodeResponse)ResponseFactory.CreateObjectfromRawResponse <SendCodeResponse>(responseStr)
                                      .SetRawResponse(this.ApiRequest.RawResponse);

            sendCodeResponse.Client = this;

            return(sendCodeResponse);
        }
Ejemplo n.º 2
0
        public void ResendThroughResponseObjectTest()
        {
            var apiRequestMock = new ApiRequest(
                TestingUtils.GetMockHttpClient((HttpRequestMessage httpRequest) =>
            {
                var dictBody = TestingUtils.RewindBody(httpRequest.Content);
                Assert.AreEqual("CPASS_restapi_C0000002737000000.0002", dictBody["mocean-reqid"]);
                Assert.AreEqual(HttpMethod.Post, httpRequest.Method);
                Assert.AreEqual(TestingUtils.GetTestUri("/verify/resend/sms"), httpRequest.RequestUri.LocalPath);
                return(TestingUtils.GetResponse("resend_code.json"));
            })
                );

            var mocean           = TestingUtils.GetClientObj(apiRequestMock);
            var sendCodeResponse = (SendCodeResponse)ResponseFactory.CreateObjectfromRawResponse <SendCodeResponse>(TestingUtils.ReadFile("resend_code.json"))
                                   .SetRawResponse(TestingUtils.ReadFile("resend_code.json"));

            sendCodeResponse.Client = mocean.SendCode;

            var resendCodeResponse = sendCodeResponse.Resend();

            Assert.AreEqual(resendCodeResponse.Status, "0");
            Assert.AreEqual(resendCodeResponse.ReqId, "CPASS_restapi_C0000002737000000.0002");
            Assert.AreEqual(resendCodeResponse.To, "60123456789");
            Assert.AreEqual(resendCodeResponse.ResendNumber, "1");
        }
Ejemplo n.º 3
0
        public CommandResponse Execute(CommandRequest command)
        {
            this.ValidatedAndParseFields(command);
            string responseStr = this.ApiRequest.Post("/send-message", this.parameters);

            return((CommandResponse)ResponseFactory.CreateObjectfromRawResponse <CommandResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 4
0
        public VoiceResponse Call(VoiceRequest voice)
        {
            this.ValidatedAndParseFields(voice);

            string responseStr = this.ApiRequest.Post("/voice/dial", this.parameters);

            return((VoiceResponse)ResponseFactory.CreateObjectfromRawResponse <VoiceResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 5
0
        public MessageStatusResponse Inquiry(MessageStatusRequest messageStatusRequest)
        {
            this.ValidatedAndParseFields(messageStatusRequest);

            string responseStr = this.ApiRequest.Get("/report/message", this.parameters);

            return((MessageStatusResponse)ResponseFactory.CreateObjectfromRawResponse <MessageStatusResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 6
0
        public BalanceResponse Inquiry(BalanceRequest balance = default(BalanceRequest))
        {
            this.ValidatedAndParseFields(balance);

            string responseStr = this.ApiRequest.Get("/account/balance", this.parameters);

            return((BalanceResponse)ResponseFactory.CreateObjectfromRawResponse <BalanceResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 7
0
        public SmsResponse Send(SmsRequest sms)
        {
            this.ValidatedAndParseFields(sms);

            string responseStr = this.ApiRequest.Post("/sms", this.parameters);

            return((SmsResponse)ResponseFactory.CreateObjectfromRawResponse <SmsResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 8
0
        public PricingResponse Inquiry(PricingRequest pricing = default(PricingRequest))
        {
            this.ValidatedAndParseFields(pricing);

            string responseStr = this.ApiRequest.Get("/account/pricing", this.parameters);

            return((PricingResponse)ResponseFactory.CreateObjectfromRawResponse <PricingResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 9
0
        public NumberLookupResponse Inquiry(NumberLookupRequest numberLookup)
        {
            this.ValidatedAndParseFields(numberLookup);

            string responseStr = this.ApiRequest.Post("/nl", this.parameters);

            return((NumberLookupResponse)ResponseFactory.CreateObjectfromRawResponse <NumberLookupResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 10
0
        public VerifyCodeResponse Send(VerifyCodeRequest verifyCode)
        {
            this.ValidatedAndParseFields(verifyCode);

            string responseStr = this.ApiRequest.Post("/verify/check", this.parameters);

            return((VerifyCodeResponse)ResponseFactory.CreateObjectfromRawResponse <VerifyCodeResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }
Ejemplo n.º 11
0
        public HangupResponse Hangup(string callUuid)
        {
            this.requiredFields = new List <string> {
                "mocean-api-key", "mocean-api-secret", "mocean-call-uuid"
            };

            this.parameters["mocean-call-uuid"] = callUuid;
            this.ValidatedAndParseFields();

            string responseStr = this.ApiRequest.Post("/voice/hangup", this.parameters);

            return((HangupResponse)ResponseFactory.CreateObjectfromRawResponse <HangupResponse>(responseStr)
                   .SetRawResponse(this.ApiRequest.RawResponse));
        }