Class: TwilioMock::Mocker
- Inherits:
-
Object
- Object
- TwilioMock::Mocker
- Defined in:
- lib/twilio_mock/mocker.rb
Direct Known Subclasses
Constant Summary collapse
- API_VERSION =
'2010-04-01'.freeze
- HOST =
'api.twilio.com'.freeze
Instance Method Summary collapse
- #available_number(number = nil, params = nil) ⇒ Object
- #buy_number(attrs) ⇒ Object
- #clean ⇒ Object
- #create_message(attrs) ⇒ Object
-
#initialize(username: Twilio.account_sid, token: Twilio.auth_token) ⇒ Mocker
constructor
A new instance of Mocker.
- #messages ⇒ Object
Constructor Details
Instance Method Details
#available_number(number = nil, params = nil) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/twilio_mock/mocker.rb', line 22 def available_number(number = nil, params = nil) query_string = params && params.any? ? Twilify.process(params).to_h.to_query : '' stub_request(:get, "#{base_twilio_url}/AvailablePhoneNumbers/US/Local.json?#{query_string}") .with(basic_auth: basic_auth) .to_return(status: 200, body: available_number_response(number), headers: {}) end |
#buy_number(attrs) ⇒ Object
29 30 31 |
# File 'lib/twilio_mock/mocker.rb', line 29 def buy_number(attrs) prepare_stub(attrs, 'IncomingPhoneNumbers.json') end |
#clean ⇒ Object
37 38 39 40 |
# File 'lib/twilio_mock/mocker.rb', line 37 def clean number_generator.clean .clean end |
#create_message(attrs) ⇒ Object
17 18 19 20 |
# File 'lib/twilio_mock/mocker.rb', line 17 def (attrs) .add OpenStruct.new(attrs) prepare_stub(attrs, 'Messages.json') end |
#messages ⇒ Object
33 34 35 |
# File 'lib/twilio_mock/mocker.rb', line 33 def . end |