Module: TinyAppstoreConnect::Client::Device
- Included in:
- TinyAppstoreConnect::Client
- Defined in:
- lib/tiny_appstore_connect/clients/device.rb
Instance Method Summary collapse
- #create_device(udid, name, platform: 'IOS') ⇒ Object
- #device(id: nil, udid: nil, **query) ⇒ Object
- #devices(filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object
- #rename_device(new_name, status = nil, id: nil, udid: nil) ⇒ Object
Instance Method Details
#create_device(udid, name, platform: 'IOS') ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tiny_appstore_connect/clients/device.rb', line 26 def create_device(udid, name, platform: 'IOS') body = { data: { type: 'devices', attributes: { udid: udid, name: name, platform: platform } } } post('devices', body: body) end |
#device(id: nil, udid: nil, **query) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/tiny_appstore_connect/clients/device.rb', line 18 def device(id: nil, udid: nil, **query) return get("devices/#{id}", **query).to_model unless id.to_s.empty? devices(**query).all_pages(flatten: true).find do |device| device.udid.casecmp(udid).zero? end end |
#devices(filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/tiny_appstore_connect/clients/device.rb', line 8 def devices(filter: {}, includes: nil, limit: nil, sort: nil) query = { include: includes, limit: limit, sort: sort }.delete_if { |_, v| v.nil? } get('devices', **query) end |
#rename_device(new_name, status = nil, id: nil, udid: nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tiny_appstore_connect/clients/device.rb', line 41 def rename_device(new_name, status = nil, id: nil, udid: nil) exist_device = device(id: id, udid: udid) return if exist_device.nil? device_id = exist_device.id status ||= exist_device.status body = { data: { type: 'devices', id: device_id, attributes: { name: new_name, status: status } } } patch("devices/#{device_id}", body: body).to_model end |