How to use targetToken method in wpt

Best JavaScript code snippet using wpt

TransmissionScreen.js

Source:TransmissionScreen.js Github

copy

Full Screen

1// Copyright (c) Microsoft Corporation. All rights reserved.2// Licensed under the MIT License.3import React, { Component } from 'react';4import { Image, View, SectionList, Text, TextInput, TouchableOpacity, Switch } from 'react-native';5import ModalSelector from 'react-native-modal-selector';6import Toast from 'react-native-simple-toast';7import AppCenter from 'appcenter';8import Analytics from 'appcenter-analytics';9import PropertiesConfiguratorView from './PropertiesConfiguratorView';10import SharedStyles from '../SharedStyles';11import TransmissionTabBarIcon from '../assets/fuel.png';12import Constants from '../Constants';13const targetTokens = Constants.targetTokens;14export default class TransmissionScreen extends Component {15 static navigationOptions = {16 tabBarIcon: () => <Image style={{ width: 24, height: 24 }} source={TransmissionTabBarIcon} />17 }18 standardProperties = targetTokens.reduce((map, el) => {19 map[el.key] = {20 appName: '',21 appVersion: '',22 appLocale: ''23 };24 return map;25 }, {});26 customProperties = targetTokens.reduce((map, el) => {27 map[el.key] = [];28 return map;29 }, {});30 transmissionTargets = {};31 state = {32 targetToken: targetTokens[0],33 showProperties: true,34 standardProperties: this.standardProperties[targetTokens[0].key],35 customProperties: this.customProperties[targetTokens[0].key],36 deviceIdEnabled: {},37 targetEnabled: true38 }39 async componentDidMount() {40 await AppCenter.startFromLibrary(Analytics);41 await this.createTargetsFromTokens(0, Analytics);42 const transmissionTarget = this.transmissionTargets[this.state.targetToken.key];43 if (transmissionTarget) {44 const targetEnabled = await transmissionTarget.isEnabled();45 this.setState({ targetEnabled });46 }47 }48 async createTargetsFromTokens(index, parentTarget) {49 if (index >= targetTokens.length) {50 return;51 }52 const targetToken = targetTokens[index].key;53 const transmissionTarget = await parentTarget.getTransmissionTarget(targetToken);54 this.transmissionTargets[targetToken] = transmissionTarget;55 await this.createTargetsFromTokens(++index, transmissionTarget);56 }57 async setStandardProperty(key, value) {58 if (value === '') {59 value = null;60 }61 const targetToken = this.state.targetToken.key;62 const transmissionTarget = this.transmissionTargets[targetToken];63 switch (key) {64 case 'appName':65 await transmissionTarget.propertyConfigurator.setAppName(value);66 break;67 case 'appVersion':68 await transmissionTarget.propertyConfigurator.setAppVersion(value);69 break;70 case 'appLocale':71 await transmissionTarget.propertyConfigurator.setAppLocale(value);72 break;73 default:74 throw new Error(`Unexpected key=${key}`);75 }76 this.setState((state) => {77 state.standardProperties[key] = value;78 this.standardProperties[targetToken] = state.standardProperties;79 return state;80 });81 }82 async addProperty(property) {83 const target = this.transmissionTargets[this.state.targetToken.key];84 await target.propertyConfigurator.setEventProperty(property.name, property.value);85 this.setState((state) => {86 state.customProperties.push(property);87 this.customProperties[this.state.targetToken.key] = state.customProperties;88 return state;89 });90 }91 async removeProperty(propertyName) {92 const target = this.transmissionTargets[this.state.targetToken.key];93 await target.propertyConfigurator.removeEventProperty(propertyName);94 this.setState((state) => {95 state.customProperties = state.customProperties.filter(item => item.name !== propertyName);96 this.customProperties[this.state.targetToken.key] = state.customProperties;97 return state;98 });99 }100 async replaceProperty(oldPropertyName, newProperty) {101 const target = this.transmissionTargets[this.state.targetToken.key];102 await target.propertyConfigurator.removeEventProperty(oldPropertyName);103 await target.propertyConfigurator.setEventProperty(newProperty.name, newProperty.value);104 this.setState((state) => {105 const index = state.customProperties.findIndex(el => el.name === oldPropertyName);106 state.customProperties[index] = newProperty;107 this.customProperties[this.state.targetToken.key] = state.customProperties;108 return state;109 });110 }111 render() {112 const pickerRenderItem = ({ item: { title, valueChanged, tokens } }) => (113 <ModalSelector114 data={tokens}115 initValue={title}116 onChange={valueChanged}117 style={SharedStyles.modalSelector}118 selectTextStyle={SharedStyles.itemButton}119 />120 );121 // After trying to fix the next line lint warning, the code was harder to read and format, disable it once.122 // eslint-disable-next-line object-curly-newline123 const settingsRenderItem = ({ item: { title, disabled, value, onChange } }) => (124 <View style={SharedStyles.item}>125 <Text style={SharedStyles.itemTitle}>{title}</Text>126 <Switch disabled={disabled} value={value} onValueChange={onChange} />127 </View>128 );129 const actionRenderItem = ({ item: { title, action } }) => (130 <TouchableOpacity style={SharedStyles.item} onPress={action}>131 <Text style={SharedStyles.itemButton}>{title}</Text>132 </TouchableOpacity>133 );134 const standardPropertiesRenderItem = ({ item: { title, key, onChange } }) => (135 <View style={SharedStyles.item}>136 <Text style={SharedStyles.itemTitle}>{title}</Text>137 <TextInput style={SharedStyles.itemInput} onChangeText={onChange}>{this.state.standardProperties[key]}</TextInput>138 </View>139 );140 const customPropertiesRenderItem = () => (141 <PropertiesConfiguratorView142 onPropertyAdded={() => {143 const nextItem = this.state.customProperties.length + 1;144 this.addProperty({ name: `key${nextItem}`, value: `value${nextItem}` });145 }}146 onPropertyRemoved={propertyName => this.removeProperty(propertyName)}147 onPropertyChanged={(oldPropertyName, newProperty) => this.replaceProperty(oldPropertyName, newProperty)}148 properties={this.state.customProperties}149 allowChanges={this.state.showProperties}150 />151 );152 const showEventToast = eventName => Toast.show(`Scheduled event '${eventName}'.`);153 return (154 <View style={SharedStyles.container}>155 <SectionList156 renderItem={({ item }) => <Text style={[SharedStyles.item, SharedStyles.itemTitle]}>{item}</Text>}157 renderSectionHeader={({ section: { title } }) => <Text style={SharedStyles.header}>{title}</Text>}158 keyExtractor={(item, index) => item + index}159 sections={[160 {161 title: 'Select transmission target',162 data: [163 {164 title: this.state.targetToken.label,165 valueChanged: async (option) => {166 const transmissionTarget = this.transmissionTargets[option.key];167 const targetEnabled = transmissionTarget ? await transmissionTarget.isEnabled() : false;168 this.setState({169 targetToken: option,170 showProperties: !!option.key,171 standardProperties: this.standardProperties[option.key],172 customProperties: this.customProperties[option.key],173 targetEnabled174 });175 },176 tokens: targetTokens177 },178 ],179 renderItem: pickerRenderItem180 },181 {182 title: 'Settings',183 data: [184 {185 title: 'Device ID Enabled',186 disabled: !!this.state.deviceIdEnabled[this.state.targetToken.key],187 value: !!this.state.deviceIdEnabled[this.state.targetToken.key],188 onChange: async () => {189 const transmissionTarget = this.transmissionTargets[this.state.targetToken.key];190 if (transmissionTarget) {191 this.setState({ deviceIdEnabled: { ...this.state.deviceIdEnabled, [this.state.targetToken.key]: true } });192 transmissionTarget.propertyConfigurator.collectDeviceId();193 }194 },195 },196 {197 title: 'Transmission Target Enabled',198 value: this.state.targetEnabled,199 onChange: async (value) => {200 const transmissionTarget = this.transmissionTargets[this.state.targetToken.key];201 if (transmissionTarget) {202 await transmissionTarget.setEnabled(value);203 const targetEnabled = await transmissionTarget.isEnabled();204 this.setState({ targetEnabled });205 }206 }207 }208 ],209 renderItem: settingsRenderItem210 },211 {212 title: 'Actions',213 data: [214 {215 title: 'Track event without properties',216 action: () => {217 const transmissionTarget = this.transmissionTargets[this.state.targetToken.key];218 if (transmissionTarget) {219 const eventName = 'EventWithoutPropertiesFromTarget';220 transmissionTarget.trackEvent(eventName);221 showEventToast(eventName);222 }223 }224 },225 {226 title: 'Track event with properties',227 action: () => {228 const transmissionTarget = this.transmissionTargets[this.state.targetToken.key];229 if (transmissionTarget) {230 const eventName = 'EventWithPropertiesFromTarget';231 transmissionTarget.trackEvent(eventName, { property1: '100', property2: '200' });232 showEventToast(eventName);233 }234 }235 }236 ],237 renderItem: actionRenderItem238 },239 {240 title: 'Standard Properties',241 data: [242 {243 title: 'App Name',244 key: 'appName',245 onChange: appName => this.setStandardProperty('appName', appName)246 },247 {248 title: 'App Version',249 key: 'appVersion',250 onChange: appVersion => this.setStandardProperty('appVersion', appVersion)251 },252 {253 title: 'App Locale',254 key: 'appLocale',255 onChange: appLocale => this.setStandardProperty('appLocale', appLocale)256 },257 ],258 renderItem: standardPropertiesRenderItem259 },260 {261 title: 'Properties',262 data: [{}],263 renderItem: customPropertiesRenderItem264 },265 ]}266 />267 </View>268 );269 }...

