Email
Register Email Channel
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
email_channel = UA::Email.new(client: airship)
email_channel.type = 'email'
email_channel.commercial_opted_in = '2018-10-28T10:34:22'
email_channel.address = 'new.name@new.domain.com'
email_channel.timezone = 'America/Los_Angeles'
email_channel.locale_country = 'US'
email_channel.locale_language = 'en'
email_channel.register
Note
The registration of an email channel should yield a 201 response. The address portion must be defined with an email address to register an email channel. There are a few more fields listed on the email object that can be set as well such as transactional_opted_in.
Uninstall Email Channel
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
email_channel = UA::Email.new(client: airship)
email_channel.address = 'new.name@new.domain.com'
email_channel.uninstall
Note
This will uninstall an existing email channel. Note that a valid email must be present to make the request.
Lookup Email Channel
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
email_channel = UA::Email.new(client: airship)
email_channel.address = 'new.name@new.domain.com'
email_channel.lookup
Update Email Channel
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
email_channel = UA::Email.new(client: airship)
email_channel.channel_id = '01234567-890a-bcde-f012-3456789abc0'
email_channel.type = 'email'
email_channel.commercial_opted_in = '2018-10-28T10:34:22'
email_channel.timezone = 'America/Los_Angeles'
email_channel.locale_country = 'US'
email_channel.locale_language = 'en'
email_channel.update
Note
The only thing required to make a request is the channel_id. However, anything that needs to be updated must also be included. Please note that you cannot update an email address with this method. Please use the replace method instead.
Replace Email Channel
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
email_channel = UA::Email.new(client: airship)
email_channel.channel_id = '01234567-890a-bcde-f012-3456789abc0'
email_channel.address = 'new.name@new.domain.com'
email_channel.type = 'email'
email_channel.commercial_opted_in = '2018-10-28T10:34:22'
email_channel.timezone = 'America/Los_Angeles'
email_channel.locale_country = 'US'
email_channel.locale_language = 'en'
email_channel.update
Note
This will replace an existing email channel and will do the following actions:
Register a new channel
Associate the new email channel with the same user as the source channel
Uninstall the source channel
Address, Channel ID and type are all required parameters for this method.