diff --git a/lib/twilio-ruby/framework/domain.rb b/lib/twilio-ruby/framework/domain.rb index c9a242dd7..17f7290ad 100644 --- a/lib/twilio-ruby/framework/domain.rb +++ b/lib/twilio-ruby/framework/domain.rb @@ -31,6 +31,10 @@ def request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeo timeout ) end + + def as_json(*) + @properties + end end end end diff --git a/spec/framework/domain_spec.rb b/spec/framework/domain_spec.rb new file mode 100644 index 000000000..14bef46f3 --- /dev/null +++ b/spec/framework/domain_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' +require 'logger' + +describe Twilio::REST::Domain do + class MyOtherDomain < Twilio::REST::Domain + def initialize(client) + # Marshaled Properties + @properties = { + 'account_sid' => "RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + 'auth_token' => "ABC1234", + 'url' => "http://www.example.com", + } + end + end + + describe '#as_json' do + before do + @domain = MyOtherDomain.new(@client) + @json = @domain.as_json + end + + it 'converts the objects properties to json' do + expect(@json["account_sid"]).to eq("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") + expect(@json["auth_token"]).to eq("ABC1234") + expect(@json["url"]).to eq("http://www.example.com") + end + end +end