Class: Fryfro::App

Inherits:
Object
  • Object
show all
Defined in:
lib/fryfro/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ App

Returns a new instance of App.



5
6
7
8
9
10
11
12
13
14
# File 'lib/fryfro/app.rb', line 5

def initialize(opts = {})
  # Mandatory
  @access_code = opts[:access_code] or raise ArgumentError, 'Provide an apiAccessCode'
  @key         = opts[:key]         or raise ArgumentError, 'Provide an apiKey'

  # Optional
  @name       = opts[:name]
  @platform   = opts[:platform]
  @created_at = opts[:created_at]
end

Instance Attribute Details

#access_codeObject (readonly)

Returns the value of attribute access_code.



3
4
5
# File 'lib/fryfro/app.rb', line 3

def access_code
  @access_code
end

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/fryfro/app.rb', line 3

def created_at
  @created_at
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/fryfro/app.rb', line 3

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/fryfro/app.rb', line 3

def name
  @name
end

#platformObject (readonly)

Returns the value of attribute platform.



3
4
5
# File 'lib/fryfro/app.rb', line 3

def platform
  @platform
end

Instance Method Details

#event(opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/fryfro/app.rb', line 31

def event(opts = {})
  raise ArgumentError, 'Provide an eventName' unless opts[:event_name] || opts['eventName']
  check_required_dates(opts)
  EventMetrics[:event].(@access_code, @key, opts)['eventMetrics']
end

#events(opts = {}) ⇒ Object



26
27
28
29
# File 'lib/fryfro/app.rb', line 26

def events(opts = {})
  check_required_dates(opts)
  EventMetrics[:summary].(@access_code, @key, opts)['eventMetrics']
end

#infoObject



16
17
18
# File 'lib/fryfro/app.rb', line 16

def info
  AppInfo[:get_application].(@access_code, @key)['appInfo']
end

#metric(metric, opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
# File 'lib/fryfro/app.rb', line 20

def metric(metric, opts = {})
  raise ArgumentError, 'Provide an eventName' unless metric
  check_required_dates(opts)
  AppMetrics[metric].(@access_code, @key, opts)['appMetrics']
end

#raw_data(opts = {}) ⇒ Object



37
38
39
40
41
# File 'lib/fryfro/app.rb', line 37

def raw_data(opts = {})
  check_params_overlap(opts)
  time_params?(opts) ? check_required_times(opts) : check_required_dates(opts)
  RawData[:events].(@access_code, @key, opts)
end