Full Screen

Full Screen

Actions.js

Source:Actions.js Github

copy

Full Screen

1/* ----- Attack Start ----- */2/**3 * @param {Roll20Object} sourceToken - Token initiating the attack4 * @param {Roll20Object} targetToken - The defending token5 * @returns {boolean}6 */7function Enchant(sourceToken, targetToken) {8 return { sourceToken, targetToken };9}10/**11 * @param {Roll20Object} sourceToken - Token initiating the attack12 * @param {Roll20Object} targetToken - The defending token13 * @returns {boolean}14 */15function Launch(sourceToken, targetToken) {16 return { sourceToken, targetToken };17}18/**19 * @param {Roll20Object} sourceToken - Token initiating the attack20 * @param {Roll20Object} targetToken - The defending token21 * @returns {boolean}22 */23function Shoot(sourceToken, targetToken) {24 return { sourceToken, targetToken };25}26/**27 * @param {Roll20Object} sourceToken - Token initiating the attack28 * @param {Roll20Object} targetToken - The defending token29 * @returns {boolean}30 */31function Simple(sourceToken, targetToken) {32 return { sourceToken, targetToken };33}34/* ----- Attack End ----- */35/* ----- Movement Start ----- */36/**37 * @param {Roll20Object} sourceToken - Token initiating the attack38 * @param {Roll20Object} targetToken - The defending token39 * @returns {boolean}40 */41function Fly(sourceToken, targetToken) {42 return { sourceToken, targetToken };43}44/**45 * @param {Roll20Object} sourceToken - Token initiating the attack46 * @param {Roll20Object} targetToken - The defending token47 * @returns {boolean}48 */49function Jump(sourceToken, targetToken) {50 return { sourceToken, targetToken };51}52/**53 * @param {Roll20Object} sourceToken - Token initiating the attack54 * @param {Roll20Object} targetToken - The defending token55 * @returns {boolean}56 */57function Swap(sourceToken, targetToken) {58 return { sourceToken, targetToken };59}60/* ----- Movement End ----- */61/* ----- Utility Start ----- */62/**63 * @param {Roll20Object} sourceToken - Token initiating the attack64 * @param {Roll20Object} targetToken - The defending token65 * @returns {boolean}66 */67function Repair(sourceToken, targetToken) {68 return { sourceToken, targetToken };69}70/**71 * @param {Roll20Object} sourceToken - Token initiating the attack72 * @param {Roll20Object} targetToken - The defending token73 * @returns {boolean}74 */75function Vitiate(sourceToken, targetToken) {76 return { sourceToken, targetToken };77}78/**79 * @param {Roll20Object} sourceToken - Token initiating the attack80 * @param {Roll20Object} targetToken - The defending token81 * @returns {boolean}82 */83function Hide(sourceToken, targetToken) {84 return { sourceToken, targetToken };85}86/* ----- Utility End ----- */87export default {88 attack: {89 Enchant,90 Launch,91 Shoot,92 Simple,93 },94 movement: {95 Fly,96 Jump,97 Swap,98 },99 utility: {100 Repair,101 Vitiate,102 Hide,103 },...

Full Screen

Full Screen

Constants.js

Source:Constants.js Github

copy

Full Screen

1const ENV = process.env.NODE_ENV || 'dev';2const CONSTANTS = {3 ENV, 4 5 EUN_REWARD_GAS:50000,6 SYMBOL_MAPPING: {7 "USDT": {8 "decimals": 6,9 "targetToken": "USDM"10 },11 "USDC": {12 "decimals": 6,13 "targetToken": "USDM"14 },15 "wBTC": {16 "decimasl": 8,17 "targetToken": "BTCM"18 },19 "ETH": {20 "decimals": 18,21 "targetToken": "ETHM"22 },23 "wETH": {24 "decimals": 18,25 "targetToken": "ETHM"26 },27 "USDM": {28 "decimals": 6,29 "targetToken": "USDM"30 },31 "BTCM": {32 "decimals": 18,33 "targetToken": "BTCM"34 },35 "ETHM": {36 "decimals": 18,37 "targetToken": "ETHM"38 }39 40 }41}42const ENUM_TRANSFER_STATUS = {43 "PENDING":1,44 "COMPLETED":2,45 "REVERTED":-1,46 "FAIL":-247}48module.exports = {49 CONSTANTS,50 ENUM_TRANSFER_STATUS...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('wpt-api')('API_KEY');2wpt.targetToken('TARGET_TOKEN', (err, data) => {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9const wpt = require('wpt-api')('API_KEY');10wpt.targetTokenUsage('TARGET_TOKEN', (err, data) => {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17const wpt = require('wpt-api')('API_KEY');18wpt.targetTokenUsageHistory('TARGET_TOKEN', (err, data) => {19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25const wpt = require('wpt-api')('API_KEY');26wpt.test('TEST_ID', (err, data) => {27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33const wpt = require('wpt-api')('API_KEY');34wpt.testResults('TEST_ID', (err, data) => {35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41const wpt = require('wpt-api')('API_KEY');42wpt.testStatus('TEST_ID', (err, data) => {43 if (err) {44 console.log(err);45 } else {46 console.log(data);47 }48});49const wpt = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.5ef5e5a5f5e5a5ef5e5a5ef5e5a5ef5e');3 if (err) return console.error(err);4 console.log('Test submitted to WebPageTest for %s', data.data.summary);5 console.log('Poll the test status at %s/jsonResult.php?test=%s', data.data.xmlUrl, data.data.testId);6});7wpt.getTestStatus('150509_5P_2b6c7b6d1f1b9c2e2b6d1f1b9c2e2b6d', function(err, data) {8 if (err) return console.error(err);9 console.log('Test status for %s: %s', data.data.testId, data.data.statusText);10});11wpt.getTestResults('150509_5P_2b6c7b6d1f1b9c2e2b6d1f1b9c2e2b6d', function(err, data) {12 if (err) return console.error(err);13 console.log('Test results for %s:', data.data.testId);14 console.log('First view: %s', data.data.average.firstView.loadTime);15 console.log('Repeat view: %s', data.data.average.repeatView.loadTime);16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptApi = require('./wptApi');2var target = process.argv[2];3var wptToken = process.argv[3];4var targetToken = wptApi.targetToken(target, wptToken, function (err, token) {5 if (err) {6 console.log('err: ', err);7 } else {8 console.log('token: ', token);9 }10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('./wptools.js');2var fs = require('fs');3var target = process.argv[2];4wptools.targetToken(target, function(token){5 wptools.pageId(token, function(pageId){6 wptools.pageData(pageId, function(pageData){7 fs.writeFile('data.json', JSON.stringify(pageData), function(err){8 if(err) throw err;9 console.log('file saved');10 });11 });12 });13});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful