Class: HockeyApp::WS

Inherits:
Object
  • Object
show all
Includes:
HTTMultiParty
Defined in:
lib/hockeyapp/ws/ws.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WS

Returns a new instance of WS.



11
12
13
14
15
16
# File 'lib/hockeyapp/ws/ws.rb', line 11

def initialize (options = {})
  @options = Config.to_h.merge(options)
  raise "No API Token Given" if (@options[:token].nil?)
  self.class.headers 'X-HockeyAppToken' => @options[:token]
  self.class.base_uri @options[:base_uri] if @options[:base_uri].present?
end

Instance Method Details

#get_appsObject



19
20
21
# File 'lib/hockeyapp/ws/ws.rb', line 19

def get_apps
  self.class.get '/apps'
end

#get_crash_description(app_id, crash_id, options = {}) ⇒ Object

this is damn not thread safe !



41
42
43
44
45
46
# File 'lib/hockeyapp/ws/ws.rb', line 41

def get_crash_description app_id, crash_id, options = {}
  self.class.format :plain
  description = self.class.get "/apps/#{app_id}/crashes/#{crash_id}?format=text", options
  self.class.format :json
  description
end

#get_crash_groups(app_id, options = {}) ⇒ Object



28
29
30
# File 'lib/hockeyapp/ws/ws.rb', line 28

def get_crash_groups app_id, options = {}
  self.class.get "/apps/#{app_id}/crash_reasons", options
end

#get_crash_log(app_id, crash_id, options = {}) ⇒ Object

this is damn not thread safe !



33
34
35
36
37
38
# File 'lib/hockeyapp/ws/ws.rb', line 33

def get_crash_log app_id, crash_id, options = {}
  self.class.format :plain
  log = self.class.get "/apps/#{app_id}/crashes/#{crash_id}?format=log", options
  self.class.format :json
  log
end

#get_crashes(app_id, options = {}) ⇒ Object



24
25
26
# File 'lib/hockeyapp/ws/ws.rb', line 24

def get_crashes app_id, options = {}
  self.class.get "/apps/#{app_id}/crashes", options
end

#get_versions(app_id, options = {}) ⇒ Object



48
49
50
# File 'lib/hockeyapp/ws/ws.rb', line 48

def get_versions app_id, options = {}
  self.class.get "/apps/#{app_id}/app_versions", options
end

#post_new_app(file_ipa, notes = "New app", notes_type = App::NOTES_TYPES_TO_SYM.invert[:textile], notify = App::NOTIFY_TO_BOOL.invert[false], status = App::STATUS_TO_SYM.invert[:allow]) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/hockeyapp/ws/ws.rb', line 83

def post_new_app(file_ipa,
    notes="New app",
    notes_type=App::NOTES_TYPES_TO_SYM.invert[:textile],
    notify=App::NOTIFY_TO_BOOL.invert[false],
    status=App::STATUS_TO_SYM.invert[:allow])
  params = {
      :ipa => file_ipa,
      :notes => notes,
      :notes_type => notes_type,
      :notify => notify,
      :status => status
  }
  self.class.post "/apps", :body => params
end

#post_new_version(app_id, ipa, dsym = nil, notes = "New version", notes_type = Version::NOTES_TYPES_TO_SYM.invert[:textile], notify = Version::NOTIFY_TO_BOOL.invert[:none], status = Version::STATUS_TO_SYM.invert[:allow], tags = '') ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/hockeyapp/ws/ws.rb', line 52

def post_new_version(
    app_id,
        ipa,
        dsym=nil,
        notes="New version",
        notes_type=Version::NOTES_TYPES_TO_SYM.invert[:textile],
        notify=Version::NOTIFY_TO_BOOL.invert[:none],
        status=Version::STATUS_TO_SYM.invert[:allow],
        tags=''
)
  params = {
      :ipa => ipa ,
      :dsym => dsym ,
      :notes => notes,
      :notes_type => notes_type,
      :notify => notify,
      :status => status,
      :tags => tags
  }
  params.reject!{|_,v|v.nil?}
  self.class.post "/apps/#{app_id}/app_versions/upload", :body => params
end

#remove_app(app_id) ⇒ Object



76
77
78
79
80
81
# File 'lib/hockeyapp/ws/ws.rb', line 76

def remove_app app_id
  self.class.format :plain
  response = self.class.delete "/apps/#{app_id}"
  self.class.format :json
  response
end