diff --git a/lib/fcm.rb b/lib/fcm.rb index f3ad0b8..b4e8854 100644 --- a/lib/fcm.rb +++ b/lib/fcm.rb @@ -188,9 +188,7 @@ def send_to_topic(topic, options = {}) end def get_instance_id_info(iid_token, options = {}) - params = { - query: options, - } + params = options for_uri(INSTANCE_ID_API) do |connection| response = connection.get("/iid/info/" + iid_token, params) diff --git a/spec/fcm_spec.rb b/spec/fcm_spec.rb index 0d1afd1..fb1ee9e 100644 --- a/spec/fcm_spec.rb +++ b/spec/fcm_spec.rb @@ -499,6 +499,40 @@ # TODO end + describe 'getting instance info' do + subject(:get_info) { client.get_instance_id_info(registration_id, options) } + + let(:options) { nil } + let(:client) { FCM.new('TEST_SERVER_KEY') } + let(:base_uri) { "#{FCM::INSTANCE_ID_API}/iid/info" } + let(:uri) { "#{base_uri}/#{registration_id}" } + let(:mock_request_attributes) do + { headers: { + 'Authorization' => 'key=TEST_SERVER_KEY', + 'Content-Type' => 'application/json' + } } + end + + context 'without options' do + it 'calls info endpoint' do + endpoint = stub_request(:get, uri).with(mock_request_attributes) + get_info + expect(endpoint).to have_been_requested + end + end + + context 'with detail option' do + let(:uri) { "#{base_uri}/#{registration_id}?details=true" } + let(:options) { { details: true } } + + it 'calls info endpoint' do + endpoint = stub_request(:get, uri).with(mock_request_attributes) + get_info + expect(endpoint).to have_been_requested + end + end + end + describe "credentials path" do it "can be a path to a file" do fcm = FCM.new("test", "README.md")