added apikey read
This commit is contained in:
parent
cfa89c9948
commit
451c169ae6
|
@ -1,5 +1,6 @@
|
|||
import Service from '@overflow/commons/api/Service';
|
||||
import ApiKey from '../model/ApiKey';
|
||||
import Domain from '@overflow/domain/api/model/Domain';
|
||||
|
||||
|
||||
class ApiKeyService extends Service {
|
||||
|
@ -12,6 +13,10 @@ class ApiKeyService extends Service {
|
|||
return null;
|
||||
}
|
||||
|
||||
public read(domain: Domain): ApiKey {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
44
src/ts/@overflow/apikey/redux/action/read.ts
Normal file
44
src/ts/@overflow/apikey/redux/action/read.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
import Action from '@overflow/commons/redux/Action';
|
||||
import ApiKey from '../..//api/model/ApiKey';
|
||||
import Domain from '@overflow/domain/api/model/Domain';
|
||||
|
||||
import ReadPayload from '../payload/ReadPayload';
|
||||
|
||||
// Action Type
|
||||
export type REQUEST = '@overflow/apikey/read/REQUEST';
|
||||
export type REQUEST_SUCCESS = '@overflow/apikey/read/REQUEST_SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/apikey/read/REQUEST_FAILURE';
|
||||
|
||||
export const REQUEST: REQUEST = '@overflow/apikey/read/REQUEST';
|
||||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/apikey/read/REQUEST_SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/apikey/read/REQUEST_FAILURE';
|
||||
|
||||
// Action Creater
|
||||
export type request = (domain: Domain) => Action<ReadPayload>;
|
||||
export type requestSuccess = (apiKey: ApiKey) => Action<ApiKey>;
|
||||
export type requestFailure = (error: Error) => Action;
|
||||
|
||||
|
||||
|
||||
export const request: request = (domain: Domain): Action<ReadPayload> => {
|
||||
return {
|
||||
type: REQUEST,
|
||||
payload: {
|
||||
domain:domain,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const requestSuccess: requestSuccess = (apiKey: ApiKey): Action<ApiKey> => {
|
||||
return {
|
||||
type: REQUEST_SUCCESS,
|
||||
payload: apiKey,
|
||||
};
|
||||
};
|
||||
|
||||
export const requestFailure: requestFailure = (error: Error): Action => {
|
||||
return {
|
||||
type: REQUEST_FAILURE,
|
||||
error: error,
|
||||
};
|
||||
};
|
9
src/ts/@overflow/apikey/redux/payload/ReadPayload.ts
Normal file
9
src/ts/@overflow/apikey/redux/payload/ReadPayload.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
import Domain from '@overflow/domain/api/model/Domain';
|
||||
|
||||
interface ReadPayload {
|
||||
domain: Domain;
|
||||
}
|
||||
|
||||
export default ReadPayload;
|
||||
|
39
src/ts/@overflow/apikey/redux/saga/read.ts
Normal file
39
src/ts/@overflow/apikey/redux/saga/read.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { SagaIterator } from 'redux-saga';
|
||||
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
|
||||
import AppContext from '@overflow/commons/context';
|
||||
import Action from '@overflow/commons/redux/Action';
|
||||
|
||||
import ApiKey from '../../api/model/ApiKey';
|
||||
import ApiKeyService from '../../api/service/ApiKeyService';
|
||||
import * as ReadActions from '../action/read';
|
||||
import ReadPayload from '../payload/ReadPayload';
|
||||
|
||||
function* read(action: Action<ReadPayload>): SagaIterator {
|
||||
try {
|
||||
const {domain} = action.payload;
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
|
||||
const retApikey = yield call(AppContext.getService<ApiKeyService>().read, domain);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
// }
|
||||
yield put(ReadActions.requestSuccess(retApikey));
|
||||
} catch (e) {
|
||||
yield put(ReadActions.requestFailure(e));
|
||||
} finally {
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: false},
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchSignin(): SagaIterator {
|
||||
yield takeLatest(ReadActions.REQUEST, read);
|
||||
}
|
Loading…
Reference in New Issue
Block a user