Class: BranchIO::LinkProperties

Inherits:
Object
  • Object
show all
Defined in:
lib/branch_io/link_properties.rb

Defined Under Namespace

Classes: ErrorInvalidParameters

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ LinkProperties

Returns a new instance of LinkProperties.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/branch_io/link_properties.rb', line 21

def initialize(options={})
  @tags     = options.delete(:tags)     ||options.delete("tags")
  @channel  = options.delete(:channel)  || options.delete("channel")
  @feature  = options.delete(:feature)  || options.delete("feature")
  @campaign = options.delete(:campaign) || options.delete("campaign")
  @stage    = options.delete(:stage)    || options.delete("stage")
  @alias    = options.delete(:alias)    || options.delete("alias")
  @type     = options.delete(:type)     || options.delete("type")
  @data     = options.delete(:data)     || options.delete("data")

  unless options.empty?
    raise ErrorInvalidParameters.new(options.keys)
  end
end

Instance Attribute Details

#aliasObject (readonly)

Returns the value of attribute alias.



9
10
11
# File 'lib/branch_io/link_properties.rb', line 9

def alias
  @alias
end

#campaignObject (readonly)

Returns the value of attribute campaign.



7
8
9
# File 'lib/branch_io/link_properties.rb', line 7

def campaign
  @campaign
end

#channelObject (readonly)

Returns the value of attribute channel.



5
6
7
# File 'lib/branch_io/link_properties.rb', line 5

def channel
  @channel
end

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/branch_io/link_properties.rb', line 11

def data
  @data
end

#featureObject (readonly)

Returns the value of attribute feature.



6
7
8
# File 'lib/branch_io/link_properties.rb', line 6

def feature
  @feature
end

#stageObject (readonly)

Returns the value of attribute stage.



8
9
10
# File 'lib/branch_io/link_properties.rb', line 8

def stage
  @stage
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/branch_io/link_properties.rb', line 4

def tags
  @tags
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/branch_io/link_properties.rb', line 10

def type
  @type
end

Class Method Details

.wrap(options) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/branch_io/link_properties.rb', line 13

def self.wrap(options)
  if options.kind_of?(LinkProperties)
    options
  else
    new(options)
  end
end

Instance Method Details

#as_jsonObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/branch_io/link_properties.rb', line 36

def as_json
  json = {}
  json[:tags]     = tags if tags
  json[:channel]  = channel if channel
  json[:feature]  = feature if feature
  json[:campaign] = campaign if campaign
  json[:stage]    = stage if stage
  json[:alias]    = self.alias if self.alias
  json[:type]     = type if type
  json[:data]     = data if data
  json
end