Class: GCM::SuccessfulConnection

Inherits:
Object
  • Object
show all
Includes:
TokenSerializer
Defined in:
lib/mercurius/testing/gcm/successful_connection.rb

Instance Method Summary collapse

Methods included from TokenSerializer

#canonical_token_json, #invalid_token_json, #valid_token_json

Instance Method Details

#write(json) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mercurius/testing/gcm/successful_connection.rb', line 5

def write(json)
  tokens = json[:registration_ids]

  json = {
    'multicast_id' => '123',
    'success' => tokens.size,
    'failure' => 0,
    'canonical_ids' => 0,
    'results' => tokens.map { |token| valid_token_json(token) }
  }.to_json

  Mercurius::FakeResponse.new body: json, status: 200
end