Class: Findi::Client
- Inherits:
-
Object
- Object
- Findi::Client
- Defined in:
- lib/findi/client.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username, password) ⇒ Client
constructor
A new instance of Client.
- #update_devices ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 |
# File 'lib/findi/client.rb', line 11 def initialize(username, password) @username = username @password = password @devices = [] get_partition update_devices end |
Instance Attribute Details
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
9 10 11 |
# File 'lib/findi/client.rb', line 9 def devices @devices end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/findi/client.rb', line 8 def username @username end |
Instance Method Details
#update_devices ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/findi/client.rb', line 20 def update_devices body = { clientContext: { appName: 'FindMyiPhone', appVersion: '1.4', buildVersion: '145', deviceUDID: '0000000000000000000000000000000000000000', inactiveTime: 2147483647, osVersion: '4.2.1', personID: 0, productType: 'iPad1,1' } } response = post("fmipservice/device/#{@username}/initClient", body) json = MultiJson.load(response.body) # TODO: Catch parse error raise "Web service error: #{json['error']}" if json['error'] @devices = [] json['content'].each do |device| @devices << Device.new(device) end @devices end |