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) (defaults to: 1)

    optional, used for pagination

Returns:

  • (Array<App>)

    an array of App objects.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hockeyhelper/client.rb', line 20

def apps(page: 1)
  @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

  PagingArray.paginate with: @cached_apps, page: page
end

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

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



54
55
56
57
58
59
60
# File 'lib/hockeyhelper/client.rb', line 54

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) (defaults to: 1)

    optional, used for pagination

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/hockeyhelper/client.rb', line 37

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