## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true require 'spec_helper.rb' describe 'PublicKey' do it "can read" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.accounts.v1.credentials \ .public_key.list() }.to raise_exception(Twilio::REST::TwilioError) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'get', url: 'https://accounts.twilio.com/v1/Credentials/PublicKeys', ))).to eq(true) end it "receives read_empty responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "credentials": [], "meta": { "first_page_url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0", "key": "credentials", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0" } } ] )) actual = @client.accounts.v1.credentials \ .public_key.list() expect(actual).to_not eq(nil) end it "receives read_full responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "credentials": [ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ], "meta": { "first_page_url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0", "key": "credentials", "next_page_url": null, "page": 0, "page_size": 50, "previous_page_url": null, "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0" } } ] )) actual = @client.accounts.v1.credentials \ .public_key.list() expect(actual).to_not eq(nil) end it "can create" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.accounts.v1.credentials \ .public_key.create(public_key: 'publickey') }.to raise_exception(Twilio::REST::TwilioError) values = {'PublicKey' => 'publickey', } expect( @holodeck.has_request?(Holodeck::Request.new( method: 'post', url: 'https://accounts.twilio.com/v1/Credentials/PublicKeys', data: values, ))).to eq(true) end it "receives create responses" do @holodeck.mock(Twilio::Response.new( 201, %q[ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] )) actual = @client.accounts.v1.credentials \ .public_key.create(public_key: 'publickey') expect(actual).to_not eq(nil) end it "can fetch" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.accounts.v1.credentials \ .public_key('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() }.to raise_exception(Twilio::REST::TwilioError) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'get', url: 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', ))).to eq(true) end it "receives fetch responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] )) actual = @client.accounts.v1.credentials \ .public_key('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch() expect(actual).to_not eq(nil) end it "can update" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.accounts.v1.credentials \ .public_key('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() }.to raise_exception(Twilio::REST::TwilioError) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'post', url: 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', ))).to eq(true) end it "receives update responses" do @holodeck.mock(Twilio::Response.new( 200, %q[ { "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "date_created": "2015-07-31T04:00:00Z", "date_updated": "2015-07-31T04:00:00Z", "friendly_name": "friendly_name", "sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } ] )) actual = @client.accounts.v1.credentials \ .public_key('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update() expect(actual).to_not eq(nil) end it "can delete" do @holodeck.mock(Twilio::Response.new(500, '')) expect { @client.accounts.v1.credentials \ .public_key('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() }.to raise_exception(Twilio::REST::TwilioError) values = {} expect( @holodeck.has_request?(Holodeck::Request.new( method: 'delete', url: 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', ))).to eq(true) end it "receives delete responses" do @holodeck.mock(Twilio::Response.new( 204, nil, )) actual = @client.accounts.v1.credentials \ .public_key('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').delete() expect(actual).to eq(true) end end