class Fastlane::Client::MobileironApiClient

Constants

API_VERSION
APPLICATION_JSON
APPLICATION_OCTET_STREAM
CONTENT_TYPE

Public Class Methods

new(base_url, username, password, debug = true) click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 15
def initialize(base_url, username, password, debug = true)
  @base_url = base_url
  @username = username
  @password = password
  @debug = debug
end

Public Instance Methods

appstore_apps_labels(app_id, label_id, space_id) click to toggle source

Apply app to app group label on Mobileiron

args

app_id - App Id from Mobileiron
label_id - Label Id from Mobileiron
space_id - Space Id from Mobileiron

Returns status.

# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 81
def appstore_apps_labels(app_id, label_id, space_id)
  response = connection.put(get_appstore_apps_labels_url(app_id, label_id)) do |request|
    request.params[:adminDeviceSpaceId] = space_id
  end

  if response.success?
     AppStoreAppsLabelsResponse.new(response.body)
  end
end
appstore_apps_message(app_id) click to toggle source

Send message to update App on Mobileiron

args

app_id - App Id from Mobileiron

Throws a user_error if the binary file does not exist

# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 97
def appstore_apps_message(app_id)
  response = connection.post(get_appstore_apps_message_url(app_id)) do |request|
    request.headers[CONTENT_TYPE] = APPLICATION_JSON
    request.params[:adminDeviceSpaceId] = "1"
    request.body = JSON.dump({ installIncluded: true, updateIncluded: true, pushApp: true })
  end

  if response.success?
    AppStoreAppsMessageResponse.new(response.body)
  end
end
appstore_inhouse(artifact) click to toggle source

Upload artefact to Mobileiron

args

artifact - Absolute path to your app's apk/ipa file

Throws a user_error if the binary file does not exist Returns status.

# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 61
def appstore_inhouse(artifact)
  payload = { :installer => Faraday::FilePart.new(artifact, APPLICATION_OCTET_STREAM) }
  response = connection.post(get_appstore_inhouse_url) do |request|
    request.params[:adminDeviceSpaceId] = "1"
    request.body = payload
  end

  if response.success?
    AppStoreInhouseResponse.new(response.body)
  end
end
get_api_url() click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 109
def get_api_url
  @base_url + API_VERSION
end
get_label_summary(label) click to toggle source

Get App label info on Mobileiron

Returns the Mobileiron App label info, otherwise returns nil.

# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 47
def get_label_summary(label)
  labels = get_labels_summary
  unless labels.nil?
    labels.results.find { |item| item.name == label }
  end
end
get_labels_summary() click to toggle source

Get App labels on Mobileiron

Returns the available Mobileiron App label(s), otherwise returns nil.

# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 35
def get_labels_summary
  response = connection.get(get_labels_summary_url) do |request|
    request.params[:adminDeviceSpaceId] = "1"
  end
  if response.success?
    LabelsSummaryResponse.new(response.body)
  end
end
ping() click to toggle source

Ping Mobileiron API

Returns the Mobileiron API version, otherwise returns nil.

# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 25
def ping
  response = connection.get(get_ping_url)
  if response.success?
    PingResponse.new(response.body)
  end
end

Private Instance Methods

connection() click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 137
def connection
  @connection ||= Faraday.new(url: @base_url) do |conn|
    conn.basic_auth(@username, @password)
    conn.request(:multipart)
    conn.request :url_encoded
    conn.response(:json, parser_options: { symbolize_names: true })
    conn.response(:raise_error) # raise_error middleware will run before the json middleware
    conn.response(:logger, nil, { headers: false, bodies: { request: false, response: true }, log_level: :debug }) if @debug
    conn.adapter(Faraday.default_adapter)
  end
end
get_appstore_apps_labels_url(app_id, label_id) click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 129
def get_appstore_apps_labels_url(app_id, label_id)
  API_VERSION + "/appstore/apps/#{app_id}/labels/#{label_id}"
end
get_appstore_apps_message_url(app_id) click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 133
def get_appstore_apps_message_url(app_id)
  API_VERSION + "/appstore/apps/#{app_id}/message"
end
get_appstore_inhouse_url() click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 125
def get_appstore_inhouse_url
  API_VERSION + "/appstore/inhouse"
end
get_labels_summary_url() click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 121
def get_labels_summary_url
  API_VERSION + "/labels/label_summary"
end
get_ping_url() click to toggle source
# File lib/fastlane/plugin/mobileiron/client/mobileiron_api_client.rb, line 117
def get_ping_url
  API_VERSION + "/ping"
end