Skip to content

Commit

Permalink
refactor(api-core): pass config object to core classes
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Options to core classes are being passed in as config object instead of parameters.
  • Loading branch information
KaseyPowers authored and robmcguinness committed Jan 6, 2018
1 parent a48a072 commit d7b859c
Show file tree
Hide file tree
Showing 52 changed files with 758 additions and 187 deletions.
8 changes: 7 additions & 1 deletion packages/api-angular/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ function factory($http, $q, avApiOptions) {
throw new Error('[options] cannot be null or undefined');
}
options = angular.merge({}, avApiOptions, options);
super($http, $q, options);

super({
http: $http,
promise: $q,
merge: angular.merge,
config: options,
});
}
}
return AvApi;
Expand Down
7 changes: 6 additions & 1 deletion packages/api-angular/src/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ import angular from 'angular';
import { AvLogMessages } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvLogMessages($http, $q, angular.copy(avApiOptions));
new AvLogMessages({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ import angular from 'angular';
import { AvNavigation } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvNavigation($http, $q, angular.copy(avApiOptions));
new AvNavigation({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
17 changes: 7 additions & 10 deletions packages/api-angular/src/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import angular from 'angular';

import { AvNotification } from '@availity/api-core';

function factory($http, $q, avApiOptions) {
class AvNotificationApi extends AvNotification {
constructor() {
const theseOptions = angular.copy(avApiOptions);
super($http, $q, theseOptions);
}
}
return new AvNotificationApi();
}
export default factory;
export default ($http, $q, avApiOptions) =>
new AvNotification({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
8 changes: 7 additions & 1 deletion packages/api-angular/src/organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ import angular from 'angular';
import { AvOrganizations } from '@availity/api-core';

export default ($http, $q, avUsersApi, avApiOptions) =>
new AvOrganizations($http, $q, avUsersApi, angular.copy(avApiOptions));
new AvOrganizations({
http: $http,
promise: $q,
merge: angular.merge,
avUsers: avUsersApi,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/pdfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ import angular from 'angular';
import { AvPdf } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvPdf($http, $q, angular.copy(avApiOptions));
new AvPdf({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ import angular from 'angular';
import { AvPermissions } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvPermissions($http, $q, angular.copy(avApiOptions));
new AvPermissions({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ import angular from 'angular';
import { AvProviders } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvProviders($http, $q, angular.copy(avApiOptions));
new AvProviders({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ function factory($http, $q, avApiOptions) {
class AvProxyApi extends AvProxy {
constructor(options) {
options = angular.merge({}, avApiOptions, options);
super($http, $q, options);
super({
http: $http,
promise: $q,
merge: angular.merge,
config: options,
});
}
}
return AvProxyApi;
Expand Down
8 changes: 7 additions & 1 deletion packages/api-angular/src/regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ import angular from 'angular';
import { AvRegions } from '@availity/api-core';

export default ($http, $q, avUsersApi, avApiOptions) =>
new AvRegions($http, $q, avUsersApi, angular.copy(avApiOptions));
new AvRegions({
http: $http,
promise: $q,
merge: angular.merge,
avUsers: avUsersApi,
config: angular.copy(avApiOptions),
});
18 changes: 7 additions & 11 deletions packages/api-angular/src/spaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ import angular from 'angular';

import { AvSpaces } from '@availity/api-core';

function factory($http, $q, avApiOptions) {
class AvSpacesApi extends AvSpaces {
constructor() {
const options = angular.copy(avApiOptions);
super($http, $q, options);
}
}
return new AvSpacesApi();
}

export default factory;
export default ($http, $q, avApiOptions) =>
new AvSpaces({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ import angular from 'angular';
import { AvUsers } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvUsers($http, $q, angular.copy(avApiOptions));
new AvUsers({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
7 changes: 6 additions & 1 deletion packages/api-angular/src/userPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ import angular from 'angular';
import { AvUserPermissions } from '@availity/api-core';

export default ($http, $q, avApiOptions) =>
new AvUserPermissions($http, $q, angular.copy(avApiOptions));
new AvUserPermissions({
http: $http,
promise: $q,
merge: angular.merge,
config: angular.copy(avApiOptions),
});
11 changes: 9 additions & 2 deletions packages/api-axios/src/api.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import axios from 'axios';

import utils from 'axios/lib/utils';
import Api from '@availity/api-core';

const { merge } = utils;

export default class AvApi extends Api {
constructor(options) {
super(axios, Promise, options);
super({
http: axios,
promise: Promise,
merge,
config: options,
});
}
}
10 changes: 8 additions & 2 deletions packages/api-axios/src/logs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import axios from 'axios';

import utils from 'axios/lib/utils';
import { AvLogMessages } from '@availity/api-core';

export default new AvLogMessages(axios, Promise);
const { merge } = utils;

export default new AvLogMessages({
http: axios,
promise: Promise,
merge,
});
8 changes: 7 additions & 1 deletion packages/api-axios/src/navigation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvNavigation } from '@availity/api-core';

export default new AvNavigation(axios, Promise);
const { merge } = utils;
export default new AvNavigation({
http: axios,
promise: Promise,
merge,
});
10 changes: 8 additions & 2 deletions packages/api-axios/src/notification.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import axios from 'axios';

import utils from 'axios/lib/utils';
import { AvNotification } from '@availity/api-core';

const { merge } = utils;
class AvNotificationApi extends AvNotification {
constructor(options) {
super(axios, Promise, options);
super({
http: axios,
promise: Promise,
merge,
config: options,
});
}
}

Expand Down
10 changes: 8 additions & 2 deletions packages/api-axios/src/organizations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import axios from 'axios';

import utils from 'axios/lib/utils';
import { AvOrganizations } from '@availity/api-core';
import avUserApi from './user';

export default new AvOrganizations(axios, Promise, avUserApi);
const { merge } = utils;
export default new AvOrganizations({
http: axios,
promise: Promise,
merge,
avUsers: avUserApi,
});
8 changes: 7 additions & 1 deletion packages/api-axios/src/pdf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvPdf } from '@availity/api-core';

export default new AvPdf(axios, Promise);
const { merge } = utils;
export default new AvPdf({
http: axios,
promise: Promise,
merge,
});
8 changes: 7 additions & 1 deletion packages/api-axios/src/permissions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvPermissions } from '@availity/api-core';

export default new AvPermissions(axios, Promise);
const { merge } = utils;
export default new AvPermissions({
http: axios,
promise: Promise,
merge,
});
9 changes: 7 additions & 2 deletions packages/api-axios/src/providers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import axios from 'axios';

import utils from 'axios/lib/utils';
import { AvProviders } from '@availity/api-core';

export default new AvProviders(axios, Promise);
const { merge } = utils;
export default new AvProviders({
http: axios,
promise: Promise,
merge,
});
10 changes: 8 additions & 2 deletions packages/api-axios/src/proxy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import axios from 'axios';

import utils from 'axios/lib/utils';
import { AvProxy } from '@availity/api-core';

const { merge } = utils;
export default class AvProxyApi extends AvProxy {
constructor(options) {
super(axios, Promise, options);
super({
http: axios,
promise: Promise,
merge,
config: options,
});
}
}
9 changes: 8 additions & 1 deletion packages/api-axios/src/regions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvRegions } from '@availity/api-core';
import userApi from './user';

export default new AvRegions(axios, Promise, userApi);
const { merge } = utils;
export default new AvRegions({
http: axios,
promise: Promise,
merge,
avUsers: userApi,
});
8 changes: 7 additions & 1 deletion packages/api-axios/src/spaces.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvSpaces } from '@availity/api-core';

export default new AvSpaces(axios, Promise);
const { merge } = utils;
export default new AvSpaces({
http: axios,
promise: Promise,
merge,
});
8 changes: 7 additions & 1 deletion packages/api-axios/src/user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvUsers } from '@availity/api-core';

export default new AvUsers(axios, Promise);
const { merge } = utils;
export default new AvUsers({
http: axios,
promise: Promise,
merge,
});
8 changes: 7 additions & 1 deletion packages/api-axios/src/userPermissions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import axios from 'axios';
import utils from 'axios/lib/utils';
import { AvUserPermissions } from '@availity/api-core';

export default new AvUserPermissions(axios, Promise);
const { merge } = utils;
export default new AvUserPermissions({
http: axios,
promise: Promise,
merge,
});
Loading

0 comments on commit d7b859c

Please sign in to comment.