Skip to content

Commit

Permalink
Add getNetworkDetails action
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya committed Dec 2, 2018
1 parent c8febb2 commit 665f21a
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 3 deletions.
53 changes: 53 additions & 0 deletions src/actions/getNetworkDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { withActionOutput } from '../utils';

import WFCellularDetail from '../interfaces/WF/WFCellularDetail';
import WFNetworkDetailsNetwork from '../interfaces/WF/WFNetworkDetailsNetwork';
import WFSerialization from '../interfaces/WF/WFSerialization';
import WFWiFiDetail from '../interfaces/WF/WFWiFiDetail';
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction';

/**
* Get Network Details Action. Gets various network-related information from
* the device.
*
* ```js
* getNetworkDetails({
* network: 'Wi-Fi',
* get: 'Network Name',
* });
*
* getNetworkDetails({
* network: 'Cellular',
* get: 'Carrier Name',
* });
* ```
*/
const getNetworkDetails = (
options: {
/** The type of network to look at */
network?: WFNetworkDetailsNetwork,

/** The particular network detail to retrieve */
attribute?: WFSerialization | WFWiFiDetail | WFCellularDetail,
},
): WFWorkflowAction => {
const {
network = 'Wi-Fi',
attribute = 'Network Name',
} = options;

let detailKey = 'WFWiFiDetail';
if (network === 'Cellular') {
detailKey = 'WFCellularDetail';
}

return {
WFWorkflowActionIdentifier: 'is.workflow.actions.getwifi',
WFWorkflowActionParameters: {
WFNetworkDetailsNetwork: network,
[detailKey]: attribute,
},
};
};

export default withActionOutput(getNetworkDetails);
2 changes: 2 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import getCurrentIpAddress from './getCurrentIpAddress';
import getDeviceDetails from './getDeviceDetails';
import getDictionaryValue from './getDictionaryValue';
import getName from './getName';
import getNetworkDetails from './getNetworkDetails';
import getType from './getType';
import getVariable from './getVariable';
import nothing from './nothing';
Expand Down Expand Up @@ -52,6 +53,7 @@ export {
getDeviceDetails,
getDictionaryValue,
getName,
getNetworkDetails,
getType,
getVariable,
nothing,
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/WF/WFCellularDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type WFCellularDetail = (
'Carrier Name'
| 'Radio Technology'
| 'Country Code'
| 'WFTextTokenAttachment'
);

export default WFCellularDetail;
6 changes: 6 additions & 0 deletions src/interfaces/WF/WFNetworkDetailsNetwork.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type WFNetworkDetailsNetwork = (
'Wi-Fi'
| 'Cellular'
);

export default WFNetworkDetailsNetwork;
6 changes: 6 additions & 0 deletions src/interfaces/WF/WFWiFiDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type WFWiFiDetail = (
'Network Name'
| 'BSSID'
);

export default WFWiFiDetail;
1 change: 1 addition & 0 deletions src/interfaces/WF/WFWorkflowActionIdentifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type WFWorkflowActionIdentifier = (
| 'is.workflow.actions.gettext'
| 'is.workflow.actions.getvalueforkey'
| 'is.workflow.actions.getvariable'
| 'is.workflow.actions.getwifi'
| 'is.workflow.actions.handoff'
| 'is.workflow.actions.lowpowermode.set'
| 'is.workflow.actions.math'
Expand Down
8 changes: 5 additions & 3 deletions src/interfaces/WF/WFWorkflowActionParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import WFInputType from './WFInputType';
import WFIPAddressSourceOption from './WFIPAddressSourceOption';
import WFIPAddressTypeOption from './WFIPAddressTypeOption';
import WFMathOperation from './WFMathOperation';
import WFNetworkDetailsNetwork from './WFNetworkDetailsNetwork';
import WFSerialization from './WFSerialization';

interface WFWorkflowActionParameters {
Expand Down Expand Up @@ -39,24 +40,25 @@ interface WFWorkflowActionParameters {
WFHTTPBodyType?: WFHTTPBodyType;
WFHTTPHeaders?: WFSerialization;
WFHTTPMethod?: WFHTTPMethod;
WFInputType?: WFInputType;
WFIPAddressSourceOption?: WFIPAddressSourceOption;
WFIPAddressTypeOption?: WFIPAddressTypeOption;
WFInputType?: WFInputType;
WFJSONValues?: WFSerialization;
WFMathOperand?: number;
WFMathOperation?: WFMathOperation;
WFMenuItems?: string[];
WFMenuItemTitle?: string;
WFMenuItems?: string[];
WFMenuPrompt?: string;
WFName?: string;
WFNetworkDetailsNetwork?: WFNetworkDetailsNetwork;
WFNumberActionNumber?: number;
WFNumberValue?: number;
WFShowWorkflow?: boolean;
WFSSHHost?: WFSerialization | string;
WFSSHPassword?: WFSerialization | string;
WFSSHPort?: WFSerialization | string;
WFSSHScript?: WFSerialization | string;
WFSSHUser?: WFSerialization | string;
WFShowWorkflow?: boolean;
WFTextActionText?: WFSerialization | string;
WFURLActionURL?: string;
WFVariable?: WFSerialization | string;
Expand Down

0 comments on commit 665f21a

Please sign in to comment.