class Fabricio::Networking::BuildRequestModelFactory

This factory creates request models for fetching data for Build model object

Constants

FABRIC_API_PATH
FABRIC_API_URL

Server constants

FABRIC_APPS_ENDPOINT
FABRIC_ORGANIZATIONS_ENDPOINT

Public Instance Methods

all_builds_request_model(session, app_id) click to toggle source

Returns a request model for obtaining the list of all builds for a specific app

@param session [Fabricio::Authorization::Session] @param app_id [String] @return [Fabricio::Networking::RequestModel]

# File lib/fabricio/networking/build_request_model_factory.rb, line 19
def all_builds_request_model(session, app_id)
  path = "#{FABRIC_API_PATH}#{org_app_endpoint(session, app_id)}/beta_distribution/releases"
  model = Fabricio::Networking::RequestModel.new do |config|
    config.type = :GET
    config.base_url = FABRIC_API_URL
    config.api_path = path
  end
  model
end
get_build_request_model(session, app_id, version, build_number) click to toggle source

Returns a request model for obtaining a specific build for a specific app

@param session [Fabricio::Authorization::Session] @param app_id [String] @param version [String] The version number. E.g. ‘4.0.0’ @param build_number [String] The build number. E.g. ‘48’ @return [Fabricio::Networking::RequestModel]

# File lib/fabricio/networking/build_request_model_factory.rb, line 36
def get_build_request_model(session, app_id, version, build_number)
  path = "#{FABRIC_API_PATH}#{org_app_endpoint(session, app_id)}/beta_distribution/releases"
  params = {
      'app[display_version]' => version,
      'app[build_version]' => build_number
  }
  model = Fabricio::Networking::RequestModel.new do |config|
    config.type = :GET
    config.base_url = FABRIC_API_URL
    config.api_path = path
    config.params = params
  end
  model
end
top_versions_request_model(session, app_id, start_time, end_time) click to toggle source

Returns a request model for obtaining an array of top versions for a given app

@param session [Fabricio::Authorization::Session] @param app_id [String] @param start_time [String] Timestamp of the start date @param end_time [String] Timestamp of the end date @return [Fabricio::Networking::RequestModel]

# File lib/fabricio/networking/build_request_model_factory.rb, line 58
def top_versions_request_model(session, app_id, start_time, end_time)
  path = "#{FABRIC_API_PATH}#{org_app_endpoint(session, app_id)}/growth_analytics/top_builds"
  params = {
      'app_id' => app_id,
      'start' => start_time,
      'end' => end_time
  }
  model = Fabricio::Networking::RequestModel.new do |config|
    config.type = :GET
    config.base_url = FABRIC_API_URL
    config.api_path = path
    config.params = params
  end
  model
end

Private Instance Methods

app_endpoint(app_id) click to toggle source

Returns an API path to app endpoint

@param app_id [String] @return [String]

# File lib/fabricio/networking/build_request_model_factory.rb, line 80
def app_endpoint(app_id)
  "/#{FABRIC_APPS_ENDPOINT}/#{app_id}"
end
org_app_endpoint(session, app_id) click to toggle source

Returns an API path to organization endpoint

@param session [Fabricio::Authorization::Session] @param app_id [String] @return [String]

# File lib/fabricio/networking/build_request_model_factory.rb, line 97
def org_app_endpoint(session, app_id)
  "#{org_endpoint(session)}/#{app_endpoint(app_id)}"
end
org_endpoint(session) click to toggle source

Returns an API path to app endpoint

@param session [Fabricio::Authorization::Session] @return [String]

# File lib/fabricio/networking/build_request_model_factory.rb, line 88
def org_endpoint(session)
  "/#{FABRIC_ORGANIZATIONS_ENDPOINT}/#{session.organization_id}"
end