Class: Iterable::Device
- Inherits:
-
ApiResource
- Object
- ApiResource
- Iterable::Device
- Defined in:
- lib/iterable/device.rb
Overview
Interact with user device API endpoints
Constant Summary collapse
- PLATFORMS =
[ APNS = 'APNS'.freeze, APNS_SANDBOX = 'APNS_SANDBOX'.freeze, GCM = 'GCM'.freeze ].freeze
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#data_fields ⇒ Object
readonly
Returns the value of attribute data_fields.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes inherited from ApiResource
Instance Method Summary collapse
-
#initialize(token, app, platform, data_fields = {}, conf = nil) ⇒ Iterable::Device
constructor
Initialize an [Iterable::Device] to register for a user.
-
#register(email, user_id = nil) ⇒ Iterable::Response
Register a device for a user email or id.
Methods inherited from ApiResource
default_config, #default_config
Constructor Details
#initialize(token, app, platform, data_fields = {}, conf = nil) ⇒ Iterable::Device
Initialize an [Iterable::Device] to register for a user
34 35 36 37 38 39 40 |
# 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 |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
21 22 23 |
# File 'lib/iterable/device.rb', line 21 def app @app end |
#data_fields ⇒ Object (readonly)
Returns the value of attribute data_fields.
21 22 23 |
# File 'lib/iterable/device.rb', line 21 def data_fields @data_fields end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
21 22 23 |
# File 'lib/iterable/device.rb', line 21 def platform @platform end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
21 22 23 |
# File 'lib/iterable/device.rb', line 21 def token @token end |
Instance Method Details
#register(email, user_id = nil) ⇒ Iterable::Response
Register a device for a user email or id
50 51 52 53 54 55 56 57 |
# 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 |