Class: Hockey::Client

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

Overview

HockeyApp API Client for Application

Instance Method Summary collapse

Constructor Details

#initialize(token, debug: false, network: nil) ⇒ Client

Returns a new instance of Client


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

def initialize(token, debug: false, network: nil)
  @net = network || Networking.new(token, debug:debug)
  @cached_apps = nil
end

Instance Method Details

#apps(page: 1) ⇒ Array<App>

List all apps for the logged user, including owned apps, developer apps, member apps, and tester apps on HockeyApp.

Parameters:

  • page (Fixnum)

    optional, used for pagination

Returns:

  • (Array<App>)

    an array of App objects.


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

def apps(page: 1)
  return @cached_apps if @cached_apps

  @cached_apps ||= []

  if @cached_apps.empty?
    obj = @net.get_object '/api/2/apps'
    obj['apps'].each do |hashobj|
      @cached_apps << App.create_from(hashobj, @net)
    end
  end

  apps = PagingArray.new
  apps.replace(@cached_apps[(page - 1) * apps.per_page, apps.per_page])
  apps.update_page_with(page, @cached_apps.size)

  apps
end

#new_app(title:, bundle_identifier:, platform: 'iOS') ⇒ Object

Create a new app without uploading a file on HockeyApp. return an App object.


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

def new_app(title:, bundle_identifier:, platform: 'iOS')
  obj = @net.post_object '/api/2/apps/new', {:title=>title, :bundle_identifier=>bundle_identifier, :platform=>platform, :release_type=>0}

  app = App.create_from(obj, @net)

  app
end

#teams(page: 1) ⇒ Hockey::PagingArray<Team>

List all teams for an account.

Parameters:

  • page (Fixnum)

    optional, used for pagination

Returns:


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

def teams(page: 1)
  teams = PagingArray.new

  obj = @net.get_object('/api/2/teams') do |req|
    req.params[:page] = page
  end
  obj['teams'].each do |hashobj|
    teams << Team.create_from(hashobj, @net)
  end

  teams.update_page(obj)

  teams
end