Last active
May 5, 2016 18:04
-
-
Save iamdustan/9dd288e4dd0dda7fad0b17d88dbb6e7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* File generated on 2015-01-01T00:00:00.000Z against https://path.to.swaggerdocs.com/example | |
* | |
* @flow | |
**/ | |
/* eslint-disable */ | |
import type {Action} from 'redux'; | |
import {apiBase} from '../../../config'; | |
import bind from 'bind-effect'; | |
import {fetch} from 'redux-effects-fetch'; | |
import {createAction} from 'redux-actions'; | |
import {assert, serialize} from './_utils'; | |
import {GET_EXAMPLE_ENDPOINT_REQUEST, GET_EXAMPLE_ENDPOINT_SUCCESS, GET_EXAMPLE_ENDPOINT_ERROR} from '../../constants/actions'; | |
const onGetExampleEndpointRequest = createAction(GET_EXAMPLE_ENDPOINT_REQUEST); | |
const onGetExampleEndpointSuccess = createAction(GET_EXAMPLE_ENDPOINT_SUCCESS); | |
const onGetExampleEndpointError = createAction(GET_EXAMPLE_ENDPOINT_ERROR); | |
export type GetExampleEndpoint = {someParam: string}; | |
export function getExampleEndpoint(options: GetExampleEndpoint): Array<Action> { | |
assert(options, getAccessPoint.optionTypes, 'ExampleEndpointActions.getExampleEndpoint'); | |
const url = `${apiBase}/example/${options.someParam}`; | |
return [onGetExampleEndpointRequest({ | |
options, | |
url | |
}), bind(fetch(url, { | |
method: 'get' | |
}), res => onGetExampleEndpointSuccess(Object.assign({ | |
options, | |
url | |
}, res)), res => onGetExampleEndpointError(Object.assign({ | |
options, | |
url | |
}, res)))]; | |
}; | |
getExampleEndpoint.optionTypes = { | |
someParam: { | |
required: true, | |
paramType: 'path', | |
type: 'string' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment