Skip to content

Commit

Permalink
Removed BB things. Next will update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeyABedneyJr committed Sep 21, 2017
1 parent 88932bd commit 9739f61
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 226 deletions.
17 changes: 1 addition & 16 deletions docs/push.rst
Expand Up @@ -194,7 +194,7 @@ single piece of text:
You can override the notification payload with one of the following platform
keys::

ios, amazon, android, wns, mpns
ios, amazon, android, wns

In the examples below, we override the general ``'Hello World!'`` alert with
platform-specific alerts, and we set a number of other platform-specific options.
Expand Down Expand Up @@ -279,26 +279,11 @@ platform-specific alerts, and we set a number of other platform-specific options
)
)
**Example MPNS Override**

.. code-block:: ruby
push.notification = UA.notification(
alert: 'Hello World!',
mpns: UA.mpns_payload(
alert: 'Hello MPNS!',
tile: nil,
toast: nil,
badge: nil
)
)
.. note::
The input for wns_payload must include exactly one of
alert, toast, tile, or badge.

The input for mpns_payload must include exactly one of
alert, toast, or tile.

Actions
-------
Expand Down
1 change: 0 additions & 1 deletion lib/urbanairship/common.rb
Expand Up @@ -9,7 +9,6 @@ module Common
CHANNEL_URL = BASE_URL + '/channels/'
DEVICE_TOKEN_URL = BASE_URL + '/device_tokens/'
APID_URL = BASE_URL + '/apids/'
DEVICE_PIN_URL = BASE_URL + '/device_pins/'
PUSH_URL = BASE_URL + '/push/'
DT_FEEDBACK_URL = BASE_URL + '/device_tokens/feedback/'
APID_FEEDBACK_URL = BASE_URL + '/apids/feedback/'
Expand Down
53 changes: 0 additions & 53 deletions lib/urbanairship/devices/devicelist.rb
Expand Up @@ -125,58 +125,5 @@ def initialize(client: required('client'))
@data_attribute = 'apids'
end
end

class DevicePin
include Urbanairship::Common
include Urbanairship::Loggable

def initialize(client: required('client'))
@client = client
end

def lookup(pin: required('pin'))
fail ArgumentError, 'Device pin must be an 8 digit hex string' if pin[/\H/] or pin.length != 8
resp = @client.send_request(
method: 'GET',
url: DEVICE_PIN_URL + pin
)
logger.info("Retrieved info on device pin #{pin}")
resp
end

def register(pin: required('pin'), pin_alias: nil, tags: nil)
fail ArgumentError, 'Device pin must be an 8 digit hex string' if pin[/\H/] or pin.length != 8
payload = {}
payload['alias'] = pin_alias unless pin_alias.nil?
payload['tags'] = tags unless tags.nil?

resp = @client.send_request(
method: 'PUT',
url: DEVICE_PIN_URL + pin,
body: JSON.dump(payload),
content_type: 'application/json'
)
logger.info("Registered device pin #{pin}")
resp
end

def deactivate(pin: required('pin'))
fail ArgumentError, 'Device pin must be an 8 digit hex string' if pin[/\H/] or pin.length != 8
resp = @client.send_request(
method: 'DELETE',
url: DEVICE_PIN_URL + pin
)
logger.info("Deactivated device pin #{pin}")
resp
end
end

class DevicePinList < Urbanairship::Common::PageIterator
def initialize(client: required('client'))
super(client: client)
@next_page = DEVICE_PIN_URL
@data_attribute = 'device_pins'
end
end
end
end
11 changes: 0 additions & 11 deletions lib/urbanairship/push/payload.rb
Expand Up @@ -76,17 +76,6 @@ def wns_payload(alert: nil, toast: nil, tile: nil, badge: nil)
payload
end

# MPNS specific portion of Push Notification Object
def mpns_payload(alert: nil, toast: nil, tile: nil)
payload = compact_helper({
alert: alert,
toast: toast,
tile: tile
})
fail ArgumentError, 'Must specify one message type' if payload.size != 1
payload
end

# Rich Message specific portion of Push Notification Object
def message(title: required('title'), body: required('body'), content_type: nil, content_encoding: nil,
extra: nil, expiry: nil, icons: nil, options: nil)
Expand Down
120 changes: 0 additions & 120 deletions spec/lib/urbanairship/devices/device_info_spec.rb
Expand Up @@ -316,124 +316,4 @@
expect(instantiated_list.size).to eq(6)
end
end

