Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push docstrings updates #420

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ably/rest/push/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(push)

# Publish a push message directly to a single recipient
#
# @param recipient [Hash] A recipient device, client_id or raw APNS/GCM target. Refer to push documentation
# @param recipient [Hash] A recipient device, client_id or raw APNS/FCM/web target. Refer to push documentation
# @param data [Hash] The notification payload data and fields. Refer to push documentation
#
# @return [void]
Expand Down
35 changes: 20 additions & 15 deletions spec/acceptance/rest/push_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registration_token: 'secret_token',
}
}
Expand Down Expand Up @@ -250,7 +250,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registration_token: 'secret_token',
}
}
Expand All @@ -268,15 +268,15 @@
expect(device).to be_a(Ably::Models::DeviceDetails)
expect(device.platform).to eql('ios')
expect(device.client_id).to eql(client_id)
expect(device.push.recipient.fetch(:transport_type)).to eql('gcm')
expect(device.push.recipient.fetch(:transport_type)).to eql('fcm')
end

it 'returns a DeviceDetails object if a DeviceDetails object is provided' do
device = subject.get(Ably::Models::DeviceDetails.new(id: "device-#{client_id}-1"))
expect(device).to be_a(Ably::Models::DeviceDetails)
expect(device.platform).to eql('ios')
expect(device.client_id).to eql(client_id)
expect(device.push.recipient.fetch(:transport_type)).to eql('gcm')
expect(device.push.recipient.fetch(:transport_type)).to eql('fcm')
end

it 'raises a ResourceMissing exception if device ID does not exist' do
Expand Down Expand Up @@ -350,37 +350,41 @@
expect(device_retrieved.push.recipient['foo_bar']).to eql('string')
end

context 'with GCM target' do
context 'with FCM target' do
let(:device_token) { random_str }

it 'saves the associated DevicePushDetails' do
subject.save(device_details.merge(
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registrationToken: device_token
}
}
))

device_retrieved = subject.get(device_details.fetch(:id))

expect(device_retrieved.push.recipient.fetch('transportType')).to eql('gcm')
expect(device_retrieved.push.recipient.fetch('transportType')).to eql('fcm')
expect(device_retrieved.push.recipient[:registration_token]).to eql(device_token)
end
end

context 'with web target' do
let(:target_url) { 'http://foo.com/bar' }
let(:encryption_key) { random_str }
let(:p256dh) { random_str }
let(:auth) { random_str }

it 'saves the associated DevicePushDetails' do
subject.save(device_details.merge(
push: {
recipient: {
transport_type: 'web',
targetUrl: target_url,
encryptionKey: encryption_key
encryptionKey: {
p256dh: p256dh,
auth: auth
}
}
}
))
Expand All @@ -389,7 +393,8 @@

expect(device_retrieved.push.recipient[:transport_type]).to eql('web')
expect(device_retrieved.push.recipient['targetUrl']).to eql(target_url)
expect(device_retrieved.push.recipient['encryptionKey']).to eql(encryption_key)
expect(device_retrieved.push.recipient['encryptionKey']['p256dh']).to eql(p256dh)
expect(device_retrieved.push.recipient['encryptionKey']['auth']).to eql(auth)
end
end

Expand Down Expand Up @@ -462,7 +467,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registrationToken: 'secret_token',
}
}
Expand All @@ -476,7 +481,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registration_token: 'secret_token',
}
}
Expand Down Expand Up @@ -525,7 +530,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registration_token: 'secret_token',
}
}
Expand All @@ -539,7 +544,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registration_token: 'secret_token',
}
}
Expand Down Expand Up @@ -580,7 +585,7 @@
client_id: client_id,
push: {
recipient: {
transport_type: 'gcm',
transport_type: 'fcm',
registration_token: 'secret_token',
}
}
Expand Down
Loading