Class: SmartlistPushApi::User
- Inherits:
-
Object
- Object
- SmartlistPushApi::User
- Defined in:
- lib/smartlist_push_api/user.rb
Class Method Summary collapse
- .canceled_subscription(user_id, plan_name, canceled_at) ⇒ Object
- .create(data) ⇒ Object
- .destroy(user_id) ⇒ Object
- .downgraded_subscription(user_id, from_plan, to_plan, conversion_at) ⇒ Object
- .signed_in(user_id, date) ⇒ Object
- .started_subscription(user_id, plan_name, started_at) ⇒ Object
- .update(user_id, data) ⇒ Object
- .upgraded_subscription(user_id, from_plan, to_plan, conversion_at) ⇒ Object
Class Method Details
.canceled_subscription(user_id, plan_name, canceled_at) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/smartlist_push_api/user.rb', line 27 def self.canceled_subscription(user_id, plan_name, canceled_at) raise InvalidDataException if plan_name.blank? raise InvalidDataException if canceled_at.blank? SmartlistPushApi.make_post_request("/users/#{user_id}/subscription/", { type: :canceled, plan_name: plan_name, event_at: canceled_at.utc.strftime('%Y-%m-%d %H:%M:%S') }) end |
.create(data) ⇒ Object
4 5 6 |
# File 'lib/smartlist_push_api/user.rb', line 4 def self.create(data) SmartlistPushApi.make_post_request('/users/', data) end |
.destroy(user_id) ⇒ Object
12 13 14 |
# File 'lib/smartlist_push_api/user.rb', line 12 def self.destroy(user_id) SmartlistPushApi.make_delete_request("/users/#{user_id}/") end |
.downgraded_subscription(user_id, from_plan, to_plan, conversion_at) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/smartlist_push_api/user.rb', line 51 def self.downgraded_subscription(user_id, from_plan, to_plan, conversion_at) raise InvalidDataException if from_plan.blank? raise InvalidDataException if to_plan.blank? raise InvalidDataException if conversion_at.blank? SmartlistPushApi.make_post_request("/users/#{user_id}/subscription/", { type: :downgraded, plan_name: to_plan, from_plan: from_plan, event_at: conversion_at.utc.strftime('%Y-%m-%d %H:%M:%S') }) end |
.signed_in(user_id, date) ⇒ Object
64 65 66 67 68 |
# File 'lib/smartlist_push_api/user.rb', line 64 def self.signed_in(user_id, date) raise InvalidDataException if date.blank? SmartlistPushApi.make_post_request("/users/#{user_id}/login/", {date: date.utc.strftime('%Y-%m-%d %H:%M:%S')}) end |
.started_subscription(user_id, plan_name, started_at) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/smartlist_push_api/user.rb', line 16 def self.started_subscription(user_id, plan_name, started_at) raise InvalidDataException if plan_name.blank? raise InvalidDataException if started_at.blank? SmartlistPushApi.make_post_request("/users/#{user_id}/subscription/", { type: :signed_up, plan_name: plan_name, event_at: started_at.utc.strftime('%Y-%m-%d %H:%M:%S') }) end |
.update(user_id, data) ⇒ Object
8 9 10 |
# File 'lib/smartlist_push_api/user.rb', line 8 def self.update(user_id, data) SmartlistPushApi.make_patch_request("/users/#{user_id}/", data) end |
.upgraded_subscription(user_id, from_plan, to_plan, conversion_at) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/smartlist_push_api/user.rb', line 38 def self.upgraded_subscription(user_id, from_plan, to_plan, conversion_at) raise InvalidDataException if from_plan.blank? raise InvalidDataException if to_plan.blank? raise InvalidDataException if conversion_at.blank? SmartlistPushApi.make_post_request("/users/#{user_id}/subscription/", { type: :upgraded, plan_name: to_plan, from_plan: from_plan, event_at: conversion_at.utc.strftime('%Y-%m-%d %H:%M:%S') }) end |