Class: Hockey::App

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

Overview

App on HockeyApp

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hashobj, networking) ⇒ App


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/hockeyhelper/app.rb', line 22

def initialize(hashobj, networking)
  @title = hashobj['title']
  @bundle_identifier = hashobj['bundle_identifier']
  @public_identifier = hashobj['public_identifier']
  @device_family = hashobj['device_family']
  @minimum_os_version = hashobj['minimum_os_version']
  @release_type = hashobj['release_type']
  @status = hashobj['status']
  @platform = hashobj['platform']
  @original_hash = hashobj
  @net = networking
  @users = nil
  @versions = nil
end

Instance Attribute Details

#bundle_identifierObject (readonly)

Returns the value of attribute bundle_identifier


7
8
9
# File 'lib/hockeyhelper/app.rb', line 7

def bundle_identifier
  @bundle_identifier
end

#device_familyObject (readonly)

Returns the value of attribute device_family


9
10
11
# File 'lib/hockeyhelper/app.rb', line 9

def device_family
  @device_family
end

#minimum_os_versionObject (readonly)

Returns the value of attribute minimum_os_version


10
11
12
# File 'lib/hockeyhelper/app.rb', line 10

def minimum_os_version
  @minimum_os_version
end

#netObject (readonly)

Returns the value of attribute net


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

def net
  @net
end

#original_hashObject (readonly)

Returns the value of attribute original_hash


14
15
16
# File 'lib/hockeyhelper/app.rb', line 14

def original_hash
  @original_hash
end

#platformObject (readonly)

Returns the value of attribute platform


13
14
15
# File 'lib/hockeyhelper/app.rb', line 13

def platform
  @platform
end

#public_identifierObject (readonly)

Returns the value of attribute public_identifier


8
9
10
# File 'lib/hockeyhelper/app.rb', line 8

def public_identifier
  @public_identifier
end

#release_typeObject (readonly)

Returns the value of attribute release_type


11
12
13
# File 'lib/hockeyhelper/app.rb', line 11

def release_type
  @release_type
end

#statusObject (readonly)

Returns the value of attribute status


12
13
14
# File 'lib/hockeyhelper/app.rb', line 12

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title


6
7
8
# File 'lib/hockeyhelper/app.rb', line 6

def title
  @title
end

Class Method Details

.create_from(hashobj, networking) ⇒ Object


18
19
20
# File 'lib/hockeyhelper/app.rb', line 18

def self.create_from(hashobj, networking)
  self.new hashobj, networking
end

Instance Method Details

#crash_reasons(page: 1, per: 25, symbolicated: true, sort: :date, order: :asc) ⇒ Object

List all crash groups for an app. return an Array of CrashReason objects.

sort parameter:

:date, :class, :number_of_crashes, :last_crash_at

order parameter:

:asc, :desc

99
100
101
102
103
104
105
106
107
108
# File 'lib/hockeyhelper/app.rb', line 99

def crash_reasons(page: 1, per: 25, symbolicated: true, sort: :date, order: :asc)
  obj = @net.get_object "/api/2/apps/#{@public_identifier}/crash_reasons"

  cr = []
  obj['crash_reasons'].each do |hashobj|
    cr << CrashReason.create_from(hashobj, @net)
  end

  cr
end

#inspectObject Also known as: to_s


37
38
39
# File 'lib/hockeyhelper/app.rb', line 37

def inspect
  "#{@title}, #{@bundle_identifier}, #{@platform}, #{@public_identifier}"
end

#invite_user(email: email) ⇒ Object

Invite a user to an app. return a User object.


59
60
61
62
63
64
65
# File 'lib/hockeyhelper/app.rb', line 59

def invite_user(email:email)
  obj = @net.post_object "/api/2/apps/#{@public_identifier}/app_users", {:email=>email, :role=>1}

  user = User.create_from(obj, @net)

  user
end

#remove_user(email: nil) ⇒ Object

Remove a user from an app on HockeyApp.


68
69
70
71
72
73
74
75
# File 'lib/hockeyhelper/app.rb', line 68

def remove_user(email:nil)
  users()
  user = @users.find {|u| u.email == email }

  if user
    @net.delete "/api/2/apps/#{@public_identifier}/app_users/#{user.id}"
  end
end

#usersObject

List all users of an app on HockeyApp. return an Array of User objects.


44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hockeyhelper/app.rb', line 44

def users
  return @users if @users

  obj = @net.get_object "/api/2/apps/#{@public_identifier}/app_users"

  @users = []
  obj['app_users'].each do |hashobj|
    @users << User.create_from(hashobj, @net)
  end

  @users
end

#versionsObject

List all versions of an app. The endpoint returns all versions for developer and members, but only released versions for testers. return an Array of Version objects.


79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/hockeyhelper/app.rb', line 79

def versions
  return @versions if @versions

  obj = @net.get_object "/api/2/apps/#{@public_identifier}/app_versions"

  @versions = []
  obj['app_versions'].each do |hashobj|
    @versions << Version.create_from(hashobj, @net)
  end

  @versions
end