Class: IOSPortal::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ios-portal/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Creates a new API



10
11
12
13
14
15
16
17
# File 'lib/ios-portal/client.rb', line 10

def initialize(options={})
  self.username = options[:username]
  self.password = options[:password]
  self. = options[:account]
  
  @@agent = Mechanize.new
  @@agent.follow_meta_refresh = true
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



7
8
9
# File 'lib/ios-portal/client.rb', line 7

def 
  @account
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/ios-portal/client.rb', line 7

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/ios-portal/client.rb', line 7

def username
  @username
end

Instance Method Details

#devices(options = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ios-portal/client.rb', line 37

def devices(options={})
  if _authenticate
    page = @@agent.get(IOSPortal::DEVICES_URL)
    #puts page.parser.xpath('/').to_html
    profile_devices = []

    devices = page.at("div[@class='nt_multi']")
    raise "No devices" unless devices
    
    
    hidden_name = ""
    checkbox_name = ""
    devices.at("tbody").children.each{|row|
        device = {}
        row.children.each{|column|
            case column['class']
            when "checkbox"
              device[:id] = column.children[1]['value'].strip
            when "name"
              device[:name] = column.children[1].text.strip
            when "id"
              device[:udid] = column.text.strip
            end
        }
        
        profile_devices.push(device) if device.length > 0
        
    }
    return profile_devices
    
  end
end

#profiles(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ios-portal/client.rb', line 19

def profiles(options={})
  if _authenticate

    profiles = {}
    
    all = options.has_key?(:all) ? options[:all] : true
    
    if options[:development] or all
      profiles[:development] = development_provisioning_profiles
    end

    if options[:distribution] or all
      profiles[:distribution] = distribution_provisioning_profiles
    end
    return profiles
  end
end