added apikey
This commit is contained in:
parent
6321099f9b
commit
ba2037bad5
|
@ -7,7 +7,7 @@ class ApiKeyService extends Service {
|
|||
super('ApiKeyService');
|
||||
}
|
||||
|
||||
public regist(apikey: ApiKey): void {
|
||||
public regist(apikey: ApiKey): ApiKey {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,31 @@ export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/apikey/regist/REQUEST
|
|||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/apikey/regist/REQUEST_FAILURE';
|
||||
|
||||
// Action Creater
|
||||
export type request = () => Action<RegistPayload>;
|
||||
export type request = (ApiKey: ApiKey) => Action<RegistPayload>;
|
||||
export type requestSuccess = (apiKey: ApiKey) => Action<ApiKey>;
|
||||
export type requestFailure = (error: Error) => Action;
|
||||
|
||||
|
||||
|
||||
export const request: request = (apiKey: ApiKey): Action<RegistPayload> => {
|
||||
return {
|
||||
type: REQUEST,
|
||||
payload: {
|
||||
apiKey:apiKey,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import ApiKey from '../../api/model/ApiKey';
|
||||
|
||||
interface RegistPayload {
|
||||
signinId: string;
|
||||
signinPw: string;
|
||||
apiKey: ApiKey;
|
||||
}
|
||||
|
||||
export default RegistPayload;
|
||||
|
|
|
@ -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 RegistActions from '../action/regist';
|
||||
import RegistPayload from '../payload/RegistPayload';
|
||||
|
||||
function* regist(action: Action<RegistPayload>): SagaIterator {
|
||||
try {
|
||||
const {apiKey} = action.payload;
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: true},
|
||||
// });
|
||||
|
||||
const retApikey = yield call(AppContext.getService<ApiKeyService>().regist, apiKey);
|
||||
|
||||
// if (responseBody.token === undefined) {
|
||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||
// }
|
||||
yield put(RegistActions.requestSuccess(retApikey));
|
||||
} catch (e) {
|
||||
yield put(RegistActions.requestFailure(e));
|
||||
} finally {
|
||||
// yield put({
|
||||
// type: types.SENDING_REQUEST,
|
||||
// payload: {sendingRequest: false},
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
export function* watchSignin(): SagaIterator {
|
||||
yield takeLatest(RegistActions.REQUEST, regist);
|
||||
}
|
Loading…
Reference in New Issue
Block a user