mno-enterprise-api 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce57f9284f88612e924df7c0cd054f49e73b3966
4
- data.tar.gz: 4a017727ef7501242222557b3473ed132cc59a49
3
+ metadata.gz: 0f9a59af5d82066b5218e41fded2d2d15415c3f2
4
+ data.tar.gz: fd7515bcc91ce757de834cc3456c86a52f4a81aa
5
5
  SHA512:
6
- metadata.gz: 79e4618c0754140515cf6146337607ef38be216a379e27235741c6553d7f1ef1dd6ee2659ed107c1e1e4b40859d0b5f8eb8ebf824af45f78e128897750f95aa4
7
- data.tar.gz: a970b387a73880e4c33e5bd4df6ece4338f7fec48f6c7e95ce2e3421f482f5a5bf22cf3985a91f33015174a07b49dd06f993f30b1b779337b4623ed83845d6d3
6
+ metadata.gz: 0426722e7384f3fd85058066d2ac2ab2eaafe86127d8f76844f4c1c2a152e776927f91667857929eea4399a7c22ea89bab48d2c1ab40d50159ed0f50b7563289
7
+ data.tar.gz: b834cc97dc3bd7253171f58dc36cf7d62b34584aa071388ce415b8f46da3085a4c2a5d72b0812e3b061ffc73d5aa730e3b06adfa9b150e7471c92721f611daee
@@ -3,14 +3,21 @@ module MnoEnterprise
3
3
 
4
4
  # GET /mnoe/jpi/v1/admin/organizations
5
5
  def index
6
- @organizations = MnoEnterprise::Organization
7
- @organizations = @organizations.limit(params[:limit]) if params[:limit]
8
- @organizations = @organizations.skip(params[:offset]) if params[:offset]
9
- @organizations = @organizations.order_by(params[:order_by]) if params[:order_by]
10
- @organizations = @organizations.where(params[:where]) if params[:where]
11
- @organizations = @organizations.all
12
-
13
- response.headers['X-Total-Count'] = @organizations.metadata[:pagination][:count]
6
+ if params[:terms]
7
+ # Search mode
8
+ @organizations = []
9
+ JSON.parse(params[:terms]).map { |t| @organizations = @organizations | MnoEnterprise::Organization.where(Hash[*t]) }
10
+ response.headers['X-Total-Count'] = @organizations.count
11
+ else
12
+ # Index mode
13
+ @organizations = MnoEnterprise::Organization
14
+ @organizations = @organizations.limit(params[:limit]) if params[:limit]
15
+ @organizations = @organizations.skip(params[:offset]) if params[:offset]
16
+ @organizations = @organizations.order_by(params[:order_by]) if params[:order_by]
17
+ @organizations = @organizations.where(params[:where]) if params[:where]
18
+ @organizations = @organizations.all
19
+ response.headers['X-Total-Count'] = @organizations.metadata[:pagination][:count]
20
+ end
14
21
  end
15
22
 
16
23
  # GET /mnoe/jpi/v1/admin/organizations/1
@@ -23,5 +30,11 @@ module MnoEnterprise
23
30
  def in_arrears
24
31
  @arrears = MnoEnterprise::ArrearsSituation.all
25
32
  end
33
+
34
+ # GET /mnoe/jpi/v1/admin/organizations/count
35
+ def count
36
+ organizations_count = MnoEnterprise::Tenant.get('tenant').organizations_count
37
+ render json: {count: organizations_count }
38
+ end
26
39
  end
27
40
  end
@@ -3,14 +3,21 @@ module MnoEnterprise
3
3
 
4
4
  # GET /mnoe/jpi/v1/admin/users
5
5
  def index
6
- @users = MnoEnterprise::User
7
- @users = @users.limit(params[:limit]) if params[:limit]
8
- @users = @users.skip(params[:offset]) if params[:offset]
9
- @users = @users.order_by(params[:order_by]) if params[:order_by]
10
- @users = @users.where(params[:where]) if params[:where]
11
- @users = @users.all
12
-
13
- response.headers['X-Total-Count'] = @users.metadata[:pagination][:count]
6
+ if params[:terms]
7
+ # Search mode
8
+ @users = []
9
+ JSON.parse(params[:terms]).map { |t| @users = @users | MnoEnterprise::User.where(Hash[*t]) }
10
+ response.headers['X-Total-Count'] = @users.count
11
+ else
12
+ # Index mode
13
+ @users = MnoEnterprise::User
14
+ @users = @users.limit(params[:limit]) if params[:limit]
15
+ @users = @users.skip(params[:offset]) if params[:offset]
16
+ @users = @users.order_by(params[:order_by]) if params[:order_by]
17
+ @users = @users.where(params[:where]) if params[:where]
18
+ @users = @users.all
19
+ response.headers['X-Total-Count'] = @users.metadata[:pagination][:count]
20
+ end
14
21
  end
15
22
 
