class Iterable::Device
Interact with user device API endpoints
@example Creating device endpoint object
# With default config campaigns = Iterable::Device.new 'token', 'app-name', Iterable::Device::APNS campaigns.all # With custom config conf = Iterable::Device.new(token: 'new-token') campaigns = Iterable::Device.new('token', 'app-name', Iterable::Device::APNS, config)
Constants
- PLATFORMS
Attributes
app[R]
data_fields[R]
platform[R]
token[R]
Public Class Methods
new(token, app, platform, data_fields = {}, conf = nil)
click to toggle source
Initialize an [Iterable::Device] to register for a user
@param token [String] The device token @param app [String] The application name for mobile push @param platform [String] The device device platform; one of [Iterable::Device::PLATFORMS] @param data_fields
[Hash] Additional device data fields @param conf [Iterable::Config] A config to optionally pass for requests
@return [Iterable::Device]
Calls superclass method
Iterable::ApiResource::new
# File lib/iterable/device.rb, line 34 def initialize(token, app, platform, data_fields = {}, conf = nil) @token = token @app = app @platform = platform @data_fields = data_fields super conf end
Public Instance Methods
register(email, user_id = nil)
click to toggle source
Register a device for a user email or id
@param email [String] Email
of user to associate device with @param user_id [String] User ID to associate device with instead of email
@return [Iterable::Response] A response object
# File lib/iterable/device.rb, line 50 def register(email, user_id = nil) attrs = { device: device_data } attrs[:email] = email if email attrs[:userId] = user_id if user_id Iterable.request(conf, base_path).post(attrs) end
Private Instance Methods
base_path()
click to toggle source
# File lib/iterable/device.rb, line 61 def base_path '/users/registerDeviceToken' end
device_data()
click to toggle source
# File lib/iterable/device.rb, line 65 def device_data { token: @token, applicationName: @app, platform: @platform, dataFields: @data_fields } end