Class: Fabricio::Networking::AppRequestModelFactory
- Inherits:
-
Object
- Object
- Fabricio::Networking::AppRequestModelFactory
- Defined in:
- lib/fabricio/networking/app_request_model_factory.rb
Overview
This factory creates request models for fetching data for App model object
Constant Summary collapse
- FABRIC_API_URL =
Server constants
'https://fabric.io'
- FABRIC_GRAPHQL_API_URL =
'https://api-dash.fabric.io/graphql'
- FABRIC_API_PATH =
'/api/v2'
- FABRIC_APPS_ENDPOINT =
'/apps'
- FABRIC_ORGANIZATIONS_ENDPOINT =
'/organizations'
Instance Method Summary collapse
-
#active_now_request_model(session, app_id) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of active users at the current moment.
-
#all_apps_request_model ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the list of all apps.
-
#crash_count_request_model(app_id, start_time, end_time, builds) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of app crashes.
-
#daily_active_request_model(session, app_id, start_time, end_time, build) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of daily active users.
-
#daily_new_request_model(session, app_id, start_time, end_time) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of daily new users.
-
#get_app_request_model(app_id) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining a specific app.
-
#oom_count_request_model(app_id, days, builds) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of ooms.
-
#total_sessions_request_model(session, app_id, start_time, end_time, build) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of sessions.
Instance Method Details
permalink #active_now_request_model(session, app_id) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of active users at the current moment
47 48 49 50 51 52 53 54 55 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 47 def active_now_request_model(session, app_id) path = growth_analytics_endpoint(session, app_id, 'active_now') model = Fabricio::Networking::RequestModel.new do |config| config.type = :GET config.base_url = FABRIC_API_URL config.api_path = path end model end |
permalink #all_apps_request_model ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the list of all apps
19 20 21 22 23 24 25 26 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 19 def all_apps_request_model model = Fabricio::Networking::RequestModel.new do |config| config.type = :GET config.base_url = FABRIC_API_URL config.api_path = FABRIC_API_PATH + FABRIC_APPS_ENDPOINT end model end |
permalink #crash_count_request_model(app_id, start_time, end_time, builds) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of app crashes
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 128 def crash_count_request_model(app_id, start_time, end_time, builds) headers = { 'Content-Type' => 'application/json' } builds_string = builds.map { |build| "\"#{build}\"" }.join(',') body = { 'query' => "query AppScalars($app_id:String!,$type:IssueType!) {project(externalId:$app_id) {crashlytics {scalars:scalars(synthesizedBuildVersions:[#{builds_string}],type:$type,start:#{start_time},end:#{end_time}) {crashes}}}}", 'variables' => { 'app_id' => app_id, 'type' => 'crash' } }.to_json model = Fabricio::Networking::RequestModel.new do |config| config.type = :POST config.base_url = FABRIC_GRAPHQL_API_URL config.headers = headers config.body = body end model end |
permalink #daily_active_request_model(session, app_id, start_time, end_time, build) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of daily active users
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 84 def daily_active_request_model(session, app_id, start_time, end_time, build) path = growth_analytics_endpoint(session, app_id, 'daily_active') params = time_range_params(start_time, end_time) params['build'] = build 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 |
permalink #daily_new_request_model(session, app_id, start_time, end_time) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of daily new users
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 64 def daily_new_request_model(session, app_id, start_time, end_time) path = growth_analytics_endpoint(session, app_id, 'daily_new') params = time_range_params(start_time, 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 |
permalink #get_app_request_model(app_id) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining a specific app
32 33 34 35 36 37 38 39 40 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 32 def get_app_request_model(app_id) path = "#{FABRIC_API_PATH}#{app_endpoint(app_id)}" model = Fabricio::Networking::RequestModel.new do |config| config.type = :GET config.base_url = FABRIC_API_URL config.api_path = path end model end |
permalink #oom_count_request_model(app_id, days, builds) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of ooms
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 157 def oom_count_request_model(app_id, days, builds) headers = { 'Content-Type' => 'application/json' } body = { 'query' => 'query oomCountForDaysForBuild($app_id: String!, $builds: [String!]!, $days: Int!) { project(externalId: $app_id) { crashlytics{ oomCounts(builds: $builds, days: $days){ timeSeries{ allTimeCount } } oomSessionCounts(builds: $builds, days: $days){ timeSeries{ allTimeCount } } } } }', 'variables' => { 'app_id' => app_id, 'days' => days, 'builds' => builds } }.to_json model = Fabricio::Networking::RequestModel.new do |config| config.type = :POST config.base_url = FABRIC_GRAPHQL_API_URL config.headers = headers config.body = body end model end |
permalink #total_sessions_request_model(session, app_id, start_time, end_time, build) ⇒ Fabricio::Networking::RequestModel
Returns a request model for obtaining the count of sessions
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/fabricio/networking/app_request_model_factory.rb', line 105 def total_sessions_request_model(session, app_id, start_time, end_time, build) path = growth_analytics_endpoint(session, app_id, 'total_sessions_scalar') params = { 'start' => start_time, 'end' => end_time, 'build' => build } 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 |