Class: Twilio::REST::Preview::TrustedComms::BusinessContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/trusted_comms/business.rb,
lib/twilio-ruby/rest/preview/trusted_comms/business/brand.rb,
lib/twilio-ruby/rest/preview/trusted_comms/business/insights.rb,
lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb,
lib/twilio-ruby/rest/preview/trusted_comms/business/insights/impressions_rate.rb,
lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Defined Under Namespace

Classes: BrandContext, BrandInstance, BrandList, BrandPage, InsightsInstance, InsightsList, InsightsPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ BusinessContext

Initialize the BusinessContext



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/twilio-ruby/rest/preview/trusted_comms/business.rb', line 74

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {sid: sid, }
  @uri = "/Businesses/#{@solution[:sid]}"

  # Dependents
  @brands = nil
  @insights = nil
end

Instance Method Details

#brands(sid = :unset) ⇒ BrandList, BrandContext

Access the brands

Raises:

  • (ArgumentError)


99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/twilio-ruby/rest/preview/trusted_comms/business.rb', line 99

def brands(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return BrandContext.new(@version, @solution[:sid], sid, )
  end

  unless @brands
    @brands = BrandList.new(@version, business_sid: @solution[:sid], )
  end

  @brands
end

#fetchBusinessInstance

Fetch the BusinessInstance



89
90
91
92
93
# File 'lib/twilio-ruby/rest/preview/trusted_comms/business.rb', line 89

def fetch
  payload = @version.fetch('GET', @uri)

  BusinessInstance.new(@version, payload, sid: @solution[:sid], )
end

#insightsInsightsList, InsightsContext

Access the insights



117
118
119
120
121
122
123
# File 'lib/twilio-ruby/rest/preview/trusted_comms/business.rb', line 117

def insights
  unless @insights
    @insights = InsightsList.new(@version, business_sid: @solution[:sid], )
  end

  @insights
end

#inspectObject

Provide a detailed, user friendly representation



134
135
136
137
# File 'lib/twilio-ruby/rest/preview/trusted_comms/business.rb', line 134

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Preview.TrustedComms.BusinessContext #{context}>"
end

#to_sObject

Provide a user friendly representation



127
128
129
130
# File 'lib/twilio-ruby/rest/preview/trusted_comms/business.rb', line 127

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Preview.TrustedComms.BusinessContext #{context}>"
end