16
23
  # GET /mnoe/jpi/v1/admin/users/1
@@ -47,6 +54,12 @@ module MnoEnterprise
47
54
  head :no_content
48
55
  end
49
56
 
57
+ # GET /mnoe/jpi/v1/admin/users/count
58
+ def count
59
+ users_count = MnoEnterprise::Tenant.get('tenant').users_count
60
+ render json: {count: users_count }
61
+ end
62
+
50
63
  private
51
64
 
52
65
  def user_params
@@ -4,4 +4,4 @@ json.organizations do
4
4
  json.partial! 'credit_card', credit_card: organization.credit_card
5
5
  end
6
6
  end
7
- json.metadata @organizations.metadata
7
+ json.metadata @organizations.metadata if @organizations.respond_to?(:metadata)
@@ -1,2 +1,2 @@
1
1
  json.users @users, partial: 'user', as: :user
2
- json.metadata @users.metadata
2
+ json.metadata @users.metadata if @users.respond_to?(:metadata)
@@ -27,6 +27,7 @@ json.cache! ['v1', @user.cache_key] do
27
27
  json.currency o.billing_currency
28
28
  json.current_user_role o.role
29
29
  json.has_myob_essentials_only o.has_myob_essentials_only?
30
+ json.financial_year_end_month o.financial_year_end_month
30
31
  end
31
32
  end
32
33
 
@@ -1,4 +1,4 @@
1
- json.extract! dashboard, :id, :name, :full_name, :widgets_templates, :currency
1
+ json.extract! dashboard, :id, :name, :full_name, :currency
2
2
 
3
3
  json.data_sources dashboard.organizations.compact.map do |org|
4
4
  json.id org.id
@@ -6,4 +6,5 @@ json.data_sources dashboard.organizations.compact.map do |org|
6
6
  json.label org.name
7
7
  end
8
8
  json.widgets dashboard.sorted_widgets, partial: 'mno_enterprise/jpi/v1/impac/widgets/widget', as: :widget
9
+ json.widgets_templates dashboard.filtered_widgets_templates
9
10
  json.kpis dashboard.kpis, partial: 'mno_enterprise/jpi/v1/impac/kpis/kpi', as: :kpi
data/config/routes.rb CHANGED
@@ -124,10 +124,15 @@ MnoEnterprise::Engine.routes.draw do
124
124
  #============================================================
125
125
  namespace :admin, defaults: {format: 'json'} do
126
126
  resources :audit_events, only: [:index]
127
- resources :users, only: [:index, :show, :destroy, :update, :create]
127
+ resources :users, only: [:index, :show, :destroy, :update, :create] do
128
+ collection do
129
+ get :count
130
+ end
131
+ end
128
132
  resources :organizations, only: [:index, :show] do
129
133
  collection do
130
134
  get :in_arrears
135
+ get :count
131
136
  end
132
137
  end
133
138
  resources :tenant_invoices, only: [:index, :show]
@@ -60,6 +60,7 @@ module MnoEnterprise
60
60
  return hash
61
61
  end
62
62
 
63
+
63
64
  #===============================================
64
65
  # Assignments
65
66
  #===============================================
@@ -27,7 +27,8 @@ module MnoEnterprise
27
27
  'phone_country_code' => res.phone_country_code,
28
28
  'country_code' => res.geo_country_code || 'US',
29
29
  'website' => res.website,
30
- 'sso_session' => res.sso_session
30
+ 'sso_session' => res.sso_session,
31
+ 'admin_role' => res.admin_role
31
32
  }
32
33
 
33
34
  if res.id
@@ -39,7 +40,8 @@ module MnoEnterprise
39
40
  'name' => o.name,
40
41
  'currency' => 'AUD',
41
42
  'current_user_role' => o.role,
42
- 'has_myob_essentials_only' => o.has_myob_essentials_only?
43
+ 'has_myob_essentials_only' => o.has_myob_essentials_only?,
44
+ 'financial_year_end_month' => o.financial_year_end_month
43
45
  }
44
46
  end
45
47
 
@@ -15,6 +15,9 @@ module MnoEnterprise
15
15
  it 'routes to #in_arrears' do
16
16
  expect(get('/jpi/v1/admin/organizations/in_arrears')).to route_to("mno_enterprise/jpi/v1/admin/organizations#in_arrears", format: "json")
17
17
  end
18
+
19
+ it 'routes to #count' do
20
+ expect(get('/jpi/v1/admin/organizations/count')).to route_to("mno_enterprise/jpi/v1/admin/organizations#count", format: 'json')
21
+ end
18
22
  end
19
23
  end
20
-
@@ -19,6 +19,9 @@ module MnoEnterprise
19
19
  it 'routes to #destroy' do
20
20
  expect(delete('/jpi/v1/admin/users/1')).to route_to("mno_enterprise/jpi/v1/admin/users#destroy", id: '1', format: 'json')
21
21
  end
