Class: Hockey::App
- Inherits:
-
Object
- Object
- Hockey::App
- Defined in:
- lib/hockeyhelper/app.rb
Overview
App on HockeyApp
Instance Attribute Summary collapse
-
#bundle_identifier ⇒ Object
readonly
Returns the value of attribute bundle_identifier.
-
#device_family ⇒ Object
readonly
Returns the value of attribute device_family.
-
#minimum_os_version ⇒ Object
readonly
Returns the value of attribute minimum_os_version.
-
#net ⇒ Object
readonly
Returns the value of attribute net.
-
#original_hash ⇒ Object
readonly
Returns the value of attribute original_hash.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#public_identifier ⇒ Object
readonly
Returns the value of attribute public_identifier.
-
#release_type ⇒ Object
readonly
Returns the value of attribute release_type.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
-
.create_from(hashobj, networking) ⇒ Object
Construct a new instance of App.
Instance Method Summary collapse
-
#crash_reasons(page: 1, symbolicated: true, sort: :date, order: :asc) ⇒ Object
List all crash groups for an app.
- #crashes_histogram(date: Date.today, version: nil) ⇒ Object
-
#initialize(hashobj, networking) ⇒ App
constructor
Construct a new instance of App.
- #inspect ⇒ Object (also: #to_s)
-
#invite_user(email: '') ⇒ Object
Invite a user to an app.
-
#remove_user(email: nil) ⇒ Object
Remove a user from an app on HockeyApp.
-
#users(page: 1) ⇒ Array<User>
List all users of an app on HockeyApp.
-
#versions(page: 1) ⇒ Object
List all versions of an app.
Constructor Details
#initialize(hashobj, networking) ⇒ App
Construct a new instance of Hockey::App
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hockeyhelper/app.rb', line 31 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 @cached_users = nil @cached_versions = nil end |
Instance Attribute Details
#bundle_identifier ⇒ Object (readonly)
Returns the value of attribute bundle_identifier.
11 12 13 |
# File 'lib/hockeyhelper/app.rb', line 11 def bundle_identifier @bundle_identifier end |
#device_family ⇒ Object (readonly)
Returns the value of attribute device_family.
13 14 15 |
# File 'lib/hockeyhelper/app.rb', line 13 def device_family @device_family end |
#minimum_os_version ⇒ Object (readonly)
Returns the value of attribute minimum_os_version.
14 15 16 |
# File 'lib/hockeyhelper/app.rb', line 14 def minimum_os_version @minimum_os_version end |
#net ⇒ Object (readonly)
Returns the value of attribute net.
20 21 22 |
# File 'lib/hockeyhelper/app.rb', line 20 def net @net end |
#original_hash ⇒ Object (readonly)
Returns the value of attribute original_hash.
18 19 20 |
# File 'lib/hockeyhelper/app.rb', line 18 def original_hash @original_hash end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
17 18 19 |
# File 'lib/hockeyhelper/app.rb', line 17 def platform @platform end |
#public_identifier ⇒ Object (readonly)
Returns the value of attribute public_identifier.
12 13 14 |
# File 'lib/hockeyhelper/app.rb', line 12 def public_identifier @public_identifier end |
#release_type ⇒ Object (readonly)
Returns the value of attribute release_type.
15 16 17 |
# File 'lib/hockeyhelper/app.rb', line 15 def release_type @release_type end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
16 17 18 |
# File 'lib/hockeyhelper/app.rb', line 16 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/hockeyhelper/app.rb', line 10 def title @title end |
Class Method Details
.create_from(hashobj, networking) ⇒ Object
Construct a new instance of Hockey::App
26 27 28 |
# File 'lib/hockeyhelper/app.rb', line 26 def self.create_from(hashobj, networking) self.new hashobj, networking end |
Instance Method Details
#crash_reasons(page: 1, 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
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/hockeyhelper/app.rb', line 115 def crash_reasons(page: 1, 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 |
#crashes_histogram(date: Date.today, version: nil) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/hockeyhelper/app.rb', line 126 def crashes_histogram(date: Date.today, version: nil) start = date.strftime url = "/api/2/apps/#{@public_identifier}" if version url += "/app_versions/#{version.id}/crashes/histogram?start_date=#{start}&end_date=#{start}" else url += "/crashes/histogram?start_date=#{start}&end_date=#{start}" end obj = @net.get_object url histogram ||= {} obj['histogram'].each do |arr| histogram = {:date=>arr[0], :count=>arr[1]} end histogram end |
#inspect ⇒ Object Also known as: to_s
46 47 48 |
# File 'lib/hockeyhelper/app.rb', line 46 def inspect "#{@title}, #{@bundle_identifier}, #{@platform}, #{@public_identifier}" end |
#invite_user(email: '') ⇒ Object
Invite a user to an app. return a User object.
69 70 71 72 73 74 75 |
# File 'lib/hockeyhelper/app.rb', line 69 def invite_user(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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/hockeyhelper/app.rb', line 78 def remove_user(email: nil) begin total_pages = users().total_pages rescue => e return end 1.upto(total_pages) do |page| user = users(page: page).find {|u| u.email == email } if user @net.delete "/api/2/apps/#{@public_identifier}/app_users/#{user.id}" end end end |
#users(page: 1) ⇒ Array<User>
List all users of an app on HockeyApp.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/hockeyhelper/app.rb', line 54 def users(page: 1) @cached_users ||= [] if @cached_users.empty? obj = @net.get_object "/api/2/apps/#{@public_identifier}/app_users" obj['app_users'].each do |hashobj| @cached_users << User.create_from(hashobj, @net) end end PagingArray.paginate with: @cached_users, page: page end |
#versions(page: 1) ⇒ Object
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.
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/hockeyhelper/app.rb', line 95 def versions(page: 1) @cached_versions ||= [] if @cached_versions.empty? obj = @net.get_object "/api/2/apps/#{@public_identifier}/app_versions" obj['app_versions'].each do |hashobj| @cached_versions << Version.create_from(hashobj, @net) end end PagingArray.paginate with: @cached_versions, page: page end |