Skip to content

Commit

Permalink
Fixed some minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CognitiveDisson committed Feb 21, 2018
1 parent 937b7b8 commit 58bd77a
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
reported by contacting the project team at [email protected], [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Rambler Digital Solutions
Copyright (c) 2016 StrongSelf

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Or install it yourself as:

### CLI
#### Commands
##### App
```
# Obtain all app
fabricio app all
Expand All @@ -63,22 +64,30 @@ Or install it yourself as:
# Obtain latest issue session
fabricio app latest_session --app_id 'app_id'
```
##### Build
```
# Obtain all builds
fabricio build all --org_id 'org_id' --app_id 'app_id'
# Obtain single build
fabricio build get --org_id 'org_id' --app_id 'app_id' 'version' 'build_number'
```
##### Version
```
# Obtain all versions
fabricio version all --app_id 'app_id'
# Obtain top versions
fabricio version top --org_id 'org_id' --app_id 'app_id' --start 'timestamp' --end 'timestamp'
```
##### Organization
```
# Obtain organization
fabricio organization all
```
##### Other
```
# Setup credential
fabricio credential
Expand Down
4 changes: 2 additions & 2 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ curl -X POST "https://fabric.io/oauth/token" \
```
{
"type": "string",
"default": "{\"grant_type\":\"password\",\"scope\":\"organizations apps issues features account twitter_client_apps beta software answers\",\"username\":\"email@rambler.ru\",\"password\":\"pa$$word\",\"client_id\":\"your_client_id\",\"client_secret\":\"your_client_secret\"}"
"default": "{\"grant_type\":\"password\",\"scope\":\"organizations apps issues features account twitter_client_apps beta software answers\",\"username\":\"email@email.ru\",\"password\":\"pa$$word\",\"client_id\":\"your_client_id\",\"client_secret\":\"your_client_secret\"}"
}
```

Expand Down Expand Up @@ -608,4 +608,4 @@ curl -X GET "https://fabric.io/api/v2/organizations/{organization_id}/apps/{app_

## References

- [API in Swagger format](swagger-api.json)
- [API in Swagger format](swagger-api.json)
4 changes: 2 additions & 2 deletions docs/swagger-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"in": "body",
"schema": {
"type": "string",
"default": "{\"grant_type\":\"password\",\"scope\":\"organizations apps issues features account twitter_client_apps beta software answers\",\"username\":\"email@rambler.ru\",\"password\":\"pa$$word\",\"client_id\":\"your_client_id\",\"client_secret\":\"your_client_secret\"}"
"default": "{\"grant_type\":\"password\",\"scope\":\"organizations apps issues features account twitter_client_apps beta software answers\",\"username\":\"email@email.ru\",\"password\":\"pa$$word\",\"client_id\":\"your_client_id\",\"client_secret\":\"your_client_secret\"}"
}
}
],
Expand Down Expand Up @@ -550,4 +550,4 @@
"https"
],
"securityDefinitions": {}
}
}
8 changes: 4 additions & 4 deletions lib/fabricio/cli/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
require 'yaml'

def client
sessionStorage = Fabricio::Authorization::FileSessionStorage.new()
session_storage = Fabricio::Authorization::FileSessionStorage.new()
param_storage = Fabricio::Authorization::FileParamStorage.new()
session = sessionStorage.obtain_session
session = session_storage.obtain_session
if session
return Fabricio::Client.new do |config|
config.session_storage = sessionStorage
config.session_storage = session_storage
config.param_storage = param_storage
end
else
credential = ask_credential
return Fabricio::Client.new do |config|
config.username = credential.email
config.password = credential.password
config.session_storage = sessionStorage
config.session_storage = session_storage
config.param_storage = param_storage
end
end
Expand Down
12 changes: 5 additions & 7 deletions lib/fabricio/client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Client

attr_accessor :client_id, :client_secret, :username, :password, :session_storage, :param_storage;

# Default initialize options
def default_options
{
:client_id => DEFAULT_CLIENT_ID,
Expand All @@ -38,7 +39,7 @@ def default_options

# Initializes a new Client object. You can use a block to fill all the options:
# client = Fabricio::Client.new do |config|
# config.username = 'email@rambler.ru'
# config.username = 'email@email.ru'
# config.password = 'pa$$word'
# end
#
Expand All @@ -56,15 +57,12 @@ def default_options
# @option options [Hash] Default params
# @return [Fabricio::Client]
def initialize(options = default_options)
options.each do |key, value|
instance_variable_set("@#{key}", value)
end
options.each { |key, value| instance_variable_set("@#{key}", value) }
yield(self) if block_given?

@auth_client = Fabricio::Authorization::AuthorizationClient.new
if obtain_session.nil?
raise StandardError.new("Session is empty: #{auth_data}")
end
raise StandardError.new("Session is empty: #{auth_data}") if obtain_session.nil?

network_client = Fabricio::Networking::NetworkClient.new(@auth_client, @session_storage)

@organization_service ||= Fabricio::Service::OrganizationService.new(param_storage, network_client)
Expand Down
5 changes: 1 addition & 4 deletions lib/fabricio/networking/app_request_model_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ def top_issues_request_model(app_id, start_time, end_time, builds, count)
headers = {
'Content-Type' => 'application/json'
}
builds_string = builds.map { |build|
"\"#{build}\""
}.join(',')

builds_string = builds.map { |build| "\"#{build}\"" }.join(',')
body = {
'query' => "query TopIssues($externalId_0:String!,$type_1:IssueType!,$start_2:UnixTimestamp!,$end_3:UnixTimestamp!,$filters_4:IssueFiltersType!,$state_5:IssueState!) {project(externalId:$externalId_0) {crashlytics {_appDetails1JwAD1:appDetails(synthesizedBuildVersions:[#{builds_string}],type:$type_1,start:$start_2,end:$end_3,filters:$filters_4) {topCrashInsightsMatchers {groupKey}},_issues4Eg1Tv:issues(synthesizedBuildVersions:[#{builds_string}],eventType:$type_1,start:$start_2,end:$end_3,state:$state_5,first:#{count},filters:$filters_4) {edges {node {externalId,displayId,createdAt,resolvedAt,title,subtitle,state,type,impactLevel,isObfuscated,occurrenceCount,impactedDevices,latestSessionId,notesCount,earliestBuildVersion {buildVersion {name}},latestBuildVersion {buildVersion {name}},id},cursor},pageInfo {hasNextPage,hasPreviousPage}}},id}}",
'variables' => {
Expand Down
23 changes: 10 additions & 13 deletions lib/fabricio/services/app_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def get(app_id = nil)
request_model = @request_model_factory.get_app_request_model(app_id)
response = @network_client.perform_request(request_model)
json = JSON.parse(response.body)
# TODO Handle error
Fabricio::Model::App.new(json)
end

Expand All @@ -63,9 +62,7 @@ def active_now(organization_id = nil, app_id = nil)
def daily_new(organization_id = nil, app_id = nil, start_time = week_ago_timestamp, end_time = today_timestamp)
request_model = @request_model_factory.daily_new_request_model(organization_id, app_id, start_time, end_time)
response = @network_client.perform_request(request_model)
JSON.parse(response.body)['series'].map do |array|
Fabricio::Model::Point.new(array)
end
parse_point_response(response)
end

# Obtains the count of daily active users
Expand All @@ -79,9 +76,7 @@ def daily_new(organization_id = nil, app_id = nil, start_time = week_ago_timesta
def daily_active(organization_id = nil, app_id = nil, start_time = week_ago_timestamp, end_time = today_timestamp, build)
request_model = @request_model_factory.daily_active_request_model(organization_id, app_id, start_time, end_time, build)
response = @network_client.perform_request(request_model)
JSON.parse(response.body)['series'].map do |array|
Fabricio::Model::Point.new(array)
end
parse_point_response(response)
end

# Obtains the count of weekly active users
Expand All @@ -95,9 +90,7 @@ def daily_active(organization_id = nil, app_id = nil, start_time = week_ago_time
def weekly_active(organization_id = nil, app_id = nil, start_time = week_ago_timestamp, end_time = today_timestamp, build)
request_model = @request_model_factory.weekly_active_request_model(organization_id, app_id, start_time, end_time, build)
response = @network_client.perform_request(request_model)
JSON.parse(response.body)['series'].map do |array|
Fabricio::Model::Point.new(array)
end
parse_point_response(response)
end

# Obtains the count of monhtly active users
Expand All @@ -111,9 +104,7 @@ def weekly_active(organization_id = nil, app_id = nil, start_time = week_ago_tim
def monthly_active(organization_id = nil, app_id = nil, start_time = week_ago_timestamp, end_time = today_timestamp, build)
request_model = @request_model_factory.monthly_active_request_model(organization_id, app_id, start_time, end_time, build)
response = @network_client.perform_request(request_model)
JSON.parse(response.body)['series'].map do |array|
Fabricio::Model::Point.new(array)
end
parse_point_response(response)
end

# Obtains the count of sessions
Expand Down Expand Up @@ -243,6 +234,12 @@ def today_timestamp
Time.now.to_i
end

def parse_point_response(response)
JSON.parse(response.body)['series'].map do |array|
Fabricio::Model::Point.new(array)
end
end

end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"id": "network_org_id",
"alias": "ramblerco",
"name": "Rambler&Co",
"alias": "organization",
"name": "Some_organization",
"api_key": "api_key",
"enrollments": {
"answers_enhanced_feature_set_enabled_for_new_apps": "true",
Expand All @@ -18,4 +18,4 @@
},
"build_secret": "build_secret"
}
]
]
2 changes: 1 addition & 1 deletion spec/lib/fabricio/client/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
end

expect {
client.rambler
client.some
}.to raise_error(NoMethodError)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/fabricio/client/organization_stub_response.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"id": "network_org_id",
"alias": "ramblerco",
"name": "Rambler&Co",
"alias": "organization",
"name": "SomeOrganization",
"api_key": "api_key",
"enrollments": {
"answers_enhanced_feature_set_enabled_for_new_apps": "true",
Expand All @@ -18,4 +18,4 @@
},
"build_secret": "build_secret"
}
]
]
4 changes: 2 additions & 2 deletions spec/lib/fabricio/service/app_service_all_stub_response.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"organization_id": "org_id",
"watched": null,
"importance_level": null,
"dashboard_url": "https://www.fabric.io/ramblerco/ios/apps/ru.organization.app",
"dashboard_url": "https://www.fabric.io/organization/ios/apps/ru.organization.app",
"impacted_devices_count": 0,
"unresolved_issues_count": 0,
"crashes_count": 0
Expand All @@ -48,7 +48,7 @@
"organization_id": "org_id",
"watched": null,
"importance_level": null,
"dashboard_url": "https://www.fabric.io/ramblerco/android/apps/ru.organization.app2",
"dashboard_url": "https://www.fabric.io/organization/android/apps/ru.organization.app2",
"impacted_devices_count": 0,
"unresolved_issues_count": 0,
"crashes_count": 0
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/fabricio/service/app_service_get_stub_response.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "id_1",
"name": "LiveJournal",
"name": "Some",
"bundle_identifier": "ru.organization.app",
"base_identifier": null,
"collect_analytics": true,
Expand All @@ -20,7 +20,7 @@
"organization_id": "org_id",
"watched": null,
"importance_level": null,
"dashboard_url": "https://www.fabric.io/ramblerco/ios/apps/ru.organization.app",
"dashboard_url": "https://www.fabric.io/organization/ios/apps/ru.organization.app",
"impacted_devices_count": 0,
"unresolved_issues_count": 0,
"crashes_count": 0
Expand Down

0 comments on commit 58bd77a

Please sign in to comment.