22
+
23
+ it 'routes to #count' do
24
+ expect(get('/jpi/v1/admin/users/count')).to route_to("mno_enterprise/jpi/v1/admin/users#count", format: 'json')
25
+ end
22
26
  end
23
27
  end
24
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mno-enterprise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Lachaume
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-05 00:00:00.000000000 Z
12
+ date: 2016-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mno-enterprise-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: 3.0.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.0
27
+ version: 3.0.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jbuilder
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -336,62 +336,62 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
336
  version: '0'
337
337
  requirements: []
338
338
  rubyforge_project:
339
- rubygems_version: 2.2.2
339
+ rubygems_version: 2.4.8
340
340
  signing_key:
341
341
  specification_version: 4
342
342
  summary: Maestrano Enterprise - API
343
343
  test_files:
344
- - spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb
344
+ - spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
345
+ - spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb
346
+ - spec/routing/mno_enterprise/provision_controller_routing_spec.rb
347
+ - spec/routing/mno_enterprise/status_controller_routing_spec.rb
348
+ - spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb
349
+ - spec/routing/mno_enterprise/pages_controller_routing_spec.rb
350
+ - spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb
351
+ - spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb
352
+ - spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb
353
+ - spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb
354
+ - spec/routing/mno_enterprise/jpi/v1/admin/theme_controller_routing_spec.rb
355
+ - spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb
356
+ - spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb
357
+ - spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb
358
+ - spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb
359
+ - spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb
360
+ - spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb
361
+ - spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb
362
+ - spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb
363
+ - spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb
364
+ - spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb
365
+ - spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb
366
+ - spec/routing/devise/confirmation_routing_spec.rb
367
+ - spec/routing/devise/registrations_routing_spec.rb
368
+ - spec/routing/devise/sessions_routing_spec.rb
369
+ - spec/routing/devise/passwords_routing_spec.rb
370
+ - spec/spec_helper.rb
371
+ - spec/requests/devise/authentication_spec.rb
372
+ - spec/requests/devise/registration_spec.rb
373
+ - spec/mailer/mno_enterprise/system_notification_mailer_spec.rb
374
+ - spec/lib/mno_enterprise/event_logger_spec.rb
375
+ - spec/rails_helper.rb
376
+ - spec/controllers/mno_enterprise/pages_controller_spec.rb
345
377
  - spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb
346
378
  - spec/controllers/mno_enterprise/impersonate_controller_spec.rb
379
+ - spec/controllers/mno_enterprise/provision_controller_spec.rb
380
+ - spec/controllers/mno_enterprise/org_invites_controller_spec.rb
381
+ - spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb
382
+ - spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb
347
383
  - spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb
348
384
  - spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb
349
- - spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb
350
385
  - spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb
386
+ - spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb
351
387
  - spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb
352
388
  - spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb
353
- - spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb
354
- - spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb
355
389
  - spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb
356
390
  - spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb
357
- - spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb
358
- - spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb
359
391
  - spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb
392
+ - spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb
393
+ - spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb
360
394
  - spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb
361
- - spec/controllers/mno_enterprise/org_invites_controller_spec.rb
362
- - spec/controllers/mno_enterprise/pages_controller_spec.rb
363
- - spec/controllers/mno_enterprise/provision_controller_spec.rb
395
+ - spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb
396
+ - spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb
364
397
  - spec/controllers/mno_enterprise/status_controller_spec.rb
365
- - spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb
366
- - spec/lib/mno_enterprise/event_logger_spec.rb
367
- - spec/mailer/mno_enterprise/system_notification_mailer_spec.rb
368
- - spec/rails_helper.rb
369
- - spec/requests/devise/authentication_spec.rb
370
- - spec/requests/devise/registration_spec.rb
371
- - spec/routing/devise/confirmation_routing_spec.rb
372
- - spec/routing/devise/passwords_routing_spec.rb
373
- - spec/routing/devise/registrations_routing_spec.rb
374
- - spec/routing/devise/sessions_routing_spec.rb
375
- - spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb
376
- - spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
377
- - spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb
378
- - spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb
379
- - spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb
380
- - spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb
381
- - spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb
382
- - spec/routing/mno_enterprise/jpi/v1/admin/theme_controller_routing_spec.rb
383
- - spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb
384
- - spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb
385
- - spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb
386
- - spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb
387
- - spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb
388
- - spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb
389
- - spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb
390
- - spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb
391
- - spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb
392
- - spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb
393
- - spec/routing/mno_enterprise/pages_controller_routing_spec.rb
394
- - spec/routing/mno_enterprise/provision_controller_routing_spec.rb
395
- - spec/routing/mno_enterprise/status_controller_routing_spec.rb
396
- - spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb
397
- - spec/spec_helper.rb