Class: Driftrock::Service::DriftrockModel::Channel
- Inherits:
-
Object
- Object
- Driftrock::Service::DriftrockModel::Channel
- Includes:
- Driftrock::Service::DriftrockModel
- Defined in:
- lib/driftrock-service/driftrock_model/channel.rb
Instance Attribute Summary collapse
-
#channel_type ⇒ Object
Returns the value of attribute channel_type.
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#next_step_action ⇒ Object
readonly
Returns the value of attribute next_step_action.
-
#profile_id ⇒ Object
readonly
Returns the value of attribute profile_id.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#token_expiry ⇒ Object
readonly
Returns the value of attribute token_expiry.
Class Method Summary collapse
- .channel_types ⇒ Object
- .create_by_channel_type(type_name, channel_data) ⇒ Object
- .find_by_channel_type_name(name) ⇒ Object
Instance Method Summary collapse
Methods included from Driftrock::Service::DriftrockModel
#get_from_api_method, included, #initialize, #post_to_api_method, #put_to_api_method
Instance Attribute Details
#channel_type ⇒ Object
Returns the value of attribute channel_type.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def channel_type @channel_type end |
#company ⇒ Object (readonly)
Returns the value of attribute company.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def company @company end |
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def expires_in @expires_in end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def id @id end |
#next_step_action ⇒ Object (readonly)
Returns the value of attribute next_step_action.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def next_step_action @next_step_action end |
#profile_id ⇒ Object (readonly)
Returns the value of attribute profile_id.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def profile_id @profile_id end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def refresh_token @refresh_token end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def token @token end |
#token_expiry ⇒ Object (readonly)
Returns the value of attribute token_expiry.
6 7 8 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 6 def token_expiry @token_expiry end |
Class Method Details
.channel_types ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 50 def self.channel_types object_arr = get_from_api_method.call( "/types" ) object_arr.map do |object_hash| ChannelType.new(object_hash) end end |
.create_by_channel_type(type_name, channel_data) ⇒ Object
37 38 39 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 37 def self.create_by_channel_type(type_name, channel_data) ChannelType.find_by_name(type_name).create_channel(channel_data) end |
.find_by_channel_type_name(name) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 41 def self.find_by_channel_type_name(name) object_hsh = get_from_api_method.call( "/#{name}" ) channel = new(object_hsh) channel.channel_type = ChannelType.find_by_name(name) channel end |
Instance Method Details
#has_profile? ⇒ Boolean
20 21 22 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 20 def has_profile? profile_id && !profile_id.strip.empty? end |
#set_profile_id(profile_id) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 11 def set_profile_id(profile_id) response = post_to_api_method.call( "/#{channel_type.name}/profile", {profile_id: profile_id} ) success = response['status'] == 'success' @profile_id = profile_id if success success end |
#update_token(token_data) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/driftrock-service/driftrock_model/channel.rb', line 24 def update_token(token_data) response = put_to_api_method.call( "/#{channel_type.name}/profile", token_data ) success = response['status'] == 'success' if success @token = token_data[:token] @token_expiry = token_data[:token_expiry] @expires_in = token_data[:expires_in] end success end |