describe Urbanairship::Devices::DevicePin do
include Urbanairship::Common
include Urbanairship::Loggable

device_pin = UA::DevicePin.new(client: airship)

describe '#lookup' do
it 'fails when a 7-digit hex string is given' do
expect {
device_pin.lookup(pin: '1234567')
}.to raise_error(ArgumentError)
end

it 'fails when a non-hex string is given' do
expect {
device_pin.lookup(pin: 'not hex')
}.to raise_error(ArgumentError)
end

it 'returns device pin information successfully' do
expected_resp = {
'body' => {
'device_pin' => '12345678',
'active' => true,
'alias' => 'user_id',
'tags' => ['tag1', 'tag2'],
'created' => '2015-08-01',
'last_registration' => '2015-08-01'
},
'code' => 200
}
allow(airship).to receive(:send_request).and_return(expected_resp)
actual_response = device_pin.lookup(pin: '12345678')
expect(actual_response).to eq(expected_resp)
end
end

describe '#register' do
it 'fails when a 7-digit hex string is given' do
expect {
device_pin.register(pin: '1234567')
}.to raise_error(ArgumentError)
end

it 'fails when a non-hex string is given' do
expect {
device_pin.register(pin: '1234568Z')
}.to raise_error(ArgumentError)
end

it 'registers a pin successfully' do
expected_resp = {
'body' => { 'ok' => true },
'code' => 200
}
allow(airship).to receive(:send_request).and_return(expected_resp)
actual_response = device_pin.register(pin: '12345678')
expect(actual_response).to eq(expected_resp)
end
end

describe '#deactivate' do
it 'fails when a 7-digit hex string is given' do
expect {
device_pin.deactivate(pin: '1234567')
}.to raise_error(ArgumentError)
end

it 'fails when a non-hex string is given' do
expect {
device_pin.deactivate(pin: '1234568Z')
}.to raise_error(ArgumentError)
end

it 'deactivates a pin successfully' do
expected_resp = {
'body' => {},
'code' => 204
}
allow(airship).to receive(:send_request).and_return(expected_resp)
actual_response = device_pin.deactivate(pin: '12345678')
expect(actual_response).to eq(expected_resp)
end
end
end

describe Urbanairship::Devices::DevicePinList do
device_pin_item = {
'device_pin' => '12345678',
'active' => true,
'alias' => 'user_id',
'tags' => ['tag1', 'tag2'],
'created' => '2015-08-01',
'last_registration' => '2015-08-01'
}
expected_resp = {
'body' => {
'device_pins' => [device_pin_item, device_pin_item, device_pin_item],
'next_page' => 'url'
},
'code' => 200
}
expected_next_resp = {
'body' => {
'device_pins' => [device_pin_item, device_pin_item, device_pin_item]
},
'code' => 200
}
it 'can iterate through the list' do
allow(airship).to receive(:send_request).and_return(expected_resp, expected_next_resp)
device_pin_list = UA::DevicePinList.new(client: airship)
instantiated_list = Array.new
device_pin_list.each do |pin|
expect(pin).to eq(device_pin_item)
instantiated_list.push(pin)
end
expect(instantiated_list.size).to eq(6)
end
end
end
25 changes: 0 additions & 25 deletions spec/lib/urbanairship/push/payload_spec.rb
Expand Up @@ -208,31 +208,6 @@
end
end


context 'MPNS' do
it 'can send a simple text "alert"' do
payload = UA.notification(mpns: UA.mpns_payload(alert: 'Hello'))
expect(payload).to eq mpns: { alert: 'Hello' }
end

it 'can send a key/value "toast"' do
payload = UA.notification(mpns: UA.mpns_payload(toast: { a_key: 'a_value' }))
expect(payload).to eq mpns: { toast: { a_key: 'a_value' } }
end

it 'can send a key/value "tile"' do
payload = UA.notification(mpns: UA.mpns_payload(tile: { a_key: 'a_value' }))
expect(payload).to eq mpns: { tile: { a_key: 'a_value' } }
end

it 'will only send one kind of notification at a time' do
expect {
UA.mpns_payload(alert: 'Hello', tile: 'Foo')
}.to raise_error ArgumentError
end
end


context 'Rich Push' do
it 'can send UTF-8 HTML' do
payload = UA.message(
Expand Down

0 comments on commit 9739f61

Please sign in to comment.